/* ============================================
   BOOK PLATFORM — Dark Premium Design System
   ============================================
   Version : 1.0.0
   Updated : 2026-02-20
   Font    : Noto Sans KR
   Theme   : Dark with Purple Accent
   ============================================ */

/* ------------------------------------------
   1. CSS Custom Properties
   ------------------------------------------ */
:root {
    /* Primary palette */
    --color-primary:        #6c5ce7;
    --color-primary-light:  #7f70f0;
    --color-primary-dark:   #5a4bd6;
    --color-primary-rgb:    108, 92, 231;

    /* Secondary palette */
    --color-secondary:      #a855f7;
    --color-secondary-light:#bc7aff;
    --color-secondary-dark: #9333ea;
    --color-secondary-rgb:  168, 85, 247;

    /* Gradient */
    --gradient-primary: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    --gradient-hover:   linear-gradient(135deg, var(--color-primary-light), var(--color-secondary-light));
    --gradient-subtle:  linear-gradient(135deg, rgba(var(--color-primary-rgb), 0.15), rgba(var(--color-secondary-rgb), 0.15));

    /* Backgrounds */
    --bg-body:          #0a0a0f;
    --bg-surface:       #12121a;
    --bg-surface-2:     #1a1a2e;
    --bg-surface-3:     #22223a;
    --bg-elevated:      #1e1e30;
    --bg-hover:         rgba(108, 92, 231, 0.08);
    --bg-active:        rgba(108, 92, 231, 0.14);

    /* Borders */
    --border-color:     #2a2a3a;
    --border-light:     #1f1f2f;
    --border-focus:     var(--color-primary);

    /* Text */
    --text-primary:     #e8e8f0;
    --text-secondary:   #a0a0b8;
    --text-muted:       #6a6a82;
    --text-inverse:     #0a0a0f;
    --text-link:        var(--color-primary-light);

    /* Status colors */
    --color-success:    #00c853;
    --color-success-bg: rgba(0, 200, 83, 0.12);
    --color-warning:    #ffab00;
    --color-warning-bg: rgba(255, 171, 0, 0.12);
    --color-danger:     #ff5252;
    --color-danger-bg:  rgba(255, 82, 82, 0.12);
    --color-info:       #40c4ff;
    --color-info-bg:    rgba(64, 196, 255, 0.12);

    /* Spacing scale */
    --space-xxs:  0.25rem;   /* 4px  */
    --space-xs:   0.5rem;    /* 8px  */
    --space-sm:   0.75rem;   /* 12px */
    --space-md:   1rem;      /* 16px */
    --space-lg:   1.5rem;    /* 24px */
    --space-xl:   2rem;      /* 32px */
    --space-2xl:  3rem;      /* 48px */
    --space-3xl:  4rem;      /* 64px */

    /* Border radius */
    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  16px;
    --radius-xl:  24px;
    --radius-full:9999px;

    /* Shadows */
    --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md:    0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg:    0 8px 30px rgba(0, 0, 0, 0.6);
    --shadow-xl:    0 16px 50px rgba(0, 0, 0, 0.7);
    --shadow-glow:  0 0 20px rgba(var(--color-primary-rgb), 0.3);
    --shadow-glow-lg: 0 0 40px rgba(var(--color-primary-rgb), 0.25);

    /* Typography */
    --font-family:  'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --font-size-xs:   0.75rem;   /* 12px */
    --font-size-sm:   0.8125rem; /* 13px */
    --font-size-base: 0.9375rem; /* 15px */
    --font-size-md:   1rem;      /* 16px */
    --font-size-lg:   1.125rem;  /* 18px */
    --font-size-xl:   1.375rem;  /* 22px */
    --font-size-2xl:  1.75rem;   /* 28px */
    --font-size-3xl:  2.25rem;   /* 36px */

    --line-height-tight:  1.3;
    --line-height-normal: 1.6;
    --line-height-loose:  1.8;

    --font-weight-light:    300;
    --font-weight-normal:   400;
    --font-weight-medium:   500;
    --font-weight-semibold: 600;
    --font-weight-bold:     700;

    /* Transitions */
    --transition-fast:   0.15s ease;
    --transition-base:   0.25s ease;
    --transition-slow:   0.4s ease;
    --transition-spring: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Z-index layers */
    --z-dropdown:  100;
    --z-sticky:    200;
    --z-nav:       300;
    --z-modal:     400;
    --z-toast:     500;
    --z-loading:   600;
    --z-tooltip:   700;

    /* Layout */
    --nav-height:       64px;
    --sidebar-width:    260px;
    --container-max:    1280px;
}


