/* =========================================================
   DAHIM DIGITAL E-BOOK SYSTEM // THEME ENGINE
   Academic Clean (Default Light) & Quantum Cyber (Dark Sub)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700;800&family=Outfit:wght@400;500;600;700;800;900&display=swap');
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');
@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css');

:root {
    /* Academic Clean Theme Variables (Default) */
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.92);
    --bg-glass: rgba(255, 255, 255, 0.78);
    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;
    
    --text-primary: #0f172a;
    --text-muted: #475569;
    --text-dim: #64748b;
    --text-inverse: #ffffff;

    /* Primary Accent (Dahim Emerald & Academic Navy) */
    --accent: #146B5C;
    --accent-rgb: 20, 107, 92;
    --accent-glow: rgba(20, 107, 92, 0.16);
    --accent-hover: #0e5246;

    /* Secondary Brand Accents */
    --brand-blue: #2563eb;
    --brand-gold: #d97706;
    --brand-rose: #e11d48;
    --brand-purple: #7c3aed;

    /* Typography */
    --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-heading: 'Outfit', 'Pretendard', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Shadows & Radii */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.12);
    --backdrop: blur(20px) saturate(180%);
}

/* Quantum Cyber Theme (Sub-theme) */
body.theme-cyber {
    --bg-main: #030712;
    --bg-surface: #0b132b;
    --bg-surface-elevated: #111e38;
    --bg-card: rgba(15, 23, 42, 0.88);
    --bg-glass: rgba(11, 19, 43, 0.75);
    --border-subtle: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.2);
    
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --text-inverse: #030712;

    --accent: #f59e0b;
    --accent-rgb: 245, 158, 11;
    --accent-glow: rgba(245, 158, 11, 0.3);
    --accent-hover: #d97706;

    --brand-blue: #38bdf8;
    --brand-gold: #f59e0b;
    --brand-rose: #f43f5e;
    --brand-purple: #a855f7;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 30px var(--accent-glow);
}

/* Base Resets */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    letter-spacing: -0.025em;
    font-weight: 800;
}

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

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

/* Common UI Components */
.dh-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.dh-badge-gold {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}
body.theme-cyber .dh-badge-gold {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--accent-glow);
}

.btn-ghost {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-primary);
    font-weight: 600;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border-subtle);
    transition: all 0.2s ease;
}
body.theme-cyber .btn-ghost {
    background: rgba(255, 255, 255, 0.06);
}
.btn-ghost:hover {
    background: rgba(15, 23, 42, 0.09);
    border-color: var(--border-strong);
}

/* Glassmorphism Navigation Bar */
.dh-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop);
    -webkit-backdrop-filter: var(--backdrop);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 24px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.25s ease;
}

.dh-nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, #1e40af 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.15rem;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-text h1 {
    font-size: 1.15rem;
    color: var(--text-primary);
    line-height: 1.2;
}

.brand-text span {
    font-size: 0.68rem;
    color: var(--text-dim);
    letter-spacing: 0.14em;
    font-family: var(--font-mono);
    font-weight: 700;
}

.dh-nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    transition: all 0.2s ease;
}
.nav-icon-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}

/* Command Palette Overlay */
.cmd-palette-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.cmd-palette-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}
.cmd-palette-box {
    width: 92%;
    max-width: 540px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(-10px);
    transition: transform 0.2s ease;
}
.cmd-palette-backdrop.active .cmd-palette-box {
    transform: translateY(0);
}
.cmd-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}
.cmd-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1rem;
    color: var(--text-primary);
    font-family: inherit;
}
.cmd-list {
    max-height: 340px;
    overflow-y: auto;
    padding: 8px;
}
.cmd-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.cmd-item:hover {
    background: var(--accent-glow);
    color: var(--accent);
}

/* 폰: 상단바 오른쪽 버튼 묶음이 화면 밖으로 밀리지 않게 */
@media (max-width: 600px) {
    .dh-nav { padding: 0 14px; gap: 10px; }
    .dh-nav-brand { min-width: 0; }
    .brand-text span { display: none; }
    .brand-text h1 { font-size: 1rem; white-space: nowrap; }
    .dh-nav-actions { gap: 8px; flex-shrink: 0; }
    .nav-icon-btn { width: 34px; height: 34px; }
}
@media (max-width: 480px) {
    .dh-nav-actions > .dh-badge { display: none; }
}
