﻿/* ===========================================
   AIVEK User Dashboard - Minimal Black & White Theme
   =========================================== */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #000000;
    min-height: 100vh;
    color: #ffffff;
    overflow-x: hidden;
}

/* Animated Background */
.dashboard-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
    opacity: 0.3;
}

.floating-cube {
    position: absolute;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    animation: floatUp 25s infinite linear;
    border-radius: 8px;
}

.floating-cube:nth-child(1) { left: 5%; width: 40px; height: 40px; animation-delay: 0s; }
.floating-cube:nth-child(2) { left: 25%; width: 60px; height: 60px; animation-delay: -5s; animation-duration: 30s; }
.floating-cube:nth-child(3) { left: 45%; width: 35px; height: 35px; animation-delay: -10s; }
.floating-cube:nth-child(4) { left: 65%; width: 50px; height: 50px; animation-delay: -15s; animation-duration: 28s; }
.floating-cube:nth-child(5) { left: 85%; width: 45px; height: 45px; animation-delay: -8s; }

@keyframes floatUp {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 0.5; }
    90% { opacity: 0.5; }
    100% { transform: translateY(-100vh) rotate(720deg); opacity: 0; }
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Sidebar */
.dashboard-sidebar {
    width: 280px;
    background: #000000;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 200;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-decoration: none;
    display: block;
}