/* ------------------------------------------
   2. Font Import
   ------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700&display=swap');


/* ------------------------------------------
   3. Reset Styles
   ------------------------------------------ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--text-primary);
    background-color: var(--bg-body);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    color: var(--text-primary);
    margin: 0;
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl);  }
h4 { font-size: var(--font-size-lg);  }
h5 { font-size: var(--font-size-md);  }
h6 { font-size: var(--font-size-base);}

p {
    margin: 0;
    line-height: var(--line-height-normal);
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-secondary-light);
}

ul, ol {
    list-style: none;
}

img, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
    outline: none;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
}

::selection {
    background-color: rgba(var(--color-primary-rgb), 0.35);
    color: #ffffff;
}

hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: var(--space-lg) 0;
}


/* ------------------------------------------
   4. Layout Utilities
   ------------------------------------------ */

/* Flex helpers */
.flex          { display: flex; }
.flex-inline   { display: inline-flex; }
.flex-col      { flex-direction: column; }
.flex-row      { flex-direction: row; }
.flex-wrap     { flex-wrap: wrap; }
.flex-nowrap   { flex-wrap: nowrap; }
.flex-1        { flex: 1; }
.flex-auto     { flex: auto; }
.flex-none     { flex: none; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-grow     { flex-grow: 1; }

/* Alignment */
.items-start    { align-items: flex-start; }
.items-center   { align-items: center; }
.items-end      { align-items: flex-end; }
.items-stretch  { align-items: stretch; }
.items-baseline { align-items: baseline; }

.justify-start   { justify-content: flex-start; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around  { justify-content: space-around; }
.justify-evenly  { justify-content: space-evenly; }

.self-start  { align-self: flex-start; }
.self-center { align-self: center; }
.self-end    { align-self: flex-end; }

/* Common flex patterns */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-col-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Grid helpers */
.grid          { display: grid; }
.grid-cols-1   { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2   { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3   { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4   { grid-template-columns: repeat(4, 1fr); }
.grid-cols-5   { grid-template-columns: repeat(5, 1fr); }
.grid-cols-6   { grid-template-columns: repeat(6, 1fr); }
.grid-cols-12  { grid-template-columns: repeat(12, 1fr); }

.col-span-2    { grid-column: span 2; }
.col-span-3    { grid-column: span 3; }
.col-span-4    { grid-column: span 4; }
.col-span-6    { grid-column: span 6; }
.col-span-full { grid-column: 1 / -1; }

/* Gap */
.gap-xxs { gap: var(--space-xxs); }
.gap-xs  { gap: var(--space-xs); }
.gap-sm  { gap: var(--space-sm); }
.gap-md  { gap: var(--space-md); }
.gap-lg  { gap: var(--space-lg); }
.gap-xl  { gap: var(--space-xl); }
.gap-2xl { gap: var(--space-2xl); }

/* Spacing utilities */
.m-0   { margin: 0; }
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-xs { margin-bottom: var(--space-xs); }
.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); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0   { padding: 0; }
.p-xs  { padding: var(--space-xs); }
.p-sm  { padding: var(--space-sm); }
.p-md  { padding: var(--space-md); }
.p-lg  { padding: var(--space-lg); }
.p-xl  { padding: var(--space-xl); }
.px-md { padding-left: var(--space-md); padding-right: var(--space-md); }
.px-lg { padding-left: var(--space-lg); padding-right: var(--space-lg); }
.py-md { padding-top: var(--space-md); padding-bottom: var(--space-md); }
.py-lg { padding-top: var(--space-lg); padding-bottom: var(--space-lg); }

/* Width / Height */
.w-full  { width: 100%; }
.h-full  { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* Container */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* Text utilities */
.text-center  { text-align: center; }
.text-left    { text-align: left; }
.text-right   { text-align: right; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--color-primary); }
.text-sm      { font-size: var(--font-size-sm); }
.text-xs      { font-size: var(--font-size-xs); }
.text-lg      { font-size: var(--font-size-lg); }
.font-medium  { font-weight: var(--font-weight-medium); }
.font-semibold{ font-weight: var(--font-weight-semibold); }
.font-bold    { font-weight: var(--font-weight-bold); }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Visibility */
.hidden     { display: none !important; }
.invisible  { visibility: hidden; }
.sr-only    {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* Overflow */
.overflow-hidden  { overflow: hidden; }
.overflow-auto    { overflow: auto; }
.overflow-y-auto  { overflow-y: auto; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }

/* Cursor */
.cursor-pointer  { cursor: pointer; }
.cursor-default  { cursor: default; }
.pointer-events-none { pointer-events: none; }

/* Border */
.rounded-sm   { border-radius: var(--radius-sm); }
.rounded-md   { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }


/* ------------------------------------------
   5. Button Styles
   ------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 0.625rem 1.25rem;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    user-select: none;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn svg,
.btn i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Primary — gradient */
.btn-primary {
    background: var(--gradient-primary);
    color: #ffffff;
    border: none;
    box-shadow: 0 2px 10px rgba(var(--color-primary-rgb), 0.35);
}

.btn-primary:hover {
    background: var(--gradient-hover);
    box-shadow: 0 4px 20px rgba(var(--color-primary-rgb), 0.5);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 1px 6px rgba(var(--color-primary-rgb), 0.3);
}

/* Secondary */
.btn-secondary {
    background-color: var(--bg-surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-3);
    border-color: var(--color-primary);
    color: var(--color-primary-light);
}

/* Danger */
.btn-danger {
    background-color: var(--color-danger);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(255, 82, 82, 0.3);
}

.btn-danger:hover {
    background-color: #ff6b6b;
    box-shadow: 0 4px 20px rgba(255, 82, 82, 0.45);
    transform: translateY(-1px);
}

.btn-danger:active {
    transform: translateY(0) scale(0.97);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

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

/* Sizes */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: var(--font-size-xs);
    border-radius: var(--radius-sm);
}

.btn-sm svg,
.btn-sm i {
    width: 14px;
    height: 14px;
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: var(--font-size-md);
    border-radius: var(--radius-md);
}

.btn-lg svg,
.btn-lg i {
    width: 20px;
    height: 20px;
}

/* Icon-only button */
.btn-icon {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
    padding: 0.25rem;
}

.btn-icon.btn-lg {
    width: 48px;
    height: 48px;
    padding: 0.75rem;
}

/* Button group */
.btn-group {
    display: inline-flex;
    gap: 0;
}

.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.btn-group .btn:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.btn-group .btn + .btn {
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}


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

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

.form-label .required {
    color: var(--color-danger);
    margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    color: var(--text-primary);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    line-height: var(--line-height-normal);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: #3a3a50;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
    background-color: var(--bg-surface-2);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(255, 82, 82, 0.1);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--bg-body);
}

/* Select */
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23a0a0b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.form-select option {
    background-color: var(--bg-surface-2);
    color: var(--text-primary);
}

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

/* Input sizes */
.form-input-sm,
.form-select-sm {
    padding: 0.375rem 0.625rem;
    font-size: var(--font-size-xs);
}

.form-input-lg,
.form-select-lg {
    padding: 0.875rem 1.125rem;
    font-size: var(--font-size-md);
}

/* Helper / error text */
.form-helper {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-xxs);
}

.form-error {
    font-size: var(--font-size-xs);
    color: var(--color-danger);
    margin-top: var(--space-xxs);
}

/* Checkbox / Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

/* Search input */
.form-search {
    position: relative;
}

.form-search .search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    width: 16px;
    height: 16px;
}

.form-search .form-input {
    padding-left: 2.5rem;
}


/* ------------------------------------------
   7. Card Component
   ------------------------------------------ */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-base);
}

