/* AutoSalesAI Dashboard Styles */

/* CSS Variables for Theme */
:root {
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --bg-sidebar: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #dee2e6;
    --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --transition: all 0.3s ease;
    --sidebar-width: 250px;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-body: #1a1a2e;
    --bg-card: #16213e;
    --bg-sidebar: linear-gradient(180deg, #0f0f1a 0%, #16213e 100%);
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --text-muted: #6c757d;
    --border-color: #2d3748;
    --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3);
}

/* Apply Theme */
body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    transition: var(--transition);
}

.card {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card-header {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

.table {
    color: var(--text-primary);
}

.table-light {
    --bs-table-bg: var(--bg-body);
    --bs-table-color: var(--text-primary);
}

.list-group-item {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.list-group-item-action:hover {
    background-color: var(--bg-body);
}

.text-muted {
    color: var(--text-muted) !important;
}

/* Theme Toggle Button */
.theme-toggle {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    transition: var(--transition);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Form Controls in Dark Mode */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #0f3460;
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #16213e;
    border-color: #0d6efd;
    color: var(--text-primary);
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted);
}

/* Alert modifications for dark mode */
[data-theme="dark"] .alert-success {
    background-color: rgba(25, 135, 84, 0.2);
    border-color: rgba(25, 135, 84, 0.3);
}

[data-theme="dark"] .alert-danger {
    background-color: rgba(220, 53, 69, 0.2);
    border-color: rgba(220, 53, 69, 0.3);
}

/* Code styling */
code {
    background-color: var(--bg-body);
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
}

/* Badge adjustments */
[data-theme="dark"] .badge.bg-light {
    background-color: #2d3748 !important;
    color: var(--text-primary) !important;
}

/* Chart container */
canvas {
    max-width: 100%;
}

/* Stat cards gradient effect */
.card.bg-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.card.bg-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%) !important;
}

.card.bg-info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%) !important;
}

.card.bg-warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
}

/* =========================
   MOBILE RESPONSIVE STYLES
   ========================= */

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1100;
    background: #1a1a2e;
    color: white;
    border: none;
    border-radius: 8px;
    width: 45px;
    height: 45px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* Mobile responsive tables */
.table-responsive-mobile {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    min-width: 300px;
    margin-bottom: 10px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Global Search */
.global-search {
    position: relative;
    max-width: 400px;
}

.global-search .search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.global-search .search-result-item {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.global-search .search-result-item:hover {
    background: var(--bg-body);
}

.global-search .search-result-item:last-child {
    border-bottom: none;
}

/* ===============
   MEDIA QUERIES
   =============== */

/* Tablet */
@media (max-width: 992px) {
    :root {
        --sidebar-width: 200px;
    }

    .sidebar .nav-link {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
        height: 100vh;
        transition: left 0.3s ease;
        z-index: 1001;
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 70px 15px 15px;
    }

    /* Stack stat cards */
    .row .col-md-3 {
        margin-bottom: 15px;
    }

    /* Table adjustments */
    .table td,
    .table th {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    /* Hide some columns on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Card adjustments */
    .card-body {
        padding: 1rem;
    }

    /* Button groups */
    .btn-group-sm .btn {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
    }

    /* Toast on mobile */
    .toast-container {
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 20px;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }

    /* Search on mobile */
    .global-search {
        max-width: 100%;
    }

    /* Page title */
    h2 {
        font-size: 1.5rem;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .sidebar .brand {
        font-size: 1rem;
    }

    .card h2,
    .card h3 {
        font-size: 1.5rem;
    }

    .btn {
        font-size: 0.85rem;
    }
}

/* Smooth transitions for interactive elements */
.btn,
.nav-link,
.list-group-item,
.card {
    transition: var(--transition);
}

/* Real-time update flash effect */
.realtime-update {
    animation: flash 0.5s ease;
}

@keyframes flash {
    0% {
        background-color: rgba(13, 110, 253, 0.2);
    }

    100% {
        background-color: transparent;
    }
}