/**
 * Styles Mobile-Friendly pour ITEA
 * Optimisé pour smartphones et tablettes
 */

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Mobile First - Base styles pour mobile */
@media (max-width: 767px) {
    
    /* ========== LAYOUT GÉNÉRAL ========== */
    body {
        font-size: 14px;
        overflow-x: hidden;
    }
    
    .container,
    .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* ========== SIDEBAR ========== */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        position: fixed;
        z-index: 9999;
        transition: transform 0.3s ease;
    }
    
    .sidebar.active,
    .sidebar-open .sidebar {
        transform: translateX(0);
    }
    
    /* Overlay pour fermer sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
    }
    
    /* ========== TOPBAR / NAVBAR ========== */
    .topbar,
    .main-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        padding: 0.5rem 0.75rem !important;
        flex-wrap: nowrap !important;
        gap: 0.5rem !important;
        overflow: visible !important;
        left: 0 !important;
    }
    .topbar { display: flex !important; align-items: center !important; }
    
    .topbar-left {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        overflow: hidden !important;
        max-width: 100% !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }
    
    .topbar-title {
        flex: 1 !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }
    
    .topbar-title h2 {
        font-size: 0.9rem !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }
    
    .topbar-title p {
        display: none !important;
    }
    
    .topbar-center {
        display: none !important; /* Cacher recherche sur mobile */
    }
    
    .topbar-right {
        gap: 0.25rem !important;
        flex-shrink: 0 !important; /* garder les icônes visibles */
        flex-wrap: nowrap !important;
        min-width: auto !important;
    }

    /* Ultra-narrow tweaks */
    @media (max-width: 380px) {
        .topbar-menu-toggle { width: 34px !important; height: 34px !important; }
        .topbar-btn { width: 34px !important; height: 34px !important; }
        .hamburger-icon { font-size: 20px !important; }
        .topbar-right { gap: 0.2rem !important; }
        .topbar-title h2 { font-size: 0.85rem !important; }
    }
    
    .topbar-btn {
        width: 38px !important;
        height: 38px !important;
        font-size: 16px !important;
        flex-shrink: 0 !important;
        background: #e0f2fe !important;
    }
    
    .topbar-btn i {
        display: block !important;
        visibility: visible !important;
        color: #0369a1 !important;
        font-size: 16px !important;
    }
    
    .topbar-btn:hover {
        background: #3b82f6 !important;
    }
    
    .topbar-btn:hover i {
        color: white !important;
    }
    
    .topbar-user {
        padding: 0.25rem !important;
    }
    
    .topbar-user-avatar {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
    }
    
    .topbar-user-info {
        display: none !important; /* Cacher nom utilisateur sur mobile */
    }
    
    .topbar-user i.fa-chevron-down {
        display: none !important;
    }
    
    .topbar-menu-toggle {
        flex-shrink: 0 !important;
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #e0f2fe !important;
        color: #0369a1 !important;
    }
    
    .hamburger-icon {
        display: block !important;
        visibility: visible !important;
        color: #0369a1 !important;
        font-size: 22px !important;
        font-weight: normal !important;
        line-height: 1 !important;
    }
    
    .topbar-menu-toggle:hover {
        background: #3b82f6 !important;
    }
    
    .topbar-menu-toggle:hover .hamburger-icon {
        color: white !important;
    }
    
    .icon-text {
        font-size: 18px !important;
        line-height: 1 !important;
    }
    
    .topbar .navbar-brand {
        font-size: 1.1rem;
    }
    
    .topbar .nav-link {
        padding: 0.5rem;
    }
    
    /* Hamburger menu */
    .navbar-toggler {
        border: none;
        padding: 0.5rem;
    }
    
    .navbar-toggler:focus {
        box-shadow: none;
    }
    
    /* ========== CONTENT AREA ========== */
    .main-content,
    .content-wrapper {
        margin-left: 0 !important;
        padding: 1rem !important;
        width: 100%;
        font-size: 1rem !important; /* Augmenter taille texte */
    }
    
    .content-header {
        padding: 1rem 0.5rem;
    }
    
    .content-header h1 {
        font-size: 1.75rem !important; /* Plus grand */
        margin-bottom: 0.75rem;
        line-height: 1.3;
    }
    
    .breadcrumb {
        font-size: 0.85rem;
        padding: 0.5rem 0;
        margin-bottom: 0;
    }
    
    /* ========== CARDS ========== */
    .card {
        margin-bottom: 1rem;
        border-radius: 0.75rem;
    }
    
    .card-header {
        padding: 1rem 1.25rem !important;
        font-size: 1.05rem !important;
    }
    
    .card-body {
        padding: 1.25rem !important; /* Plus d'espace */
        font-size: 1rem !important;
    }
    
    .card-title {
        font-size: 1.25rem !important; /* Plus grand */
        margin-bottom: 1rem;
        font-weight: 600;
    }
    
    .card-text,
    .card-body p {
        font-size: 1rem !important;
        line-height: 1.6;
    }
    
    /* Small boxes (statistiques) */
    .small-box {
        margin-bottom: 1rem;
    }
    
    .small-box .inner h3 {
        font-size: 1.8rem;
    }
    
    .small-box .inner p {
        font-size: 0.9rem;
    }
    
    .small-box .icon {
        font-size: 50px !important;
        top: 10px;
        right: 10px;
    }
    
    /* ========== TABLES ========== */
    .table-responsive {
        border: none;
        margin-bottom: 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        font-size: 0.95rem !important; /* Plus grand */
        min-width: 600px; /* Scroll horizontal si nécessaire */
    }
    
    .table thead th {
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
        white-space: nowrap;
        background: #f8f9fa;
        font-weight: 600;
    }
    
    .table tbody td {
        padding: 0.75rem !important;
        font-size: 0.95rem !important;
        line-height: 1.5;
    }
    
    /* Cacher certaines colonnes sur mobile */
    .table .d-none-mobile {
        display: none !important;
    }
    
    /* Actions dans les tables */
    .table .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .table .btn-sm {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* ========== BUTTONS ========== */
    .btn {
        padding: 0.75rem 1.25rem !important;
        font-size: 1rem !important; /* Plus grand */
        min-height: 44px; /* Touch-friendly */
    }
    
    .btn-sm {
        padding: 0.5rem 1rem !important;
        font-size: 0.9rem !important;
        min-height: 38px;
    }
    
    .btn-lg {
        padding: 1rem 2rem !important;
        font-size: 1.1rem !important;
        min-height: 50px;
    }
    
    /* Boutons pleine largeur sur mobile */
    .btn-block-mobile {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Groupe de boutons */
    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group-mobile .btn {
        width: 100%;
    }
    
    /* ========== FORMS ========== */
    .form-group,
    .mb-3 {
        margin-bottom: 1.25rem;
    }
    
    .form-label {
        font-size: 1rem !important; /* Plus grand */
        margin-bottom: 0.5rem;
        font-weight: 500;
    }
    
    .form-control,
    .form-select {
        font-size: 1rem !important; /* Plus grand */
        padding: 0.75rem 1rem !important;
        min-height: 44px; /* Touch-friendly */
    }
    
    .form-control:focus,
    .form-select:focus {
        font-size: 16px !important; /* Évite le zoom sur iOS */
    }
    
    .form-text,
    .invalid-feedback,
    .valid-feedback {
        font-size: 0.9rem !important;
    }
    
    /* Formulaires inline deviennent verticaux */
    .form-inline {
        flex-direction: column;
    }
    
    .form-inline .form-control,
    .form-inline .form-select {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* ========== MODALS ========== */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content {
        border-radius: 0.5rem;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 0.75rem;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 0.25rem 0;
    }
    
    /* ========== ALERTS ========== */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }
    
    .alert .btn-close {
        padding: 0.5rem;
    }
    
    /* ========== BADGES ========== */
    .badge {
        font-size: 0.75rem;
        padding: 0.35em 0.65em;
    }
    
    /* ========== PAGINATION ========== */
    .pagination {
        font-size: 0.85rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-link {
        padding: 0.375rem 0.75rem;
    }
    
    /* Cacher certains numéros de page */
    .pagination .d-none-mobile {
        display: none !important;
    }
    
    /* ========== DROPDOWNS ========== */
    .dropdown-menu {
        font-size: 0.9rem;
        min-width: 200px;
    }
    
    .dropdown-item {
        padding: 0.5rem 1rem;
    }
    
    /* ========== TABS ========== */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-tabs .nav-link {
        white-space: nowrap;
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }
    
    /* ========== LISTS ========== */
    .list-group-item {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    /* ========== IMAGES ========== */
    img {
        max-width: 100%;
        height: auto;
    }
    
    .img-thumbnail {
        padding: 0.25rem;
    }
    
    /* ========== UTILITIES ========== */
    .text-mobile-center {
        text-align: center !important;
    }
    
    .d-mobile-none {
        display: none !important;
    }
    
    .d-mobile-block {
        display: block !important;
    }
    
    /* Espacements réduits */
    .p-mobile-2 {
        padding: 0.5rem !important;
    }
    
    .m-mobile-2 {
        margin: 0.5rem !important;
    }
    
    /* ========== FOOTER ========== */
    footer {
        padding: 1rem;
        font-size: 0.85rem;
        text-align: center;
    }
    
    /* ========== SPECIFIC COMPONENTS ========== */
    
    /* User Panel */
    .user-panel {
        padding: 0.75rem;
    }
    
    .user-panel img {
        width: 2rem;
        height: 2rem;
    }
    
    .user-panel .info {
        font-size: 0.9rem;
    }
    
    /* Info boxes */
    .info-box {
        margin-bottom: 1rem;
    }
    
    .info-box-icon {
        width: 70px;
    }
    
    .info-box-content {
        padding: 0.5rem;
    }
    
    .info-box-text {
        font-size: 0.85rem;
    }
    
    .info-box-number {
        font-size: 1.3rem;
    }
    
    /* Timeline */
    .timeline {
        padding-left: 0;
    }
    
    .timeline-item {
        padding-left: 1rem;
    }
    
    /* DataTables */
    .dataTables_wrapper {
        font-size: 0.85rem;
    }
    
    .dataTables_filter input {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .dataTables_length select {
        width: auto;
    }
}

/* ============================================
   TABLET (768px - 991px)
   ============================================ */

@media (min-width: 768px) and (max-width: 991px) {
    .sidebar {
        width: 250px;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .table {
        font-size: 0.9rem;
    }
    
    .card-body {
        padding: 1.25rem;
    }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */

@media (max-width: 767px) and (orientation: landscape) {
    .sidebar {
        width: 250px;
    }
    
    .modal-body {
        max-height: 50vh;
    }
    
    .content-header h1 {
        font-size: 1.3rem;
    }
}

/* ============================================
   TOUCH IMPROVEMENTS
   ============================================ */

/* Augmenter la zone de clic sur mobile */
@media (max-width: 767px) {
    a, button, .btn, .nav-link, .dropdown-item {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    
    /* Améliorer le feedback tactile */
    .btn:active,
    .nav-link:active,
    .dropdown-item:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* ============================================
   ADMINLTE SPECIFIC OVERRIDES
   ============================================ */

@media (max-width: 767px) {
    /* Sidebar AdminLTE */
    .sidebar-mini.sidebar-collapse .main-sidebar {
        margin-left: 0;
    }
    
    .sidebar-mini .main-sidebar {
        transform: translateX(-250px);
    }
    
    .sidebar-mini.sidebar-open .main-sidebar {
        transform: translateX(0);
    }
    
    /* Content wrapper */
    .content-wrapper {
        margin-left: 0 !important;
    }
    
    /* Main header */
    .main-header {
        margin-left: 0 !important;
    }
    
    /* Brand link */
    .brand-link {
        padding: 0.8rem 1rem;
    }
    
    .brand-text {
        font-size: 1.1rem;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .sidebar,
    .main-header,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .main-content,
    .content-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}
