:root {
    --bg-color: #f3f4f6;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;

    /* Glassmorphism Variables */
    /* Glassmorphism Variables */
    --glass-bg: rgba(255, 255, 255, 0.4);
    /* More transparent */
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --card-radius: 20px;
    --sidebar-width: 260px;
    --header-height: 80px;

    /* Blob Colors */
    --blob-1: #e0e7ff;
    --blob-2: #f0f9ff;
    --blob-3: #fdf2f8;
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

    --blob-1: #1e1b4b;
    --blob-2: #172554;
    --blob-3: #312e81;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-color);
    overflow-x: hidden;
    min-height: 100vh;
}

/* =========================================
   Background Blobs (The "Vibe")
   ========================================= */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.8;
    animation: blob-bounce 20s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: var(--blob-1);
    transform-origin: top left;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: var(--blob-2);
    animation-delay: -5s;
    transform-origin: bottom right;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 400px;
    height: 400px;
    background: var(--blob-3);
    animation-duration: 25s;
    animation-delay: -10s;
}

@keyframes blob-bounce {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

/* =========================================
   Layout
   ========================================= */
.app-container {
    display: flex;
    min-height: 100vh;
    backdrop-filter: blur(0px);
    /* Just to trigger stacking context if needed */
}

/* Sidebar - Glassy */
.sidebar {
    width: var(--sidebar-width);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;

    /* Pure Glass Effect */
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--glass-border);
}

.logo-container h2 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(120deg, var(--accent-color), #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2.5rem;
    padding-left: 10px;
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-radius: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
    color: var(--accent-color);
    border-color: rgba(59, 130, 246, 0.2);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

[data-theme="dark"] .nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .nav-item.active {
    background: rgba(59, 130, 246, 0.2);
}

.nav-item i {
    font-size: 1.4rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

/* Main Content - Fluid & Glassy */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 0 40px 40px 40px;
    width: calc(100% - var(--sidebar-width));
    /* Fix layout overflow */
    display: flex;
    flex-direction: column;
}

/* Header */
.top-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    padding-top: 20px;
}

.header-left h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-1px);
}

/* Glass Cards */
.stat-card,
.content-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    /* Better responsiveness */
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-5px) scale(1.02);
}

/* Shine effect on hover */
.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.2) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.stat-card:hover::after {
    transform: translateX(100%);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 16px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.stat-icon.blue {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #2563eb;
}

.stat-icon.green {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    color: #166534;
}

.stat-icon.purple {
    background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
    color: #9333ea;
}

.stat-icon.orange {
    background: linear-gradient(135deg, #ffedd5, #fed7aa);
    color: #ea580c;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Dashboard Split Layout */
.dashboard-split {
    display: grid;
    grid-template-columns: 2fr 1.5fr;
    /* Custom ratio */
    gap: 24px;
}

@media (max-width: 1200px) {
    .dashboard-split {
        grid-template-columns: 1fr;
    }
}

.content-card.full-width {
    width: 100%;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 24px;
}

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

.btn-xs {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-xs:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-primary);
}

.btn-xs.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Recommendations */
.recommendation-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recommendation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    transition: all 0.2s;
}

.recommendation-item:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Log Viewer */
.log-viewer {
    background: #1e293b;
    border-radius: 12px;
    padding: 16px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    height: 350px;
    overflow-y: auto;
    color: #e2e8f0;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    line-height: 1.4;
}

.log-entry.error {
    color: #fca5a5;
}

.log-entry.success {
    color: #86efac;
}

.log-entry.system {
    color: #94a3b8;
    font-style: italic;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.8);
}

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

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.data-table td {
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Model Badges */
.model-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Progress Bar */
.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.progress-bar-fill {
    height: 6px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.progress-bar-container span {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: right;
}

/* Animation Utils */
.view-container {
    display: none;
}

.view-container.active {
    display: block;
    animation: fadeInUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================================
   TRAFFIC LOGS PAGE STYLES
   ================================== */

/* Logs Header */
.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.logs-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.recording-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #ef4444;
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.recording-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.logs-search-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.logs-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-badge {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.logs-stats {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(100, 116, 139, 0.1);
}

.logs-stats .stat-num {
    font-weight: 700;
}

.logs-stats.ok {
    color: #10b981;
}

.logs-stats.err {
    color: #ef4444;
}

.btn-icon {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-tag {
    padding: 6px 14px;
    font-size: 0.85rem;
    border: 1px solid var(--glass-border);
    background: transparent;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.filter-tag:hover {
    background: rgba(255, 255, 255, 0.6);
}

.filter-tag.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Logs Table */
.logs-table-container {
    background: var(--glass-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

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

.logs-table th,
.logs-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.logs-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(248, 250, 252, 0.5);
}

.logs-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

.logs-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

.logs-table .empty-row td {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-badge.success {
    background: #d1fae5;
    color: #10b981;
}

.status-badge.error {
    background: #fee2e2;
    color: #ef4444;
}

.status-badge.pending {
    background: #fef3c7;
    color: #f59e0b;
}

/* Logs Pagination */
.logs-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.per-page select {
    margin-left: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    background: white;
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-page {
    padding: 6px 12px;
    border: 1px solid var(--glass-border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
}

.btn-page:hover {
    background: #f1f5f9;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    background: white;
    border-radius: 16px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 1.1rem;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

.modal-body {
    padding: 24px;
}

.modal-info-row {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
}

.info-item {
    flex: 1;
}

.info-item.full-width {
    flex: 1 1 100%;
}

.info-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.info-item>div {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.token-badges {
    display: flex;
    gap: 8px;
}

.token-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.token-badge.in {
    background: #dcfce7;
    color: #16a34a;
}

.token-badge.out {
    background: #dbeafe;
    color: #2563eb;
}

.protocol-badge {
    display: inline-block;
    padding: 6px 14px;
    background: #3b82f6;
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.model-name {
    color: var(--accent-color);
    font-weight: 600;
}

/* Code Sections */
.code-section {
    margin-top: 20px;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-secondary);
}

.btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 0.8rem;
    border: 1px solid var(--glass-border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-copy:hover {
    background: #f1f5f9;
}

.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 10px;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
}