/* ============================================
   DATACTIVE - Mobile Responsive CSS
   Shared across all app pages with sidebar
   ============================================ */

/* Hamburger button */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 10001;
    background: var(--primary-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    padding: 0;
}
.hamburger-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    margin: 4px auto;
    border-radius: 2px;
    transition: all 0.3s ease;
}
.hamburger-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}
.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}
.hamburger-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
    opacity: 1;
}

/* ============================================
   MOBILE BREAKPOINT (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
    /* Show hamburger */
    .hamburger-btn {
        display: flex;
    }

    /* Sidebar: hidden by default, slide-in on mobile */
    .sidebar {
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        width: 260px !important;
        height: 100vh !important;
        z-index: 9999 !important;
        transition: left 0.3s ease !important;
        overflow-y: auto !important;
    }
    .sidebar.mobile-open {
        left: 0 !important;
    }
    /* Override collapsed state on mobile */
    .sidebar.collapsed {
        width: 260px !important;
        left: -280px !important;
    }
    .sidebar.collapsed.mobile-open {
        left: 0 !important;
    }
    .sidebar.collapsed .sidebar-logo-text,
    .sidebar.collapsed .nav-item span,
    .sidebar.collapsed .profile-text,
    .sidebar.collapsed .credits-text {
        display: block !important;
    }
    .sidebar.collapsed .nav-item {
        justify-content: flex-start !important;
        padding: 10px 16px !important;
    }

    /* Main content: full width */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding-top: 56px !important;
    }
    .app-layout {
        flex-direction: column !important;
    }

    /* Top bar adjustments */
    .top-bar {
        padding: 8px 12px 8px 56px !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .search-bar {
        max-width: 100% !important;
        width: 100% !important;
        order: 2 !important;
    }
    .top-bar-actions {
        order: 1 !important;
        margin-left: auto !important;
    }

    /* Cards & grids responsive */
    .dashboard, .cards-grid, .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        padding: 12px !important;
    }
    .card-completude, .card-coach, .card-activity,
    .card-veilles, .card-pipeline {
        grid-column: span 1 !important;
    }

    /* Tables responsive */
    .table-container, .data-table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-width: 100vw !important;
    }
    table {
        min-width: 600px;
    }

    /* Forms responsive */
    .form-row, .form-group-row, .filter-row, .filters {
        flex-direction: column !important;
        gap: 8px !important;
    }
    .form-group, .filter-group {
        width: 100% !important;
        min-width: 0 !important;
    }
    input, select, textarea, .form-control {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    input:not([type="checkbox"]):not([type="radio"]),
    select, textarea {
        font-size: 16px !important; /* Prevent iOS zoom */
    }

    /* Buttons responsive */
    .btn, button:not(.hamburger-btn):not(.icon-btn):not(.sidebar-toggle) {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    /* Modal responsive */
    .modal-content, .modal-dialog {
        width: 95vw !important;
        max-width: 95vw !important;
        margin: 10px auto !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    /* Tabs responsive */
    .tabs, .tab-list {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        flex-wrap: nowrap !important;
    }
    .tab, .tab-item {
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    /* Content padding */
    .content, .page-content, .main-section {
        padding: 12px !important;
    }
    .content-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        padding: 12px !important;
    }
    .content-header h1, .content-header h2, .page-title {
        font-size: 1.3rem !important;
    }

    /* Action bars */
    .action-bar, .toolbar {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    /* Hide sidebar toggle button on mobile (use hamburger instead) */
    .sidebar-footer .icon-btn:nth-child(2) {
        display: none !important;
    }

    /* Stats cards */
    .stat-card, .metric-card, .info-card {
        min-width: 0 !important;
        width: 100% !important;
    }
    .stats-row, .metrics-row {
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* Scroll fix */
    body {
        overflow-x: hidden !important;
    }

    /* login-left on some pages */
    .login-left {
        display: none !important;
    }
    .login-right {
        flex: 1 !important;
        width: 100% !important;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .hamburger-btn {
        top: 8px;
        left: 8px;
        width: 36px;
        height: 36px;
    }
    .main-content {
        padding-top: 50px !important;
    }
    .top-bar {
        padding: 6px 8px 6px 48px !important;
    }
    .content, .page-content, .main-section {
        padding: 8px !important;
    }
    .content-header h1, .content-header h2, .page-title {
        font-size: 1.1rem !important;
    }
    .modal-content, .modal-dialog {
        width: 98vw !important;
    }
}
