/* ===================================
   RESPONSIVE STYLES
   Mobile & Tablet Responsive Design
   Hamburger Menu + Sticky Header/Footer
   =================================== */

/* ========== MOBILE HEADER / FOOTER (hidden on desktop) ========== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #0d0d12;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 9998;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.mobile-header .brand-mobile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-header .brand-mobile img {
    max-height: 28px;
    width: auto;
}

.mobile-header .brand-mobile .brand-name {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
}

.mobile-header .brand-mobile .brand-sub {
    font-size: 9px;
    color: #a78bfa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hamburger-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    color: #fff;
    font-size: 20px;
    transition: all 0.2s;
}

.hamburger-btn:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.3);
}

.mobile-header .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-header .logout-btn-mobile {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-header .logout-btn-mobile:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Mobile sidebar overlay */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-sidebar-drawer {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: #0d0d12;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 10000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mobile-sidebar-drawer.open {
    left: 0;
}

.mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mobile-drawer-header .drawer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-drawer-header .drawer-brand img {
    max-height: 28px;
    width: auto;
}

.mobile-drawer-header .drawer-brand-text .brand-name {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    display: block;
}

.mobile-drawer-header .drawer-brand-text .brand-sub {
    font-size: 9px;
    color: #a78bfa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.close-drawer-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    color: #888;
    font-size: 18px;
    transition: all 0.2s;
}

.close-drawer-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.mobile-drawer-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.mobile-drawer-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: #888;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.mobile-drawer-nav a:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #ccc;
}

.mobile-drawer-nav a.active {
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
    border-left-color: #a78bfa;
}

.mobile-drawer-nav .drawer-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin: 8px 20px;
}

.mobile-drawer-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.mobile-drawer-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    color: #ef4444;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

/* Sticky Footer */
.mobile-footer {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: #0d0d12;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 9997;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.mobile-footer-content {
    display: flex;
    align-items: center;
    justify-content: space-around;
    width: 100%;
    max-width: 400px;
}

.mobile-footer-content a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: #666;
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.mobile-footer-content a:hover,
.mobile-footer-content a.active {
    color: #a78bfa;
}

.mobile-footer-content a svg {
    width: 20px;
    height: 20px;
}