.card:hover {
    border-color: #3a3a50;
    box-shadow: var(--shadow-md);
}

/* AI 설정 - 제공자 선택 카드 호버 */
.ai-provider-card {
    transition: all 0.25s ease;
    position: relative;
}
.ai-provider-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(108,92,231,0.2);
    border-color: #6c5ce7 !important;
    opacity: 1 !important;
}

/* AI 설정 - 키 관리 카드 호버 */
.ai-key-card {
    transition: all 0.25s ease;
}
.ai-key-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108,92,231,0.15);
    border-color: #6c5ce7 !important;
    opacity: 1 !important;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.card-header h3,
.card-header h4 {
    font-weight: var(--font-weight-semibold);
}

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.15);
}

/* Clickable card */
.card-clickable {
    cursor: pointer;
}

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

/* Compact card */
.card-compact .card-header,
.card-compact .card-body,
.card-compact .card-footer {
    padding: var(--space-md);
}

/* Highlighted card */
.card-highlighted {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}


/* ------------------------------------------
   8. Top Navigation
   ------------------------------------------ */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background-color: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: var(--z-nav);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    text-decoration: none;
    flex-shrink: 0;
}

.nav-logo img,
.nav-logo svg {
    width: 32px;
    height: 32px;
}

.nav-logo:hover {
    color: var(--color-primary-light);
}

