/* NexBook Design System - Modern Dark/Light Theme */

:root {
    /* Colors - Background */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e2e8f0;

    /* Colors - Text */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Colors - Accent */
    --accent-primary: #3b7cfc;
    --accent-hover: #2563eb;
    --accent-light: #60a5fa;
    --accent-glow: rgba(59, 124, 252, 0.15);

    /* Colors - Status */
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-error: #ef4444;
    --status-info: #06b6d4;

    /* Colors - Borders */
    --border-primary: #e2e8f0;
    --border-secondary: #cbd5e1;

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

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px -4px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 40px -12px rgba(0, 0, 0, 0.15), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px rgba(59, 124, 252, 0.1);

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

:root[data-theme='dark'] {
    --bg-primary: #0c1222;
    --bg-secondary: #080e1a;
    --bg-tertiary: #111c33;
    --bg-hover: #172647;

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --accent-primary: #3b7cfc;
    --accent-hover: #60a5fa;
    --accent-light: #93c5fd;
    --accent-glow: rgba(59, 124, 252, 0.12);

    --border-primary: rgba(148, 163, 184, 0.12);
    --border-secondary: rgba(148, 163, 184, 0.22);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px -6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 50px -16px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 30px rgba(59, 124, 252, 0.08);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle noise texture */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    opacity: 0.015;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

:root[data-theme='dark'] body::before { opacity: 0.03; }

/* Reveal animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.content-body { animation: fadeInUp 0.4s ease-out; }

/* Glow tile hover effect */
@keyframes nexGlowSweep {
    0% { transform: translateX(-30%) translateY(-25%) rotate(8deg); opacity: 0; }
    30% { opacity: 0.65; }
    100% { transform: translateX(30%) translateY(25%) rotate(8deg); opacity: 0; }
}

.glow-tile {
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
}

.glow-tile::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(60% 60% at 30% 20%, rgba(59, 124, 252, 0.15) 0%, transparent 70%),
        radial-gradient(55% 55% at 80% 85%, rgba(59, 124, 252, 0.1) 0%, transparent 70%);
    transition: opacity 250ms ease;
}

:root[data-theme='dark'] .glow-tile::before {
    background: radial-gradient(60% 60% at 30% 20%, rgba(59, 124, 252, 0.12) 0%, transparent 70%),
        radial-gradient(55% 55% at 80% 85%, rgba(96, 165, 250, 0.08) 0%, transparent 70%);
}

.glow-tile::after {
    content: '';
    position: absolute;
    inset: -40% -60%;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.4) 20%, rgba(255, 255, 255, 0) 45%);
    transform: translateX(-30%) translateY(-25%) rotate(8deg);
}

:root[data-theme='dark'] .glow-tile::after {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.12) 20%, rgba(255, 255, 255, 0) 45%);
}

.glow-tile:hover::before { opacity: 1; }
.glow-tile:hover::after { opacity: 1; animation: nexGlowSweep 1.2s ease-out; }

/* Layout Components */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.sidebar {
    width: 240px;
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 10;
    transition: background-color 0.3s;
}

:root[data-theme='dark'] .sidebar {
    background: linear-gradient(180deg, var(--bg-primary), rgba(12, 18, 34, 0.95));
    backdrop-filter: blur(12px);
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-primary);
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    transition: color 0.2s;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md);
}

.sidebar-section {
    margin-bottom: var(--space-lg);
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
    padding: 0 var(--space-sm);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0.45rem var(--space-md);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    font-size: 0.875rem;
    position: relative;
}

.sidebar-link:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateX(2px);
}

.sidebar-link.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: white;
    box-shadow: 0 4px 12px -4px rgba(59, 124, 252, 0.4);
}

:root[data-theme='dark'] .sidebar-link.active {
    box-shadow: 0 4px 16px -4px rgba(59, 124, 252, 0.3);
}

.sidebar-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border-primary);
}

.main-content {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
}

.content-header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-primary);
    padding: var(--space-lg) var(--space-xl);
    backdrop-filter: blur(8px);
}

:root[data-theme='dark'] .content-header {
    background: rgba(12, 18, 34, 0.8);
    backdrop-filter: blur(12px);
}