/* User Profile in Sidebar */
.sidebar-user {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #ffffff;
    color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.user-avatar.has-image {
    color: transparent;
    text-shadow: none;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-plan {
    font-size: 0.8rem;
    color: #a0a0a0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.plan-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    border: 1px solid rgba(255,255,255,0.3);
}

.badge-free { background: transparent; color: #a0a0a0; }
.badge-basic { background: transparent; color: #ffffff; border-color: #ffffff; }
.badge-pro { background: #ffffff; color: #000000; border-color: #ffffff; }

/* Sidebar Navigation */
.sidebar-nav {
    padding: 16px 12px;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #666;
    padding: 0 12px;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    color: #a0a0a0;
    text-decoration: none;
    transition: all 0.2s;
    margin-bottom: 4px;
    cursor: pointer;
}

.nav-item i {
    width: 20px;
    margin-right: 12px;
    font-size: 1rem;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.nav-item.active {
    background: #ffffff;
    color: #000000;
}

.nav-item.active i {
    color: #000000;
}

.nav-item.danger {
    color: #ff6b6b;
}

.nav-item.danger:hover {
    background: rgba(255, 0, 0, 0.1);
}

/* Main Content */
.dashboard-main {
    flex: 1;
    margin-left: 280px;
    padding: 32px;
    min-height: 100vh;
    overflow-x: hidden;
    min-width: 0;
}

/* Top Bar */
.dashboard-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.topbar-title h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
}

.topbar-subtitle {
    color: #a0a0a0;
    font-size: 0.9rem;
}

.topbar-actions {
    display: flex;
    gap: 12px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

/* Mobile Menu Toggle */
.mobile-menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Cards */
.dashboard-card {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}

.dashboard-card.glass {
    background: #000000;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
}

.card-subtitle {
    font-size: 0.85rem;
    color: #a0a0a0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
}

.stat-card:hover {
    border-color: #ffffff;
}

.stat-card::before {
    display: none;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    background: transparent;
}

/* Monochrome icons overrides */
.stat-icon.purple, .stat-icon.pink, .stat-icon.blue, .stat-icon.green { 
    background: transparent; 
    color: #ffffff; 
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.85rem;
    color: #a0a0a0;
}

/* Usage Progress */
.usage-progress {
    margin-top: 12px;
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #ffffff;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #a0a0a0;
    margin-top: 6px;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    font-size: 0.9rem;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}

/* Chat Item */
.chat-item {
    display: flex;
    align-items: center;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #ffffff;
}

.chat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    margin-right: 16px;
}

.chat-info {
    flex: 1;
}

.chat-title {
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
}

.chat-meta {
    font-size: 0.8rem;
    color: #a0a0a0;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.chat-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: #a0a0a0;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-action-btn:hover {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

.chat-action-btn.danger:hover {
    background: #ff6b6b;
    color: #ffffff;
    border-color: #ff6b6b;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 50px; /* PILL */
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: #ffffff;
    color: #000000;
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: #e0e0e0;
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.15);
}

.btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #ffffff;
}

.btn-danger {
    background: transparent;
    border: 1px solid rgba(255, 0, 0, 0.3);
    color: #ff6b6b;
}

.btn-danger:hover {
    background: #ff6b6b;
    color: #ffffff;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.8rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #a0a0a0;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: #ffffff;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #ffffff;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 1);
}

.form-input::placeholder {
    color: #666;
}

/* Toggle Switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toggle-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
}

.toggle-info p {
    font-size: 0.8rem;
    color: #a0a0a0;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #ffffff;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: #000000;
}

/* GDPR Section */
.gdpr-section {
    background: rgba(255, 0, 0, 0.05);
    border: 1px solid rgba(255, 0, 0, 0.2);
    border-radius: 16px;
    padding: 24px;
    margin-top: 24px;
}

.gdpr-section h3 {
    color: #ff6b6b;
    font-size: 1rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gdpr-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #ffffff;
}

.empty-state h3 {
    font-size: 1.2rem;
    color: #ffffff;
    margin-bottom: 8px;
}

.empty-state p {
    color: #a0a0a0;
    margin-bottom: 24px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: #a0a0a0;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #ffffff;
    color: #000000;
}

.modal-body {
    color: #a0a0a0;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Alert Messages */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid #22c55e;
    color: #22c55e;
}

.alert-error {
    background: rgba(255, 0, 0, 0.05);
    border: 1px solid #ef4444;
    color: #ef4444;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid #f59e0b;
    color: #f59e0b;
}

/* Hidden Sections */
.dashboard-section {
    display: none;
}

.dashboard-section.active {
    display: block;
}

/* Vision Pro Section */
.vision-status-box {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    border-radius: 16px;
    transition: all 0.3s ease;
}

.vision-status-box.inactive {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.vision-status-box.active {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #22c55e;
}

.vision-status-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.vision-status-box.inactive .vision-status-icon {
    background: transparent;
    color: #a0a0a0;
}

.vision-status-box.active .vision-status-icon {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border-color: #22c55e;
}

.vision-status-info h4 {
    font-size: 1.2rem;
    color: #ffffff;
    margin-bottom: 6px;
}

.vision-status-box.active .vision-status-info h4 {
    color: #22c55e;
}

.vision-status-info p {
    color: #a0a0a0;
    font-size: 0.95rem;
}

/* Feature Items Grid */
.feature-item {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.feature-item:hover {
    border-color: #ffffff;
    transform: translateY(-4px);
}

.feature-icon {
    width: 48px;
    height: 48px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #ffffff;
    margin-bottom: 16px;
}

.feature-item h4 {
    color: #ffffff;
    font-size: 1rem;
    margin-bottom: 8px;
}

.feature-item p {
    color: #a0a0a0;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Active key indicator */
.stat-icon.active {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }
}

/* Vision Key Active Section */
#visionKeyActive .toggle-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#visionKeyActive .toggle-info h4 {
    font-size: 1rem;
    margin-bottom: 4px;
}

/* Clickable stat cards */
.stat-card.clickable {
    cursor: pointer;
    transition: all 0.3s ease;
}

.stat-card.clickable:hover {
    transform: translateY(-4px);
    border-color: #ffffff;
}

/* Badge styles for PRO */
.badge-pro {
    background: #ffffff !important;
    color: #000000 !important;
}

.badge-free {
    background: transparent;
    color: #a0a0a0;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Responsive */

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 199;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
    display: block;
}

/* ===== Tablet (≤1024) ===== */
@media (max-width: 1024px) {
    .dashboard-sidebar {
        transform: translateX(-100%);
        z-index: 1000;
    }
    
    .dashboard-sidebar.open {
        transform: translateX(0);
    }
    
    .dashboard-main {
        margin-left: 0;
        padding: 24px 20px;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    /* Topbar */
    .dashboard-topbar {
        flex-direction: row;
        gap: 12px;
        align-items: center;
        flex-wrap: nowrap;
        margin-bottom: 24px;
    }
    
    .topbar-title {
        display: flex;
        align-items: center;
        gap: 12px;
        flex: 1;
        min-width: 0;
    }
    
    .topbar-title h1 {
        font-size: 1.3rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .topbar-subtitle {
        display: none;
    }
    
    .topbar-actions {
        flex-shrink: 0;
    }
    
    .topbar-actions .btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    /* Stats: 2 columns on tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    /* Modal tweaks for tablet */
    .modal-content {
        max-width: 90vw;
        padding: 24px;
    }
}

/* ===== Large phones / small tablets (≤768) ===== */
@media (max-width: 768px) {
    .dashboard-main {
        padding: 20px 16px;
    }

    .dashboard-topbar {
        padding: 0;
        margin-bottom: 20px;
    }
    
    .topbar-title h1 {
        font-size: 1.15rem;
    }
    
    .topbar-actions .btn {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    /* Cards */
    .dashboard-card {
        padding: 18px;
        border-radius: 14px;
        margin-bottom: 18px;
    }

    .card-header {
        margin-bottom: 16px;
    }

    /* Chat items: horizontal but compact */
    .chat-item {
        padding: 14px;
        gap: 12px;
        border-radius: 12px;
        margin-bottom: 10px;
        flex-wrap: nowrap;
    }

    .chat-icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        margin-right: 12px;
        font-size: 0.9rem;
        flex-shrink: 0;
    }

    .chat-info {
        min-width: 0;
    }

    .chat-title {
        font-size: 0.92rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chat-meta {
        font-size: 0.75rem;
    }

    /* Stat cards */
    .stat-card {
        padding: 16px;
        border-radius: 14px;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        border-radius: 10px;
        font-size: 1.05rem;
        margin-bottom: 12px;
    }

    .stat-value {
        font-size: 1.6rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    /* Vision status box */
    .vision-status-box {
        padding: 18px;
        gap: 16px;
        flex-direction: column;
        text-align: center;
    }

    .vision-status-icon {
        width: 56px;
        height: 56px;
        border-radius: 14px;
        font-size: 1.4rem;
    }

    /* Modals full-width on phones */
    .modal-content {
        width: 96%;
        max-width: 96vw;
        padding: 20px;
        border-radius: 16px;
        max-height: 92vh;
    }
    
    .modal-title {
        font-size: 1.1rem;
    }

    /* Empty state */
    .empty-state {
        padding: 40px 16px;
    }

    .empty-icon {
        width: 64px;
        height: 64px;
        font-size: 1.6rem;
    }

    .empty-state h3 {
        font-size: 1.05rem;
    }

    /* Feature items grid */
    .feature-item {
        padding: 16px;
    }

    .feature-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        margin-bottom: 12px;
    }
}

/* ===== Phones (≤640) ===== */
@media (max-width: 640px) {
    .dashboard-main {
        padding: 16px 12px;
    }
    
    /* Stats: 2-col compact grid, NOT 1-col */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 14px;
        border-radius: 12px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        border-radius: 8px;
        font-size: 0.9rem;
        margin-bottom: 10px;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .stat-label {
        font-size: 0.72rem;
    }

    /* Topbar */
    .topbar-title h1 {
        font-size: 1.05rem;
    }
    
    .topbar-actions .btn span {
        display: none;
    }
    
    .topbar-actions .btn i {
        margin-right: 0;
    }

    .topbar-actions .btn {
        padding: 10px 14px;
        min-width: 42px;
    }

    /* Mobile menu button */
    .mobile-menu-btn {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }

    /* Cards */
    .dashboard-card {
        padding: 14px;
        border-radius: 12px;
        margin-bottom: 14px;
    }

    .card-header {
        margin-bottom: 14px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .card-title {
        font-size: 1rem;
    }

    /* Chat items: stay horizontal, just tighter */
    .chat-item {
        padding: 12px;
        gap: 10px;
        margin-bottom: 8px;
    }

    .chat-icon {
        width: 36px;
        height: 36px;
        border-radius: 8px;
        margin-right: 10px;
        font-size: 0.85rem;
    }

    .chat-title {
        font-size: 0.88rem;
    }

    .chat-meta {
        font-size: 0.72rem;
    }

    .chat-actions {
        gap: 6px;
        flex-shrink: 0;
    }

    .chat-action-btn {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }

    /* GDPR */
    .gdpr-actions {
        flex-direction: column;
    }
    
    .gdpr-actions .btn {
        width: 100%;
    }

    /* Toggle wrappers */
    .toggle-wrapper {
        padding: 14px 0;
        gap: 12px;
    }

    .toggle-info h4 {
        font-size: 0.9rem;
    }

    .toggle-info p {
        font-size: 0.75rem;
    }

    /* Buttons */
    .btn {
        font-size: 0.85rem;
        padding: 10px 18px;
    }

    .btn-sm {
        padding: 8px 12px;
        font-size: 0.78rem;
    }

    /* Form */
    .form-input {
        padding: 11px 14px;
        font-size: 0.9rem;
        border-radius: 10px;
    }

    .form-label {
        font-size: 0.82rem;
    }

    /* Feature items: 1 col on small phones */
    .feature-item {
        padding: 14px;
        border-radius: 10px;
    }

    .feature-item h4 {
        font-size: 0.92rem;
    }

    .feature-item p {
        font-size: 0.8rem;
    }

    /* Vision status */
    .vision-status-box {
        padding: 16px;
        gap: 14px;
        border-radius: 14px;
    }

    .vision-status-info h4 {
        font-size: 1rem;
    }

    .vision-status-info p {
        font-size: 0.85rem;
    }

    /* Modal */
    .modal-content {
        width: 100%;
        max-width: 100vw;
        border-radius: 16px 16px 0 0;
        max-height: 95vh;
        padding: 18px 14px;
        margin-top: auto;
    }

    .modal-overlay {
        align-items: flex-end;
    }

    .modal-header {
        margin-bottom: 16px;
    }

    /* Sidebar styling for mobile */
    .dashboard-sidebar {
        width: 280px;
    }

    .sidebar-header {
        padding: 18px 20px;
    }

    .sidebar-user {
        padding: 16px 20px;
    }

    .nav-item {
        padding: 11px 14px;
        font-size: 0.92rem;
    }

    /* Better scrolling */
    .dashboard-main {
        -webkit-overflow-scrolling: touch;
    }
}

/* ===== Very small phones (≤380) ===== */
@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-icon {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
        margin-bottom: 8px;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.68rem;
    }

    .dashboard-main {
        padding: 12px 8px;
    }

    .dashboard-card {
        padding: 12px;
    }

    .card-title {
        font-size: 0.92rem;
    }

    .chat-icon {
        display: none;
    }

    .chat-item {
        padding: 10px;
    }

    .modal-content {
        padding: 16px 12px;
    }
}
