@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('sidebar.css');

:root {
    /* --- Modern Glass Dark Theme --- */
    --bg-body: #09090b;
    --bg-card: #18181b;
    --bg-card-hover: #27272a;
    --bg-surface: #27272a;

    --border-color: #3f3f46;
    --border-hover: #52525b;

    --brand-primary: #F97316;
    --brand-gradient: linear-gradient(135deg, #F97316, #EA580C);
    --brand-hover: #FB923C;
    --brand-glow: rgba(249, 115, 22, 0.4);
    --brand-secondary: #f43f5e;

    --text-main: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.1);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.1);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.1);
    --info: #38bdf8;
    --info-bg: rgba(56, 189, 248, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-stack: 'Inter', system-ui, -apple-system, sans-serif;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-active: 0 0 0 2px rgba(249, 115, 22, 0.3);

    /* Aliases */
    --bg-main: #09090b;
    --card: #18181b;
}

/* === LIGHT THEME === */
[data-theme="light"] {
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-surface: #f1f5f9;
    --bg-main: #f1f5f9;
    --card: #ffffff;

    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;

    --brand-primary: #ea580c;
    --brand-gradient: linear-gradient(135deg, #ea580c, #c2410c);
    --brand-hover: #f97316;
    --brand-secondary: #e11d48;
    --brand-glow: rgba(234, 88, 12, 0.2);

    --text-main: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.08);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.08);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.08);
    --info: #0284c7;
    --info-bg: rgba(2, 132, 199, 0.08);

    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.06);
    --shadow-card: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
    --shadow-active: 0 0 0 2px rgba(234, 88, 12, 0.2);
}

[data-theme="light"] body { background-image: none; }
[data-theme="light"] tr:hover td { background: rgba(0,0,0,0.015); }
[data-theme="light"] .sidebar { box-shadow: 1px 0 0 var(--border-color); }

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s;
    padding: 0;
    box-shadow: none;
    flex-shrink: 0;
}
.theme-toggle:hover {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
    background: var(--bg-surface);
    transform: none;
    box-shadow: none;
    filter: none;
}

/* --- Base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

body {
    background-color: var(--bg-body);
    background-image:
        radial-gradient(at 0% 0%, rgba(249, 115, 22, 0.03) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(56, 189, 248, 0.03) 0px, transparent 50%);
    color: var(--text-main);
    font-family: var(--font-stack);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    color: var(--text-main);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
}

h1 {
    font-size: 1.8rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 500;
}

a {
    text-decoration: none;
    color: var(--brand-primary);
    transition: color 0.2s;
    font-weight: 500;
}

a:hover {
    color: var(--brand-hover);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
}

/* --- Modern Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s, border-color 0.2s;
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    /* Subtle lift */
}

/* --- Beautiful Buttons --- */
.btn,
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--brand-gradient);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(249, 115, 22, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn.alt,
.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    box-shadow: none;
    color: var(--text-secondary);
    text-shadow: none;
}

.btn.alt:hover {
    background: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn.danger {
    background: transparent;
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--danger);
    box-shadow: none;
    text-shadow: none;
}

.btn.danger:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: var(--danger);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* --- Modern Inputs --- */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand-primary);
    background: var(--bg-card);
    /* Slightly lighter on focus */
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #52525b;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #3f3f46 var(--bg-body);
}

/* --- Data Tables (Clean Stripe) --- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th {
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 16px 20px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* --- Stats Grid --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 2.2rem;
    color: var(--text-main);
    font-weight: 700;
    background: linear-gradient(to right, #fff, #a1a1aa);
    -webkit-background-clip: text;
    background-clip: text;
}

/* --- Chips --- */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chip.ok {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
}

.chip.warn {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.chip.bad {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}

.chip.info {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
}

/* --- Utils --- */
.flex {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Mobile --- */
@media (max-width: 900px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .flex.justify-between {
        flex-direction: column;
        gap: 16px;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .btn-sm {
        width: auto;
        display: inline-flex;
    }

    .table-responsive {
        border: none;
        background: transparent;
        display: block;
    }

    /* Card-view for tables on mobile? Optional, but keeping scroll is safer/faster for now */
    /* Just ensure full bleed */
    table {
        width: 100%;
        display: table;
    }
}