/* index.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    /* HSL Color System */
    --bg-main: 222 47% 6%;
    --bg-surface: 223 47% 11%;
    --bg-surface-glow: 224 47% 16%;
    --border-color: 223 27% 20%;
    
    --primary: 250 89% 65%; /* Indigo */
    --primary-glow: 250 89% 65% / 0.15;
    --primary-gradient: linear-gradient(135deg, hsl(250, 89%, 65%), hsl(280, 89%, 65%));
    
    --accent: 190 90% 50%; /* Cyan */
    --accent-gradient: linear-gradient(135deg, hsl(190, 90%, 50%), hsl(220, 90%, 50%));
    
    --success: 142 70% 45%; /* Green */
    --warning: 38 92% 50%;  /* Amber */
    --danger: 350 89% 60%;  /* Coral */
    
    --text-primary: 210 40% 98%;
    --text-secondary: 215 20% 65%;
    --text-muted: 217 10% 45%;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);
}

html.light-theme {
    /* HSL Color System for Light Theme */
    --bg-main: 220 20% 96%;
    --bg-surface: 0 0% 100%;
    --bg-surface-glow: 220 15% 90%;
    --border-color: 220 15% 85%;
    
    --primary: 250 89% 55%;
    --primary-glow: 250 89% 55% / 0.15;
    --primary-gradient: linear-gradient(135deg, hsl(250, 89%, 55%), hsl(280, 89%, 55%));
    
    --accent: 195 90% 40%;
    --accent-gradient: linear-gradient(135deg, hsl(195, 90%, 40%), hsl(220, 90%, 40%));
    
    --text-primary: 222 47% 12%;
    --text-secondary: 215 15% 35%;
    --text-muted: 217 10% 55%;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.1);
}

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

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

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: hsl(var(--text-primary));
}