/* ========== TABLET (768px - 1024px) ========== */
@media screen and (max-width: 1024px) {

    .sa-sidebar,
    .admin-sidebar {
        width: 200px !important;
    }

    .sa-main {
        margin-left: 200px !important;
        padding: 20px !important;
    }

    .admin-main {
        margin-left: 200px !important;
        padding: 20px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .stat-card {
        padding: 16px !important;
    }

    .stat-card .value,
    .stat-value {
        font-size: 1.5rem !important;
    }

    .form-row {
        grid-template-columns: 1fr 1fr !important;
    }

    .form-row.three {
        grid-template-columns: 1fr 1fr !important;
    }

    .modal-content,
    .modal-box,
    .modal-container {
        width: 90% !important;
        max-width: 90% !important;
        padding: 24px !important;
    }

    .data-table,
    .detail-table,
    .details-table,
    table {
        font-size: 12px !important;
    }

    .data-table th,
    .data-table td,
    th,
    td {
        padding: 10px 8px !important;
    }

    .sa-header h1 {
        font-size: 1.4rem !important;
    }

    .dashboard-grid {
        grid-template-columns: 220px 1fr !important;
        gap: 20px !important;
    }

    .dashboard-container {
        padding: 16px !important;
    }

    .pricing-grid {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* ========== MOBILE (max-width: 768px) ========== */
@media screen and (max-width: 768px) {

    /* Show mobile header, footer */
    .mobile-header {
        display: flex !important;
    }

    .mobile-footer {
        display: flex !important;
    }

    /* Hide desktop sidebar completely */
    .sa-sidebar,
    .admin-sidebar {
        display: none !important;
    }

    /* Layout adjustments */
    .sa-layout,
    .admin-layout {
        flex-direction: column !important;
    }

    /* Main content fills full width, offset for sticky header/footer */
    .sa-main,
    .admin-main {
        margin-left: 0 !important;
        padding: 72px 16px 66px 16px !important;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .stat-card {
        padding: 14px !important;
    }

    .stat-card .value,
    .stat-value {
        font-size: 1.3rem !important;
    }

    .stat-card .label,
    .stat-label {
        font-size: 0.7rem !important;
    }

    .stat-card .sub {
        font-size: 0.65rem !important;
    }

    /* Forms stack */
    .form-row,
    .form-row.three {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    /* Modals */
    .modal-content,
    .modal-box,
    .modal-container {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        padding: 20px !important;
        border-radius: 16px !important;
        min-width: unset !important;
    }

    .modal-box.narrow {
        max-width: 95% !important;
    }

    /* Tables responsive */
    .data-table,
    .detail-table,
    .details-table,
    table {
        display: block !important;
        overflow-x: auto !important;
        font-size: 11px !important;
    }

    .data-table th,
    .data-table td,
    th,
    td {
        padding: 8px 6px !important;
        white-space: nowrap !important;
    }

    /* Cards */
    .glass-card,
    .form-card,
    .data-card {
        padding: 16px !important;
        border-radius: 12px !important;
    }

    /* Role group headers */
    .role-group-header {
        font-size: 0.85rem !important;
        padding: 10px 14px !important;
    }

    .company-group-header {
        font-size: 0.75rem !important;
        padding: 8px 12px !important;
    }

    /* Buttons */
    .btn-download {
        font-size: 0.7rem !important;
        padding: 6px 12px !important;
    }

    .btn-save {
        width: 100% !important;
        text-align: center !important;
    }

    /* Headers */
    .sa-header h1 {
        font-size: 1.2rem !important;
    }

    .sa-header p {
        font-size: 0.8rem !important;
    }

    .detail-modal-header {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    /* Search */
    .search-container {
        flex-direction: column !important;
    }

    .search-input {
        width: 100% !important;
    }

    /* User menu - hide on mobile since header has logout */
    .user-menu-top .user-menu-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }

    .user-dropdown {
        right: 0 !important;
        left: auto !important;
    }

    /* Permission checkboxes */
    div[style*="grid-template-columns: 1fr 1fr 1fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Action buttons */
    .btn-action {
        width: 28px !important;
        height: 28px !important;
    }

    .btn-action i {
        width: 12px !important;
        height: 12px !important;
    }

    /* Section divider */
    .section-divider {
        display: none !important;
    }

    /* ========== DASHBOARD.PHP ========== */
    .dashboard-container {
        padding: 68px 12px 66px 12px !important;
        margin: 0 !important;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .side-nav {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        border-radius: 12px !important;
    }

    .side-nav-link {
        white-space: nowrap !important;
        padding: 10px 14px !important;
        flex-shrink: 0 !important;
    }

    .premium-card {
        padding: 20px !important;
        border-radius: 16px !important;
    }

    .pricing-grid {
        grid-template-columns: 1fr !important;
    }

    .pricing-card {
        padding: 16px !important;
    }

    .usage-bar-container {
        height: 100px !important;
    }

    .usage-bar-label {
        font-size: 9px !important;
    }

    /* ========== LOGIN PAGE ========== */
    .login-container,
    .auth-card {
        max-width: 95% !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        margin: 16px auto !important;
        padding: 24px !important;
    }

    /* ========== CHAT INTERFACE ========== */
    .chat-sidebar {
        position: fixed !important;
        z-index: 100 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s !important;
    }

    .chat-sidebar.open {
        transform: translateX(0) !important;
    }

    .chat-main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Manager inline grids */
    div[style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Toast */
    #search-toast,
    #toast {
        left: 16px !important;
        right: 16px !important;
        bottom: 66px !important;
        font-size: 0.8rem !important;
    }
}

/* ========== SMALL MOBILE (max-width: 480px) ========== */
@media screen and (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    .stat-card .value,
    .stat-value {
        font-size: 1.1rem !important;
    }

    .sa-main,
    .admin-main {
        padding: 68px 12px 62px 12px !important;
    }

    .form-card,
    .glass-card,
    .data-card {
        padding: 12px !important;
    }

    .modal-content,
    .modal-box,
    .modal-container {
        padding: 16px !important;
    }

    h2 {
        font-size: 1.1rem !important;
    }

    h3 {
        font-size: 0.95rem !important;
    }

    div[style*="grid-template-columns: 1fr 1fr 1fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    .user-menu-top {
        display: none !important;
    }

    div[style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: 1fr !important;
    }

    .mobile-sidebar-drawer {
        width: 260px;
    }
}