/* ============================================================
   MindWorx Admin Dashboard — Dual Theme Design System
   Extends the MindWorx.ai website design tokens
   ============================================================ */

/* --- Theme Variables --- */

:root {
    /* Shared tokens (both themes) */
    --primary: 158 64% 52%;
    --primary-foreground: 160 30% 4%;
    --accent: 158 64% 52%;
    --accent-foreground: 160 30% 4%;
    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 100%;
    --warning: 38 92% 50%;
    --warning-foreground: 38 92% 10%;
    --success: 142 76% 36%;
    --success-foreground: 142 76% 95%;
    --info: 217 91% 60%;
    --info-foreground: 217 91% 95%;

    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;

    --glow-primary: 158 64% 52%;
    --glow-secondary: 160 40% 40%;
    --gradient-start: 158 64% 52%;
    --gradient-end: 160 40% 35%;

    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 64px;

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --transition-speed: 200ms;
}

/* --- Dark Theme (Default — matches MindWorx.ai) --- */

[data-theme="dark"] {
    --background: 160 30% 4%;
    --foreground: 150 20% 95%;

    --card: 160 25% 8%;
    --card-foreground: 150 20% 95%;
    --card-hover: 160 25% 10%;

    --popover: 160 25% 8%;
    --popover-foreground: 150 20% 95%;

    --secondary: 160 25% 15%;
    --secondary-foreground: 150 20% 95%;

    --muted: 160 20% 15%;
    --muted-foreground: 155 15% 55%;

    --border: 160 20% 18%;
    --input: 160 20% 18%;
    --ring: 158 64% 52%;

    --sidebar-bg: 160 25% 6%;
    --sidebar-border: 160 20% 14%;
    --sidebar-hover: 160 25% 12%;
    --sidebar-active: 158 64% 52%;

    --topbar-bg: 160 30% 4% / 0.85;

    --table-stripe: 160 20% 7%;
    --table-hover: 160 20% 12%;

    --kpi-highlight-bg: 158 64% 52% / 0.12;
    --kpi-highlight-border: 158 64% 52% / 0.3;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);

    color-scheme: dark;
}

/* --- Light Theme --- */

[data-theme="light"] {
    --background: 0 0% 96%;
    --foreground: 160 30% 10%;

    --card: 0 0% 100%;
    --card-foreground: 160 30% 10%;
    --card-hover: 0 0% 98%;

    --popover: 0 0% 100%;
    --popover-foreground: 160 30% 10%;

    --secondary: 160 10% 92%;
    --secondary-foreground: 160 30% 10%;

    --muted: 160 10% 92%;
    --muted-foreground: 160 10% 40%;

    --border: 160 10% 87%;
    --input: 160 10% 87%;
    --ring: 158 64% 42%;

    --sidebar-bg: 0 0% 100%;
    --sidebar-border: 160 10% 90%;
    --sidebar-hover: 160 15% 95%;
    --sidebar-active: 158 64% 42%;

    --topbar-bg: 0 0% 96% / 0.9;

    --table-stripe: 160 10% 97%;
    --table-hover: 160 15% 93%;

    --kpi-highlight-bg: 158 64% 52% / 0.08;
    --kpi-highlight-border: 158 64% 52% / 0.25;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);

    color-scheme: light;
}

/* ============================================================
   CSS Reset & Base
   ============================================================ */

* {
    box-sizing: border-box;
    border-width: 0;
    border-style: solid;
    border-color: hsl(var(--border));
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-speed) ease,
                color var(--transition-speed) ease;
}

/* ============================================================
   Typography
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
    color: hsl(var(--foreground));
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

p {
    color: hsl(var(--muted-foreground));
    line-height: 1.6;
}

a {
    color: hsl(var(--primary));
    text-decoration: none;
    transition: opacity var(--transition-speed);
}

a:hover { opacity: 0.85; }

/* ============================================================
   Utility Classes
   ============================================================ */

.container { width: 100%; max-width: 1400px; margin: 0 auto; padding: 0 1.5rem; }
.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-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: hsl(var(--muted-foreground)); }
.text-primary { color: hsl(var(--primary)); }
.text-success { color: hsl(var(--success)); }
.text-destructive { color: hsl(var(--destructive)); }
.text-warning { color: hsl(var(--warning)); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    height: 2.5rem;
    padding: 0 1rem;
    transition: all var(--transition-speed) ease;
    cursor: pointer;
    border: 1px solid transparent;
    font-family: inherit;
    text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}