/* App Container Layout */
.app-container {
    display: flex;
    flex: 1;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: 280px;
    background-color: hsl(var(--bg-surface));
    border-right: 1px solid hsl(var(--border-color));
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-section .logo-icon {
    width: 42px;
    height: 42px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 20px;
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.logo-section h2 {
    font-size: 20px;
    background: linear-gradient(135deg, #fff, hsl(var(--text-secondary)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: hsl(var(--text-secondary));
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item a:hover {
    background-color: hsl(var(--bg-surface-glow));
    color: hsl(var(--text-primary));
}

.nav-item.active a {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.user-profile {
    border-top: 1px solid hsl(var(--border-color));
    padding-top: 20px;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background-color: hsl(var(--primary) / 0.2);
    border: 1px solid hsl(var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: hsl(var(--primary));
    font-family: 'Outfit', sans-serif;
}

.profile-details h4 {
    font-size: 14px;
    font-weight: 600;
}

.profile-details span {
    font-size: 12px;
    color: hsl(var(--text-muted));
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background-color: hsl(var(--danger) / 0.1);
    color: hsl(var(--danger));
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-logout:hover {
    background-color: hsl(var(--danger));
    color: #fff;
}

/* Main Content Area */
.main-content {
    margin-left: 280px;
    width: calc(100% - 280px);
    padding: 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-width: 0;
}

/* Glassmorphism Card styling */
.card {
    background-color: hsl(var(--bg-surface));
    border: 1px solid hsl(var(--border-color));
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.card:hover {
    border-color: hsl(var(--primary) / 0.4);
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

@media (max-width: 1024px) {
    .grid-4, .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none; /* In a full responsive layout, we would make a hamburger menu */
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }
    .grid-4, .grid-3, .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Stats Card Widget */
.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background-color: hsl(var(--bg-surface));
    border: 1px solid hsl(var(--border-color));
    padding: 24px;
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-gradient);
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.primary { background-color: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }
.stat-icon.accent { background-color: hsl(var(--accent) / 0.15); color: hsl(var(--accent)); }
.stat-icon.success { background-color: hsl(var(--success) / 0.15); color: hsl(var(--success)); }
.stat-icon.warning { background-color: hsl(var(--warning) / 0.15); color: hsl(var(--warning)); }

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-info p {
    font-size: 13px;
    color: hsl(var(--text-secondary));
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: 'Outfit', sans-serif;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px hsl(var(--primary) / 0.25);
}

.btn-secondary {
    background-color: hsl(var(--bg-surface-glow));
    border: 1px solid hsl(var(--border-color));
    color: hsl(var(--text-primary));
}

.btn-secondary:hover {
    background-color: hsl(var(--bg-surface-glow) / 1.5);
    border-color: hsl(var(--text-muted));
    transform: translateY(-2px);
}

.btn-accent {
    background: var(--accent-gradient);
    color: #fff;
}

.btn-accent:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.btn-danger {
    background-color: hsl(var(--danger) / 0.15);
    color: hsl(var(--danger));
    border: 1px solid hsl(var(--danger) / 0.3);
}

.btn-danger:hover {
    background-color: hsl(var(--danger));
    color: #fff;
    transform: translateY(-2px);
}

/* Inputs and Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: hsl(var(--text-secondary));
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background-color: hsl(var(--bg-main));
    border: 1px solid hsl(var(--border-color));
    border-radius: var(--radius-md);
    color: hsl(var(--text-primary));
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.15);
}

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

/* Tables */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid hsl(var(--border-color));
    background-color: hsl(var(--bg-surface));
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th, .table td {
    padding: 16px 24px;
    border-bottom: 1px solid hsl(var(--border-color));
    vertical-align: middle;
}

.table th {
    background-color: hsl(var(--bg-main) / 0.5);
    font-weight: 600;
    color: hsl(var(--text-secondary));
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: hsl(var(--bg-surface-glow) / 0.4);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge-success { background-color: hsl(var(--success) / 0.15); color: hsl(var(--success)); }
.badge-warning { background-color: hsl(var(--warning) / 0.15); color: hsl(var(--warning)); }
.badge-danger { background-color: hsl(var(--danger) / 0.15); color: hsl(var(--danger)); }
.badge-info { background-color: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }

/* Logo Previews */
.logo-preview-container {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid hsl(var(--border-color));
}

.logo-preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.logo-preview-placeholder {
    font-size: 20px;
    color: hsl(var(--text-muted));
}

/* Login Page specific */
.login-body {
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 20%, hsl(220, 50%, 8%) 0%, hsl(var(--bg-main)) 90%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Comparison UI */
.progress-bar-container {
    background-color: hsl(var(--bg-main));
    height: 12px;
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 1px solid hsl(var(--border-color));
    margin-top: 10px;
    margin-bottom: 20px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary-gradient);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
    box-shadow: var(--shadow-glow);
}

.comparison-log {
    background-color: hsl(var(--bg-main));
    border: 1px solid hsl(var(--border-color));
    border-radius: var(--radius-md);
    padding: 15px;
    font-family: monospace;
    font-size: 13px;
    color: hsl(var(--text-secondary));
    height: 250px;
    overflow-y: auto;
    white-space: pre-wrap;
    display: flex;
    flex-direction: column-reverse; /* Shows latest log at top, or standard scroll */
}

/* Key pool list */
.api-key-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: hsl(var(--bg-main));
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    border: 1px solid hsl(var(--border-color));
}

.api-key-item .key-text {
    font-family: monospace;
}

/* Alert notifications banner */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background-color: hsl(var(--success) / 0.15);
    color: hsl(var(--success));
    border: 1px solid hsl(var(--success) / 0.3);
}

.alert-danger {
    background-color: hsl(var(--danger) / 0.15);
    color: hsl(var(--danger));
    border: 1px solid hsl(var(--danger) / 0.3);
}

/* Custom scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: hsl(var(--border-color));
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--text-muted));
}