.nav-logo span {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-xxs);
    list-style: none;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.5rem 0.875rem;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.nav-link.active {
    color: var(--color-primary-light);
    background-color: var(--bg-active);
}

.nav-link svg,
.nav-link i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.nav-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: #ffffff;
    cursor: pointer;
    transition: box-shadow var(--transition-fast);
}

.nav-user-avatar:hover {
    box-shadow: var(--shadow-glow);
}

.nav-user-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
}

/* Mobile nav toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

.nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 1px;
    transition: all var(--transition-fast);
}


/* ------------------------------------------
   9. App Container
   ------------------------------------------ */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: var(--nav-height);
}

.app-content {
    flex: 1;
    padding: var(--space-xl) var(--space-lg);
    max-width: var(--container-max);
    margin: 0 auto;
    width: 100%;
}

.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    height: calc(100vh - var(--nav-height));
    position: fixed;
    top: var(--nav-height);
    left: 0;
    overflow-y: auto;
    padding: var(--space-lg) 0;
    z-index: var(--z-sticky);
}

.app-with-sidebar {
    display: flex;
}

.app-with-sidebar .app-content {
    margin-left: var(--sidebar-width);
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.page-header h1,
.page-header h2 {
    flex: 1;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}


/* ------------------------------------------
   10. Toast Notifications
   ------------------------------------------ */
.toast-container {
    position: fixed;
    top: calc(var(--nav-height) + var(--space-md));
    right: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    z-index: var(--z-toast);
    pointer-events: none;
    max-width: 420px;
    width: 100%;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background-color: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: slideUp 0.35s var(--transition-spring) forwards;
    position: relative;
    overflow: hidden;
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: var(--line-height-normal);
}

.toast-close {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
    background: none;
    border: none;
    font-size: 16px;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

/* Toast variants */
.toast-success {
    border-color: rgba(0, 200, 83, 0.25);
}

.toast-success::before {
    background-color: var(--color-success);
}

.toast-success .toast-icon {
    color: var(--color-success);
}

.toast-error {
    border-color: rgba(255, 82, 82, 0.25);
}

.toast-error::before {
    background-color: var(--color-danger);
}

.toast-error .toast-icon {
    color: var(--color-danger);
}

.toast-info {
    border-color: rgba(64, 196, 255, 0.25);
}

.toast-info::before {
    background-color: var(--color-info);
}

.toast-info .toast-icon {
    color: var(--color-info);
}

.toast-warning {
    border-color: rgba(255, 171, 0, 0.25);
}

.toast-warning::before {
    background-color: var(--color-warning);
}

.toast-warning .toast-icon {
    color: var(--color-warning);
}

/* Toast exit */
.toast-exit {
    animation: fadeOut 0.25s ease forwards;
}


/* ------------------------------------------
   11. Modal
   ------------------------------------------ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: var(--space-lg);
    animation: fadeIn 0.2s ease forwards;
}

.modal-overlay.closing {
    animation: fadeOut 0.2s ease forwards;
}

.modal-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - var(--space-3xl));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: none;
    border: none;
    font-size: 20px;
}

.modal-close:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

/* Modal sizes */
.modal-sm .modal-content {
    max-width: 380px;
}

.modal-lg .modal-content {
    max-width: 720px;
}

.modal-xl .modal-content {
    max-width: 960px;
}

.modal-fullscreen .modal-content {
    max-width: none;
    max-height: none;
    width: calc(100vw - var(--space-xl));
    height: calc(100vh - var(--space-xl));
    border-radius: var(--radius-md);
}


/* ------------------------------------------
   12. Loading Overlay
   ------------------------------------------ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    z-index: var(--z-loading);
    animation: fadeIn 0.2s ease forwards;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.loading-spinner-lg {
    width: 64px;
    height: 64px;
    border-width: 4px;
}

.loading-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
}

/* Inline loading */
.loading-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.loading-inline .loading-spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-surface-2) 25%,
        var(--bg-surface-3) 50%,
        var(--bg-surface-2) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--space-xs);
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
}