.btn-primary:hover:not(:disabled) { opacity: 0.9; }

.btn-secondary {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}
.btn-secondary:hover:not(:disabled) { background-color: hsl(var(--card-hover)); }

.btn-outline {
    border-color: hsl(var(--border));
    background-color: transparent;
    color: hsl(var(--foreground));
}
.btn-outline:hover:not(:disabled) {
    background-color: hsl(var(--secondary));
}

.btn-ghost {
    background-color: transparent;
    color: hsl(var(--foreground));
}
.btn-ghost:hover:not(:disabled) { background-color: hsl(var(--secondary)); }

.btn-destructive {
    background-color: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-lg { height: 3rem; padding: 0 2rem; font-size: 1rem; }
.btn-icon { width: 2.5rem; padding: 0; }
.btn-icon.btn-sm { width: 2rem; }

/* ============================================================
   Cards
   ============================================================ */

.card {
    border-radius: var(--radius-lg);
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: var(--shadow-sm);
    transition: background-color var(--transition-speed) ease,
                border-color var(--transition-speed) ease,
                box-shadow var(--transition-speed) ease;
}

.card-header { padding: 1.25rem 1.5rem 0.75rem; }
.card-body { padding: 0 1.5rem 1.25rem; }
.card-footer { padding: 0.75rem 1.5rem 1.25rem; border-top: 1px solid hsl(var(--border)); }

.card-compact .card-header { padding: 1rem 1.25rem 0.5rem; }
.card-compact .card-body { padding: 0 1.25rem 1rem; }

/* Glass Card (dark theme effect) */
[data-theme="dark"] .glass-card {
    background: linear-gradient(135deg, hsl(160 25% 10% / 0.8), hsl(160 25% 6% / 0.9));
    backdrop-filter: blur(16px);
    border: 1px solid hsl(var(--border) / 0.6);
}

[data-theme="light"] .glass-card {
    background: hsl(0 0% 100% / 0.8);
    backdrop-filter: blur(16px);
    border: 1px solid hsl(var(--border));
}

/* ============================================================
   Form Elements
   ============================================================ */

.input, .select, .textarea {
    display: flex;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--input));
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color var(--transition-speed) ease,
                box-shadow var(--transition-speed) ease;
    outline: none;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.25);
}

.input::placeholder { color: hsl(var(--muted-foreground) / 0.6); }

.textarea { min-height: 80px; resize: vertical; }

.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: hsl(var(--foreground));
}

.input-sm { height: 2rem; font-size: 0.8rem; padding: 0.25rem 0.5rem; }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1em;
    padding-right: 2.5rem;
    cursor: pointer;
}

/* ============================================================
   Status Badges
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.6;
}

.badge-primary { background-color: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }
.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-destructive { background-color: hsl(var(--destructive) / 0.15); color: hsl(var(--destructive)); }
.badge-info { background-color: hsl(var(--info) / 0.15); color: hsl(var(--info)); }
.badge-muted { background-color: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }

/* ============================================================
   Gradient & Glow Effects
   ============================================================ */

.gradient-text {
    background: linear-gradient(135deg, hsl(var(--gradient-start)), hsl(158 64% 70%));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glow-primary {
    box-shadow: 0 0 20px hsl(var(--glow-primary) / 0.2),
                0 0 40px hsl(var(--glow-primary) / 0.1);
}

[data-theme="light"] .glow-primary {
    box-shadow: 0 0 15px hsl(var(--glow-primary) / 0.1),
                0 0 30px hsl(var(--glow-primary) / 0.05);
}

/* ============================================================
   Animations
   ============================================================ */

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes fadeIn {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid hsl(var(--border));
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg,
        hsl(var(--muted)) 25%,
        hsl(var(--muted) / 0.5) 50%,
        hsl(var(--muted)) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   Scrollbar (Dark theme custom)
   ============================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: hsl(var(--muted-foreground) / 0.3);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--muted-foreground) / 0.5);
}
