/* ============================================
   AINSIGHT DASHBOARD - MODERN DARK THEME
   ============================================ */

:root {
    /* Colors */
    --primary: #00d4ff;
    --primary-dark: #0099cc;
    --secondary: #7c3aed;
    --accent: #f59e0b;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Backgrounds */
    --bg-primary: #0a0e1a;
    --bg-secondary: #0f1420;
    --bg-tertiary: #1a1f2e;
    --bg-card: rgba(26, 31, 46, 0.8);
    --bg-overlay: rgba(10, 14, 26, 0.95);
    
    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Borders */
    --border-color: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(0, 212, 255, 0.3);
    
    /* Layout */
    --sidebar-width: 280px;
    --header-height: 70px;
    
    /* Fonts */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Space Mono', 'Courier New', monospace;
}

/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.75rem;
    color: var(--primary);
    font-family: var(--font-mono);
    margin-bottom: 0.5rem;
}

.sidebar-header .subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    margin-bottom: 0.25rem;
}

.nav-item:hover {
    background: rgba(0, 212, 255, 0.1);
    color: var(--primary);
    border-left-color: var(--primary);
}

.nav-item.active {
    background: rgba(0, 212, 255, 0.15);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.nav-item i {
    font-size: 1.25rem;
    width: 24px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
}

.user-info i {
    font-size: 1.5rem;
    color: var(--primary);
}

.user-info span {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.content-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.content-header h1 {
    flex: 1;
    font-size: 1.75rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.notification-bell {
    position: relative;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.notification-bell:hover {
    color: var(--primary);
}

.notification-bell i {
    font-size: 1.5rem;
}

.badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--error);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    background: var(--bg-primary);
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.stat-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.stat-icon.blue {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.stat-icon.purple {
    background: rgba(124, 58, 237, 0.2);
    color: var(--secondary);
}

.stat-icon.orange {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.stat-info h3 {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.stat-info p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.card-body {
    color: var(--text-secondary);
}

/* ===== Buttons ===== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #6d28d9;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--primary);
    background: rgba(0, 212, 255, 0.1);
    color: var(--primary);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-color);
}

thead th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: rgba(0, 212, 255, 0.05);
}

tbody td {
    padding: 1rem;
    color: var(--text-secondary);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

select.form-control {
    cursor: pointer;
}

/* ===== Modals ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(10px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* ===== Alerts ===== */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border-left: 4px solid;
    backdrop-filter: blur(10px);
}

.alert-success {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
    color: var(--success);
}

.alert-info {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--info);
    color: var(--info);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.2);
    border-color: var(--warning);
    color: var(--warning);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--error);
    color: var(--error);
}

/* ===== Loading Spinner ===== */
.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Charts ===== */
.chart-container {
    position: relative;
    height: 300px;
    margin: 1rem 0;
}

/* ===== AI Assistant Page ===== */
.ai-assistant-container {
    max-width: 900px;
    margin: 0 auto;
}

.ai-chat-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    overflow: hidden;
    height: 500px;
    display: flex;
    flex-direction: column;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.ai-message {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 0.75rem;
    max-width: 80%;
}

.ai-message.user {
    background: var(--bg-tertiary);
    margin-left: auto;
    text-align: right;
}

.ai-message.assistant {
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.3);
}

.ai-message-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
}

.ai-chat-input {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.ai-chat-input input {
    flex: 1;
}

/* ===== Responsive Design ===== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .content-header {
        padding: 0 1rem;
    }
    
    .content-area {
        padding: 1rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .sidebar {
        width: 100%;
    }
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.flex-1 { flex: 1; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