.skeleton-card {
    height: 200px;
    border-radius: var(--radius-md);
}


/* ------------------------------------------
   13. Badge Styles
   ------------------------------------------ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.6rem;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    line-height: 1.3;
    border-radius: var(--radius-full);
    white-space: nowrap;
    background-color: var(--bg-surface-3);
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.badge-primary {
    background-color: rgba(var(--color-primary-rgb), 0.15);
    color: var(--color-primary-light);
    border-color: rgba(var(--color-primary-rgb), 0.25);
}

.badge-secondary {
    background-color: rgba(var(--color-secondary-rgb), 0.15);
    color: var(--color-secondary-light);
    border-color: rgba(var(--color-secondary-rgb), 0.25);
}

.badge-success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
    border-color: rgba(0, 200, 83, 0.25);
}

.badge-warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
    border-color: rgba(255, 171, 0, 0.25);
}

.badge-danger {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
    border-color: rgba(255, 82, 82, 0.25);
}

.badge-info {
    background-color: var(--color-info-bg);
    color: var(--color-info);
    border-color: rgba(64, 196, 255, 0.25);
}

/* Badge with dot */
.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    flex-shrink: 0;
}

/* Badge sizes */
.badge-sm {
    padding: 0.1rem 0.4rem;
    font-size: 10px;
}

.badge-lg {
    padding: 0.3rem 0.8rem;
    font-size: var(--font-size-sm);
}

/* Count badge (notification) */
.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: var(--font-weight-bold);
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    color: #ffffff;
}


/* ------------------------------------------
   14. Table Styles
   ------------------------------------------ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color var(--transition-fast);
}

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

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

/* Sortable header */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-2);
}

.data-table th.sorted-asc::after,
.data-table th.sorted-desc::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 6px;
    vertical-align: middle;
}

.data-table th.sorted-asc::after {
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 5px solid var(--color-primary);
}

.data-table th.sorted-desc::after {
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--color-primary);
}

/* Compact table */
.data-table-compact th,
.data-table-compact td {
    padding: var(--space-xs) var(--space-sm);
}

/* Striped table */
.data-table-striped tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.015);
}

/* Table wrapper for horizontal scroll */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.table-wrapper .data-table th:first-child,
.table-wrapper .data-table td:first-child {
    padding-left: var(--space-lg);
}

.table-wrapper .data-table th:last-child,
.table-wrapper .data-table td:last-child {
    padding-right: var(--space-lg);
}

/* Empty state */
.table-empty {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg) !important;
    color: var(--text-muted);
}

.table-empty-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    opacity: 0.3;
}


/* ------------------------------------------
   15. Scrollbar Styling
   ------------------------------------------ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #3a3a50;
}

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

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* Thin scrollbar utility */
.scrollbar-thin::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.scrollbar-none::-webkit-scrollbar {
    display: none;
}

.scrollbar-none {
    scrollbar-width: none;
}


/* ------------------------------------------
   16. Animations
   ------------------------------------------ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-6px);
    }
}

/* Animation utility classes */
.animate-fadeIn     { animation: fadeIn 0.3s ease forwards; }
.animate-slideUp   { animation: slideUp 0.35s ease forwards; }
.animate-slideDown { animation: slideDown 0.35s ease forwards; }
.animate-scaleIn   { animation: scaleIn 0.3s ease forwards; }
.animate-spin      { animation: spin 0.8s linear infinite; }
.animate-pulse     { animation: pulse 2s ease-in-out infinite; }
.animate-bounce    { animation: bounce 1s ease infinite; }