.content-body {
    padding: var(--space-xl);
}

/* Cards */
.card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

:root[data-theme='dark'] .card {
    background: rgba(17, 28, 51, 0.6);
    backdrop-filter: blur(8px);
}

:root[data-theme='dark'] .card:hover {
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: rgba(59, 124, 252, 0.3);
}

.card-header {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-primary);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: white;
    box-shadow: 0 4px 16px -6px rgba(59, 124, 252, 0.5);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px -8px rgba(59, 124, 252, 0.6);
    filter: brightness(1.1);
}

:root[data-theme='dark'] .btn-primary {
    box-shadow: 0 4px 20px -8px rgba(59, 124, 252, 0.4);
}

:root[data-theme='dark'] .btn-primary:hover {
    box-shadow: 0 8px 30px -8px rgba(59, 124, 252, 0.5);
}

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

.btn-secondary:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-secondary);
    transform: translateY(-1px);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Forms */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.25s ease;
}

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

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

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

.table thead {
    background-color: var(--bg-tertiary);
}

.table th {
    padding: var(--space-md);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-primary);
}

.table td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-secondary);
    transition: background-color 0.15s;
}

.table tbody tr:hover {
    background-color: var(--bg-tertiary);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.12);
    color: var(--status-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.12);
    color: var(--status-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-error {
    background-color: rgba(239, 68, 68, 0.12);
    color: var(--status-error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-info {
    background-color: rgba(6, 182, 212, 0.12);
    color: var(--status-info);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge-gray {
    background-color: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(148, 163, 184, 0.15);
}

/* Alerts */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    border-left: 4px solid;
    backdrop-filter: blur(4px);
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.08);
    border-color: var(--status-success);
    color: var(--status-success);
}

.alert-error {
    background-color: rgba(239, 68, 68, 0.08);
    border-color: var(--status-error);
    color: var(--status-error);
}

.alert-info {
    background-color: rgba(6, 182, 212, 0.08);
    border-color: var(--status-info);
    color: var(--status-info);
}

/* Utilities */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-primary); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(59, 124, 252, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 124, 252, 0.35);
}

/* Toasts */
#ui-toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.ui-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 280px;
    max-width: 420px;
    padding: 14px 16px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-primary);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    transform: translateY(-8px);
    opacity: 0;
    transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1), opacity 250ms ease;
}

.ui-toast__text {
    font-size: 0.875rem;
    line-height: 1.4;
    flex: 1;
}

.ui-toast__close {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
    transition: color 0.15s;
}

.ui-toast__close:hover {
    color: var(--text-primary);
}

.ui-toast--success { border-left: 4px solid var(--status-success); }
.ui-toast--error { border-left: 4px solid var(--status-error); }
.ui-toast--warning { border-left: 4px solid var(--status-warning); }
.ui-toast--info { border-left: 4px solid var(--accent-light); }

:root[data-theme='dark'] .ui-toast {
    background: rgba(12, 18, 34, 0.92);
    border-color: rgba(148, 163, 184, 0.15);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(0, 0, 0, 0.3);
}

:root[data-theme='dark'] .ui-toast__close { color: var(--text-muted); }
:root[data-theme='dark'] .ui-toast__close:hover { color: var(--text-primary); }

/* Theme Toggle FAB */
.theme-fab {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 9998;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-primary);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

:root[data-theme='dark'] .theme-fab {
    background: rgba(12, 18, 34, 0.9);
    box-shadow: var(--shadow-md), 0 0 20px rgba(59, 124, 252, 0.05);
}

.theme-fab:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Confirm Modal */
.ui-confirm {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
}

.ui-confirm--open {
    display: block;
}

.ui-confirm__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.15s ease;
}

.ui-confirm__dialog {
    position: relative;
    width: min(520px, calc(100vw - 32px));
    margin: 10vh auto 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 20px;
    animation: fadeInUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme='dark'] .ui-confirm__dialog {
    background: rgba(12, 18, 34, 0.95);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 0, 0, 0.3);
}

.ui-confirm__title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 8px;
}

.ui-confirm__message {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.45;
    margin-bottom: 14px;
    white-space: pre-wrap;
}

.ui-confirm__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
