/**
 * CANDIDATE MOBILE FIX - Solution Complète Responsivité Dashboard Candidat
 * RDConnect Job Platform - Optimisation Mobile 100%
 * Date: 30 Novembre 2025
 */

/* ============================================
   VARIABLES GLOBALES
   ============================================ */
:root {
    --mobile-padding: 12px;
    --mobile-card-gap: 12px;
    --mobile-font-sm: 0.75rem;
    --mobile-font-md: 0.875rem;
    --mobile-font-lg: 1rem;
    --primary-color: #0891b2;
    --sidebar-width-mobile: 280px;
    --header-height-mobile: 60px;
}

/* ============================================
   RESET MOBILE GÉNÉRAL
   ============================================ */
@media (max-width: 991.98px) {
    
    /* Container principal */
    .main-content {
        padding-left: var(--mobile-padding) !important;
        padding-right: var(--mobile-padding) !important;
        padding-top: calc(var(--header-height-mobile) + 15px) !important;
    }
    
    .container-fluid {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* Rows sans marges excessives */
    .row {
        margin-left: -6px !important;
        margin-right: -6px !important;
        margin-bottom: var(--mobile-card-gap) !important;
    }
    
    .row > [class*="col-"] {
        padding-left: 6px !important;
        padding-right: 6px !important;
        margin-bottom: var(--mobile-card-gap) !important;
    }
}

/* ============================================
   HEADER MOBILE OPTIMISÉ
   ============================================ */
@media (max-width: 991.98px) {
    
    /* Header compact */
    .app-header {
        height: var(--header-height-mobile) !important;
        position: fixed !important;
        top: 0 !important;
        width: 100% !important;
        z-index: 1041 !important;
        background: #fff !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    }
    
    .main-header-container {
        padding: 0.5rem 0.75rem !important;
    }
    
    /* Hamburger menu visible */
    .sidemenu-toggle,
    .header-link[data-bs-toggle="sidebar"] {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 40px !important;
        height: 40px !important;
        padding: 8px !important;
        margin-right: 8px !important;
    }
    
    /* Page title - Version compacte */
    .header-element .page-title {
        font-size: 0.95rem !important;
        margin-bottom: 0 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 150px !important;
    }
    
    .breadcrumb-container {
        display: none !important; /* Cacher breadcrumb sur mobile */
    }
    
    /* Cacher les boutons "Mon Profil" et "Mon CV" dans le header */
    .header-content-right .header-element a.btn {
        display: none !important;
    }
    
    /* Icons du header - Taille optimisée */
    .header-link-icon {
        font-size: 1.25rem !important;
    }
    
    .header-icon-badge {
        font-size: 0.65rem !important;
        padding: 0.15em 0.35em !important;
    }
    
    /* Profile dropdown - Compact */
    .header-element .d-sm-block {
        display: none !important;
    }
}

/* ============================================
   SIDEBAR MOBILE - SLIDE OUT
   ============================================ */
@media (max-width: 991.98px) {
    
    /* Sidebar cachée par défaut */
    .app-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: calc(-1 * var(--sidebar-width-mobile)) !important;
        width: var(--sidebar-width-mobile) !important;
        height: 100vh !important;
        z-index: 1050 !important;
        background: #fff !important;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1) !important;
        transition: left 0.3s ease-in-out !important;
        overflow-y: auto !important;
        padding-top: 0 !important;
    }
    
    /* Sidebar visible avec classe */
    body.sidebar-open .app-sidebar,
    html.sidebar-open .app-sidebar {
        left: 0 !important;
    }
    
    /* Overlay sombre */
    .mobile-sidebar-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(0, 0, 0, 0.5) !important;
        z-index: 1049 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: opacity 0.3s ease, visibility 0.3s ease !important;
    }
    
    body.sidebar-open .mobile-sidebar-overlay,
    html.sidebar-open .mobile-sidebar-overlay {
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Menu items */
    .app-sidebar .side-menu__label {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .app-sidebar .side-menu__item {
        padding: 12px 16px !important;
        font-size: 0.9rem !important;
    }
}

/* ============================================
   BANNER PREMIUM - VERSION MOBILE
   ============================================ */
@media (max-width: 767.98px) {
    
    /* Banner compact */
    .alert {
        padding: 0.75rem !important;
        margin-bottom: 1rem !important;
    }
    
    .alert .d-flex {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }
    
    .alert .flex-shrink-0 {
        display: none !important; /* Cacher l'icône couronne */
    }
    
    .alert .alert-heading {
        font-size: 0.95rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    .alert p {
        font-size: 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .alert .d-flex.gap-2 {
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.5rem !important;
    }
    
    .alert .badge {
        font-size: 0.7rem !important;
        padding: 0.25rem 0.5rem !important;
        align-self: flex-start !important;
    }
    
    .alert .btn {
        width: 100% !important;
        font-size: 0.85rem !important;
        padding: 0.5rem !important;
    }
    
    .alert .btn-close {
        position: absolute !important;
        top: 0.5rem !important;
        right: 0.5rem !important;
        font-size: 0.8rem !important;
    }
}

/* ============================================
   STATISTICS CARDS - MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 767.98px) {
    
    /* Cards en colonne unique */
    .row > [class*="col-xl-3"],
    .row > [class*="col-lg-6"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    
    /* Card body compact */
    .custom-card .card-body {
        padding: 0.75rem !important;
    }
    
    /* Stats display */
    .custom-card .d-flex {
        gap: 0.5rem !important;
    }
    
    .custom-card h2 {
        font-size: 1.5rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    .custom-card .fs-13 {
        font-size: 0.8rem !important;
    }
    
    .custom-card .fs-12 {
        font-size: 0.75rem !important;
    }
    
    /* Avatar icons */
    .custom-card .avatar-md {
        width: 2.5rem !important;
        height: 2.5rem !important;
        font-size: 1.2rem !important;
    }
    
    /* Badge lock pour premium */
    .custom-card .badge {
        font-size: 0.65rem !important;
        padding: 0.2rem 0.4rem !important;
    }
    
    /* Carte blurred (premium) */
    .custom-card.position-relative .position-absolute.top-50 {
        z-index: 10 !important;
    }
    
    .custom-card.position-relative .btn {
        font-size: 0.75rem !important;
        padding: 0.4rem 0.8rem !important;
    }
}

/* ============================================
   QUICK ACTIONS - MOBILE GRID
   ============================================ */
@media (max-width: 767.98px) {
    
    /* Quick actions en 2 colonnes */
    .row.g-3 > [class*="col-xl-2"],
    .row.g-3 > [class*="col-lg-4"] {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    
    /* Buttons quick actions */
    .btn-wave {
        padding: 0.75rem 0.5rem !important;
        font-size: 0.75rem !important;
        min-height: 80px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
    }
    
    .btn-wave i {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .btn-wave .fw-semibold {
        font-size: 0.7rem !important;
        line-height: 1.2 !important;
    }
}

/* Extra small - 1 colonne pour quick actions */
@media (max-width: 480px) {
    .row.g-3 > [class*="col-xl-2"],
    .row.g-3 > [class*="col-lg-4"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* ============================================
   RECENT APPLICATIONS TABLE - MOBILE
   ============================================ */
@media (max-width: 767.98px) {
    
    /* Card header */
    .card-header {
        padding: 0.75rem !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
    
    .card-header .card-title {
        font-size: 0.95rem !important;
        flex: 1 !important;
    }
    
    .card-header .btn-sm {
        font-size: 0.75rem !important;
        padding: 0.35rem 0.7rem !important;
    }
    
    /* Table responsive - Mode card */
    .table-responsive {
        border: none !important;
        overflow-x: visible !important;
    }
    
    .table-responsive table {
        display: none !important; /* Cacher le tableau standard */
    }
    
    /* Empty state */
    .text-center.py-5 {
        padding: 2rem 1rem !important;
    }
    
    .text-center.py-5 i {
        font-size: 2.5rem !important;
    }
    
    .text-center.py-5 h5 {
        font-size: 1rem !important;
    }
    
    .text-center.py-5 p {
        font-size: 0.85rem !important;
    }
}

/* ============================================
   PROFILE COMPLETION & RECOMMENDATIONS
   ============================================ */
@media (max-width: 991.98px) {
    
    /* Colonnes en pleine largeur */
    .row > .col-xl-4,
    .row > .col-xl-8 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    
    /* Card spacing */
    .custom-card.mb-3 {
        margin-bottom: 1rem !important;
    }
    
    /* Progress bar */
    .progress-sm {
        height: 6px !important;
    }
    
    /* Recommended jobs */
    .custom-card .d-flex.align-items-center {
        gap: 0.5rem !important;
    }
    
    .custom-card h6 {
        font-size: 0.85rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    .custom-card .fs-11 {
        font-size: 0.7rem !important;
    }
    
    .custom-card .btn-sm {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.6rem !important;
        white-space: nowrap !important;
    }
}

/* ============================================
   PREMIUM BENEFITS SECTION - MOBILE
   ============================================ */
@media (max-width: 767.98px) {
    
    .card-body.p-4 {
        padding: 1rem !important;
    }
    
    .card-body h3 {
        font-size: 1.1rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .card-body h3 i {
        font-size: 1.3rem !important;
    }
    
    .card-body p {
        font-size: 0.85rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Benefits list en 1 colonne */
    .card-body .row.g-3 {
        row-gap: 0.5rem !important;
    }
    
    .card-body .row.g-3 > .col-md-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    
    .card-body .d-flex i {
        font-size: 1.2rem !important;
    }
    
    .card-body .d-flex span {
        font-size: 0.8rem !important;
    }
    
    /* Pricing box */
    .card-body .p-4.bg-white {
        padding: 1rem !important;
    }
    
    .card-body .fs-1 {
        font-size: 1.5rem !important;
    }
    
    .card-body .btn-lg {
        font-size: 0.9rem !important;
        padding: 0.6rem 1rem !important;
    }
    
    .card-body .small,
    .card-body small {
        font-size: 0.7rem !important;
    }
}

/* ============================================
   UTILITIES & HELPERS MOBILE
   ============================================ */
@media (max-width: 767.98px) {
    
    /* Text utilities */
    .text-mobile-truncate {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 120px !important;
    }
    
    /* Hide on mobile */
    .mobile-hide {
        display: none !important;
    }
    
    /* Show only on mobile */
    .mobile-only {
        display: block !important;
    }
    
    /* Spacing utilities */
    .mb-mobile-2 {
        margin-bottom: 0.5rem !important;
    }
    
    .p-mobile-1 {
        padding: 0.5rem !important;
    }
    
    /* Flex utilities */
    .flex-mobile-column {
        flex-direction: column !important;
    }
    
    .gap-mobile-2 {
        gap: 0.5rem !important;
    }
}

/* ============================================
   MODAL RESPONSIVE
   ============================================ */
@media (max-width: 767.98px) {
    
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
    
    .modal-content {
        border-radius: 0.5rem !important;
    }
    
    .modal-header {
        padding: 1rem !important;
    }
    
    .modal-body {
        padding: 1rem !important;
    }
    
    .modal-footer {
        padding: 0.75rem 1rem !important;
    }
    
    .modal-title {
        font-size: 1rem !important;
    }
}

/* ============================================
   SCROLL TO TOP BUTTON - MOBILE
   ============================================ */
@media (max-width: 767.98px) {
    
    .scrollToTop {
        width: 45px !important;
        height: 45px !important;
        bottom: 20px !important;
        right: 15px !important;
    }
    
    .scrollToTop .arrow {
        font-size: 1.2rem !important;
    }
}

/* ============================================
   DROPDOWN MENUS - MOBILE
   ============================================ */
@media (max-width: 767.98px) {
    
    .dropdown-menu {
        font-size: 0.85rem !important;
        max-width: 90vw !important;
    }
    
    .dropdown-item {
        padding: 0.6rem 1rem !important;
    }
    
    .dropdown-header {
        font-size: 0.8rem !important;
        padding: 0.5rem 1rem !important;
    }
}

/* ============================================
   CARDS APPLICATION MOBILE - ALTERNATIVE À TABLE
   ============================================ */
@media (max-width: 767.98px) {
    
    /* Créer des cards pour chaque application */
    .application-mobile-card {
        background: #f8f9fa;
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .application-mobile-card .company-info {
        display: flex;
        align-items: center;
        margin-bottom: 0.5rem;
        gap: 0.5rem;
    }
    
    .application-mobile-card .company-info img {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        object-fit: cover;
    }
    
    .application-mobile-card .job-title {
        font-weight: 600;
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
        color: #333;
    }
    
    .application-mobile-card .company-name {
        font-size: 0.8rem;
        color: #6c757d;
    }
    
    .application-mobile-card .meta-info {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid #dee2e6;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .application-mobile-card .date {
        font-size: 0.75rem;
        color: #6c757d;
    }
    
    .application-mobile-card .status-badge {
        font-size: 0.7rem;
    }
    
    .application-mobile-card .action-btn {
        font-size: 0.75rem;
        padding: 0.35rem 0.7rem;
    }
}

/* ============================================
   LOADING STATES - MOBILE
   ============================================ */
@media (max-width: 767.98px) {
    
    .spinner-border-sm {
        width: 1rem !important;
        height: 1rem !important;
    }
    
    .skeleton-loader {
        height: 60px !important;
        margin-bottom: 0.5rem !important;
    }
}

/* ============================================
   ACCESSIBILITY - MOBILE TOUCH TARGETS
   ============================================ */
@media (max-width: 767.98px) {
    
    /* Minimum touch target size (44x44px) */
    .btn,
    .header-link,
    .dropdown-toggle,
    .nav-link,
    .side-menu__item {
        min-height: 44px !important;
        min-width: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Links avec padding suffisant */
    a:not(.btn) {
        padding: 0.25rem !important;
    }
}

/* ============================================
   PRINT - MOBILE
   ============================================ */
@media print {
    
    .app-sidebar,
    .app-header,
    .mobile-sidebar-overlay,
    .scrollToTop,
    .btn-close,
    .dropdown,
    .modal {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        page-break-inside: avoid !important;
    }
}

/* ============================================
   ORIENTATION CHANGES
   ============================================ */
@media (max-width: 767.98px) and (orientation: landscape) {
    
    /* Header plus compact en paysage */
    .app-header {
        height: 50px !important;
    }
    
    .main-content {
        padding-top: 60px !important;
    }
    
    /* Sidebar plus étroite */
    .app-sidebar {
        width: 240px !important;
        left: -240px !important;
    }
}

/* ============================================
   DARK MODE - MOBILE (si activé)
   ============================================ */
@media (max-width: 767.98px) {
    
    [data-theme-mode="dark"] .app-sidebar {
        background: #1a1d29 !important;
    }
    
    [data-theme-mode="dark"] .app-header {
        background: #1a1d29 !important;
        border-bottom-color: #2d3142 !important;
    }
    
    [data-theme-mode="dark"] .custom-card {
        background: #1a1d29 !important;
        border-color: #2d3142 !important;
    }
    
    [data-theme-mode="dark"] .mobile-sidebar-overlay {
        background: rgba(0, 0, 0, 0.7) !important;
    }
}