/* Stagger delay helpers */
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.10s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.20s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.30s; }


/* ------------------------------------------
   17. Responsive Breakpoints
   ------------------------------------------ */

/* Tablet: 768px and below */
@media (max-width: 768px) {
    :root {
        --nav-height: 56px;
    }

    .container {
        padding: 0 var(--space-md);
    }

    .app-content {
        padding: var(--space-lg) var(--space-md);
    }

    /* Nav responsive */
    .nav-toggle {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        right: 0;
        bottom: 0;
        flex-direction: column;
        background-color: var(--bg-surface);
        padding: var(--space-lg);
        gap: var(--space-xxs);
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        border-right: 1px solid var(--border-color);
        width: 280px;
        overflow-y: auto;
        z-index: var(--z-nav);
    }

    .nav-links.open {
        transform: translateX(0);
    }

    .nav-link {
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-sm);
        width: 100%;
    }

    .nav-user-name {
        display: none;
    }

    /* Sidebar responsive */
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        z-index: var(--z-modal);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-with-sidebar .app-content {
        margin-left: 0;
    }

    /* Grid responsive */
    .grid-cols-3,
    .grid-cols-4,
    .grid-cols-5,
    .grid-cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-cols-12 {
        grid-template-columns: 1fr;
    }

    .col-span-2,
    .col-span-3,
    .col-span-4,
    .col-span-6 {
        grid-column: span 1;
    }

    /* Page header stack */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header-actions {
        width: 100%;
    }

    /* Modal responsive */
    .modal-overlay {
        padding: var(--space-md);
        align-items: flex-end;
    }

    .modal-content {
        max-width: none;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 90vh;
    }

    .modal-lg .modal-content,
    .modal-xl .modal-content {
        max-width: none;
    }

    /* Toast responsive */
    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
        max-width: none;
    }

    /* Table responsive */
    .data-table-responsive {
        display: block;
    }

    .data-table-responsive thead {
        display: none;
    }

    .data-table-responsive tbody,
    .data-table-responsive tr,
    .data-table-responsive td {
        display: block;
    }

    .data-table-responsive tr {
        padding: var(--space-md);
        border-bottom: 1px solid var(--border-color);
    }

    .data-table-responsive td {
        padding: var(--space-xxs) 0;
        border-bottom: none;
        text-align: right;
    }

    .data-table-responsive td::before {
        content: attr(data-label);
        float: left;
        font-weight: var(--font-weight-semibold);
        color: var(--text-muted);
        font-size: var(--font-size-xs);
        text-transform: uppercase;
    }
}

/* Mobile: 480px and below */
@media (max-width: 480px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4,
    .grid-cols-5,
    .grid-cols-6 {
        grid-template-columns: 1fr;
    }

    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: var(--font-size-base);
    }

    h1 { font-size: var(--font-size-2xl); }
    h2 { font-size: var(--font-size-xl);  }
    h3 { font-size: var(--font-size-lg);  }

    .page-header-actions {
        flex-direction: column;
    }

    .page-header-actions .btn {
        width: 100%;
    }

    .card-body {
        padding: var(--space-md);
    }

    .card-header {
        padding: var(--space-md);
    }

    .modal-body {
        padding: var(--space-md);
    }
}

/* Large desktop: 1440px and above */
@media (min-width: 1440px) {
    :root {
        --container-max: 1400px;
    }
}

/* Extra large: 1920px and above */
@media (min-width: 1920px) {
    :root {
        --container-max: 1600px;
    }

    html {
        font-size: 17px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .loading-spinner {
        animation: spin 2s linear infinite !important;
    }
}

/* Print styles */
@media print {
    .top-nav,
    .app-sidebar,
    .toast-container,
    .modal-overlay,
    .loading-overlay,
    .btn,
    .nav-toggle {
        display: none !important;
    }

    body {
        background: #ffffff;
        color: #000000;
    }

    .app-container {
        padding-top: 0;
    }

    .card {
        border: 1px solid #cccccc;
        box-shadow: none;
    }
}
