/* Modern Design System - Thread Console */
:root {
    /* Color Palette - HSL for easy variations */
    --primary-h: 236;
    --primary-s: 72%;
    --primary-l: 66%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-dark: hsl(var(--primary-h), var(--primary-s), 56%);
    --primary-light: hsl(var(--primary-h), var(--primary-s), 96%);

    --accent-h: 270;
    --accent: hsl(var(--accent-h), 60%, 60%);

    --surface-bg: #f8fafc;
    --surface-card: #ffffff;
    --surface-border: #e2e8f0;

    --text-main: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-Index */
    --z-nav: 50;
    --z-modal: 100;
    --z-overlay: 90;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--surface-bg);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
}

button,
input,
select {
    font-family: inherit;
}

/* --- Typography --- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-main);
}

h1 {
    font-size: 1.875rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.font-medium {
    font-weight: 500;
}

.font-bold {
    font-weight: 700;
}

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

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

/* --- Components --- */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    gap: 0.5rem;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, hsl(var(--accent-h), 60%, 55%) 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    box-shadow: var(--shadow-md);
    filter: brightness(110%);
}

.btn-secondary {
    background: white;
    border-color: var(--surface-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--surface-bg);
    border-color: #cbd5e1;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
}

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

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-main);
}

.input,
.select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    background: white;
}

.input:focus,
.select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Cards */
.card {
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--surface-border);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid transparent;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-gray {
    background: #f1f5f9;
    color: #475569;
}

.badge-blue {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-green {
    background: #ecfdf5;
    color: #059669;
}

.badge-red {
    background: #fef2f2;
    color: #dc2626;
}

/* Layouts */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

/* --- Page Specific: Index / Auth --- */
/* Base Auth Layout (Default: Original Dark Gradient) */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    position: relative;
    overflow: hidden;
    transition: background 0.5s ease;
}

/* Default Theme (Classic) */
.auth-layout.bg-default {
    background: radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    background-color: #0f172a;
}

.auth-layout.bg-default::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, transparent 30%, #000 70%);
    z-index: 0;
    pointer-events: none;
}

/* Theme 1: Animated Aurora */
.auth-layout.bg-aurora {
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Theme 2: Cyber Grid (Hacker Style) */
.auth-layout.bg-grid {
    background-color: #020b14;
    background-image:
        linear-gradient(0deg, transparent 24%, rgba(0, 255, 136, .3) 25%, rgba(0, 255, 136, .3) 26%, transparent 27%, transparent 74%, rgba(0, 255, 136, .3) 75%, rgba(0, 255, 136, .3) 76%, transparent 77%, transparent),
        linear-gradient(90deg, transparent 24%, rgba(0, 255, 136, .3) 25%, rgba(0, 255, 136, .3) 26%, transparent 27%, transparent 74%, rgba(0, 255, 136, .3) 75%, rgba(0, 255, 136, .3) 76%, transparent 77%, transparent);
    background-size: 50px 50px;
    box-shadow: inset 0 0 150px rgba(0, 0, 0, 0.9);
    animation: moveGrid 20s linear infinite;
    position: relative;
}

.auth-layout.bg-grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, transparent 40%, #000 100%);
    pointer-events: none;
    z-index: 1;
}

@keyframes moveGrid {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 50px 50px;
    }
}

/* Theme 3: Glassmorphism (Vibrant) */
.auth-layout.bg-glass {
    background: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 99%, #FECFEF 100%);
    position: relative;
    z-index: 0;
}

/* Add some dynamic moving shapes for Glass */
.auth-layout.bg-glass .orb-1,
.auth-layout.bg-glass .orb-2 {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    z-index: -1;
    opacity: 0.8;
}

.auth-layout.bg-glass .orb-1 {
    width: 60vh;
    height: 60vh;
    background: radial-gradient(circle, #84fab0 0%, #8fd3f4 100%);
    top: -10%;
    left: -10%;
    animation: floatOrb1 15s ease-in-out infinite alternate;
}

.auth-layout.bg-glass .orb-2 {
    width: 60vh;
    height: 60vh;
    background: radial-gradient(circle, #a18cd1 0%, #fbc2eb 100%);
    bottom: -10%;
    right: -10%;
    animation: floatOrb2 20s ease-in-out infinite alternate;
}

@keyframes floatOrb1 {
    0% {
        transform: translate(0, 0) scale(1);
    }

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

@keyframes floatOrb2 {
    0% {
        transform: translate(0, 0) scale(1);
    }

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

@keyframes floatUpFade {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-50px);
    }
}

.floating-message {
    position: absolute;
    bottom: 100%;
    right: 50%;
    transform: translateX(50%);
    /* Centered horizontally */
    color: white;
    /* Will override based on theme if needed, but white is safe on dark/glass/color */
    font-weight: 600;
    pointer-events: none;
    animation: floatUpFade 1.5s ease-out forwards;
    z-index: 2000;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-size: 0.9rem;
    white-space: nowrap;
    margin-bottom: 10px;
    /* Start slightly above avatar */
}

/* Theme 4: Plain Gray (Light) */
.auth-layout.bg-gray {
    background-color: #f3f4f6;
    background-image: none;
    z-index: 0;
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    max-width: 450px;
    width: 100%;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- Page Specific: Admin --- */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid var(--surface-border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: var(--spacing-md);
    flex-shrink: 0;
    transition: transform var(--transition-normal);
}

.sidebar-item {
    justify-content: flex-start;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--text-main);
    width: 100%;
}

.sidebar-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: var(--spacing-lg);
    background: var(--surface-bg);
}

/* Responsive Table / Cards */
.table-responsive {
    overflow-x: auto;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    background: white;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th,
td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--surface-border);
}

th {
    background: var(--surface-bg);
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

tr:hover {
    background: #f8fafc;
}

/* Mobile Utilities */
.mobile-menu-toggle {
    display: none;
}

.mobile-overlay {
    display: none;
}

.desktop-only {
    display: none;
}

@media (min-width: 768px) {
    .desktop-only {
        display: block;
    }
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    .admin-wrapper {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: var(--z-modal);
        transform: translateX(-100%);
        width: 80%;
        max-width: 300px;
        box-shadow: var(--shadow-xl);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: var(--z-overlay);
        display: none;
        backdrop-filter: blur(2px);
    }

    .mobile-overlay.active {
        display: block;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        padding: 0.5rem;
        margin-right: 0.5rem;
        background: white;
        border: 1px solid var(--surface-border);
        border-radius: var(--radius-sm);
    }

    .main-content {
        padding: var(--spacing-md);
    }

    /* Responsive Grid for Stats */
    .admin-stats-grid {
        grid-template-columns: 1fr;
    }

    /* Card View for Tables on Mobile */
    .table-responsive table,
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive th,
    .table-responsive td,
    .table-responsive tr {
        display: block;
    }

    .table-responsive thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .table-responsive tr {
        border: 1px solid var(--surface-border);
        margin-bottom: 1rem;
        border-radius: var(--radius-md);
        background: white;
        padding: 0.5rem;
    }

    .table-responsive td {
        border: none;
        position: relative;
        padding-left: 40%;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
        display: flex;
        align-items: center;
    }

    /* Simulate headers using data attributes would be ideal, 
       but for now we just make them flow naturally or hide/show specific specific cols 
    */
    .table-responsive td::before {
        position: absolute;
        left: 0.75rem;
        width: 35%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.75rem;
        content: attr(data-label);
    }
}