/* Unibot Documentation - Professional Theme */

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */
:root {
    /* Brand Colors */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;

    /* Background Colors */
    --bg-page: #ffffff;
    --bg-sidebar: #fafbfc;
    --bg-sidebar-hover: #f0f1f3;
    --bg-code: #f6f8fa;
    --bg-code-dark: #1e293b;

    /* Text Colors */
    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-tertiary: #718096;
    --text-link: #6366f1;
    --text-link-hover: #4f46e5;

    /* Border Colors */
    --border: #e2e8f0;
    --border-light: #edf2f7;
    --border-focus: #6366f1;

    /* Hint/Callout Colors */
    --hint-info-bg: #eff6ff;
    --hint-info-border: #3b82f6;
    --hint-info-text: #1e40af;
    --hint-info-icon: #3b82f6;

    --hint-warning-bg: #fffbeb;
    --hint-warning-border: #f59e0b;
    --hint-warning-text: #92400e;
    --hint-warning-icon: #f59e0b;

    --hint-danger-bg: #fef2f2;
    --hint-danger-border: #ef4444;
    --hint-danger-text: #991b1b;
    --hint-danger-icon: #ef4444;

    --hint-success-bg: #f0fdf4;
    --hint-success-border: #22c55e;
    --hint-success-text: #166534;
    --hint-success-icon: #22c55e;

    /* Layout */
    --sidebar-width: 280px;
    --content-max-width: 820px;
    --content-padding: 48px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

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

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    --line-height-tight: 1.4;
    --line-height-normal: 1.6;
    --line-height-relaxed: 1.75;
}

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

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

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: var(--line-height-relaxed);
    color: var(--text-primary);
    background: var(--bg-page);
}

::selection {
    background: var(--primary-light);
    color: var(--primary);
}

/* ============================================
   Layout Structure
   ============================================ */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar Navigation
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

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

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

.sidebar-header {
    padding: var(--space-lg) var(--space-md);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.logo:hover {
    opacity: 0.8;
    text-decoration: none;
}

.logo-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md) 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.nav-list {
    list-style: none;
}

.nav-list li a {
    display: flex;
    align-items: center;
    padding: 10px var(--space-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 450;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    margin: 1px 0;
    -webkit-tap-highlight-color: transparent;
}

.nav-list li a:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-list li a:active {
    background: var(--border);
}

.nav-list li.active > a {
    background: linear-gradient(90deg, var(--primary-light) 0%, transparent 100%);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 550;
}

.nav-section {
    margin-top: var(--space-md);
}

.nav-section:first-child {
    margin-top: 0;
}

.nav-section-title {
    display: block;
    padding: var(--space-lg) var(--space-md) var(--space-sm);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
}

.nav-list .nav-list {
    margin: 0;
    padding: 0;
}

.nav-list .nav-list li a {
    padding-left: var(--space-lg);
    font-size: 0.875rem;
}

.sidebar-footer {
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
    background: var(--bg-sidebar);
}

.sidebar-footer a {
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 0.6875rem;
    opacity: 0.6;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.sidebar-footer a:hover {
    opacity: 1;
    color: var(--text-secondary);
}

.footer-sep {
    color: var(--text-tertiary);
    opacity: 0.4;
    font-size: 0.6875rem;
    user-select: none;
}

/* ============================================
   Main Content Area
   ============================================ */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    background: var(--bg-page);
}

.page {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-2xl) var(--content-padding) calc(var(--space-2xl) * 2);
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 650;
    line-height: var(--line-height-tight);
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

h1 {
    font-size: 2.25rem;
    margin-bottom: var(--space-lg);
}

h2 {
    font-size: 1.625rem;
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-md);
    padding-top: var(--space-md);
}

h3 {
    font-size: 1.375rem;
    margin-top: var(--space-xl);
    margin-bottom: var(--space-sm);
}

h4 {
    font-size: 1.125rem;
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

h5, h6 {
    font-size: 1rem;
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

p {
    margin: 0 0 var(--space-md);
    color: var(--text-primary);
}

strong, b {
    font-weight: 600;
}

mark {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.1em 0.3em;
    border-radius: var(--radius-sm);
}

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

a:hover {
    color: var(--text-link-hover);
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

button:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* ============================================
   Lists
   ============================================ */
ul, ol {
    margin: 0 0 var(--space-md);
    padding-left: var(--space-lg);
}

li {
    margin-bottom: var(--space-xs);
    line-height: var(--line-height-normal);
}

li > ul, li > ol {
    margin-top: var(--space-xs);
    margin-bottom: 0;
}

li::marker {
    color: var(--text-tertiary);
}

/* ============================================
   Code & Pre
   ============================================ */
code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-code);
    color: #d946ef;
    padding: 0.2em 0.45em;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    white-space: nowrap;
    font-weight: 500;
}

pre {
    margin: var(--space-md) 0;
    padding: var(--space-md);
    background: var(--bg-code-dark);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    border: 1px solid #334155;
}

pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.875rem;
    line-height: var(--line-height-normal);
    color: #e2e8f0;
    white-space: pre;
}

/* ============================================
   Images & Figures
   ============================================ */
img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    margin: var(--space-md) 0;
    box-shadow: var(--shadow-sm);
}

figure {
    margin: var(--space-xl) 0;
    text-align: center;
}

figure img {
    margin: 0 auto;
    display: block;
}

figcaption {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin-top: var(--space-sm);
    font-style: italic;
}

/* ============================================
   Blockquotes
   ============================================ */
blockquote {
    margin: var(--space-md) 0;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-code);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    color: var(--text-secondary);
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* ============================================
   Horizontal Rules
   ============================================ */
hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: var(--space-xl) 0;
}

/* ============================================
   Tables
   ============================================ */
table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-md) 0;
    font-size: 0.9375rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

th, td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-code);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-code);
}

/* ============================================
   Hints / Callout Boxes
   ============================================ */
.hint {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    margin: var(--space-lg) 0;
    border-left: 4px solid;
    box-shadow: var(--shadow-sm);
}

.hint-icon {
    flex-shrink: 0;
    font-size: 1.25rem;
    line-height: 1.5;
}

.hint-content {
    flex: 1;
    min-width: 0;
    font-size: 0.9375rem;
}

.hint-content > *:first-child {
    margin-top: 0;
}

.hint-content > *:last-child {
    margin-bottom: 0;
}

.hint-content a {
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.hint-info {
    background: var(--hint-info-bg);
    border-color: var(--hint-info-border);
    color: var(--hint-info-text);
}

.hint-warning {
    background: var(--hint-warning-bg);
    border-color: var(--hint-warning-border);
    color: var(--hint-warning-text);
}

.hint-danger {
    background: var(--hint-danger-bg);
    border-color: var(--hint-danger-border);
    color: var(--hint-danger-text);
}

.hint-success {
    background: var(--hint-success-bg);
    border-color: var(--hint-success-border);
    color: var(--hint-success-text);
}

/* ============================================
   Details / Accordion (FAQ)
   ============================================ */
details {
    margin: var(--space-sm) 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-page);
    transition: box-shadow var(--transition-normal);
}

details:hover {
    box-shadow: var(--shadow-sm);
}

details[open] {
    box-shadow: var(--shadow-md);
}

details + details {
    margin-top: calc(var(--space-sm) * -1);
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

details:has(+ details) {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

summary {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-code);
    cursor: pointer;
    font-weight: 550;
    font-size: 0.9375rem;
    color: var(--text-primary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    transition: all var(--transition-fast);
    user-select: none;
}

summary::-webkit-details-marker {
    display: none;
}

summary::before {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-tertiary);
    border-bottom: 2px solid var(--text-tertiary);
    transform: rotate(-45deg);
    transition: transform var(--transition-normal);
    flex-shrink: 0;
    margin-left: 2px;
}

details[open] summary::before {
    transform: rotate(45deg);
}

summary:hover {
    background: var(--bg-sidebar-hover);
}

details[open] summary {
    border-bottom: 1px solid var(--border);
}

details > *:not(summary) {
    padding: 0 var(--space-lg);
}

details > *:not(summary):first-of-type {
    padding-top: var(--space-md);
}

details > *:not(summary):last-child {
    padding-bottom: var(--space-md);
}

/* ============================================
   Embeds (YouTube, Links)
   ============================================ */
.embed-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin: var(--space-lg) 0;
    border-radius: var(--radius-xl);
    background: #000;
    box-shadow: var(--shadow-lg);
}

.embed-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.embed-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin: var(--space-md) 0;
    transition: all var(--transition-fast);
}

.embed-link:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.embed-link a {
    font-weight: 500;
    color: var(--text-primary);
}

.embed-link:hover a {
    color: var(--primary);
}

/* ============================================
   Content References
   ============================================ */
.content-ref {
    display: block;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin: var(--space-md) 0;
    transition: all var(--transition-fast);
}

.content-ref:hover {
    border-color: var(--primary);
    background: var(--bg-page);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
    text-decoration: none;
}

.content-ref a {
    font-weight: 500;
    color: var(--text-primary);
}

.content-ref:hover a {
    color: var(--primary);
    text-decoration: none;
}

/* ============================================
   Mobile Menu Button
   ============================================ */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: var(--space-md);
    left: var(--space-md);
    z-index: 200;
    background: var(--bg-page);
    color: var(--text-primary);
    border: 1px solid var(--border);
    width: 48px;
    height: 48px;
    border-radius: var(--radius-xl);
    font-size: 1.375rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn:hover {
    background: var(--bg-code);
    box-shadow: var(--shadow-xl);
    transform: scale(1.02);
}

.mobile-menu-btn:active {
    transform: scale(0.96);
    box-shadow: var(--shadow-md);
}

/* ============================================
   Mobile Overlay
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.sidebar.open + .sidebar-overlay {
    display: block;
    opacity: 1;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 260px;
        --content-padding: 40px;
    }
}

@media (max-width: 1024px) {
    :root {
        --content-padding: 32px;
    }

    .page {
        padding-top: var(--space-xl);
        padding-bottom: var(--space-2xl);
    }
}

@media (max-width: 768px) {
    :root {
        --content-padding: 20px;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
        box-shadow: none;
        width: 300px;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .sidebar-header {
        padding-left: 76px;
    }

    .sidebar-footer {
        padding: var(--space-md);
        flex-wrap: wrap;
    }

    .content {
        margin-left: 0;
    }

    .page {
        padding-top: 80px;
        padding-bottom: var(--space-2xl);
    }

    h1 {
        font-size: 1.75rem;
        line-height: 1.3;
    }

    h2 {
        font-size: 1.375rem;
        margin-top: var(--space-xl);
    }

    h3 {
        font-size: 1.125rem;
    }

    p, li {
        font-size: 0.9375rem;
    }

    .hint {
        padding: var(--space-md);
        flex-direction: column;
        gap: var(--space-sm);
    }

    .hint-icon {
        font-size: 1.125rem;
    }

    details summary {
        padding: var(--space-md);
        font-size: 0.875rem;
    }

    table {
        font-size: 0.8125rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    th, td {
        padding: var(--space-sm);
        white-space: nowrap;
    }

    pre {
        font-size: 0.8125rem;
        padding: var(--space-md);
    }

    .embed-container {
        margin: var(--space-md) 0;
        border-radius: var(--radius-lg);
    }
}

@media (max-width: 480px) {
    :root {
        --content-padding: 16px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .logo {
        font-size: 0.875rem;
    }

    .logo-icon {
        width: 22px;
        height: 22px;
    }

    .nav-list li a {
        padding: 12px var(--space-md);
        font-size: 0.875rem;
    }

    .sidebar-footer {
        font-size: 0.625rem;
    }

    .sidebar-footer a {
        font-size: 0.625rem;
    }

    .footer-sep {
        font-size: 0.625rem;
    }

    .mobile-menu-btn {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
    }

    .sidebar-header {
        padding-left: 68px;
    }

    .page {
        padding-top: 72px;
    }

    .hint {
        padding: var(--space-sm) var(--space-md);
    }

    .embed-link,
    .content-ref {
        padding: var(--space-sm) var(--space-md);
    }

    figure {
        margin: var(--space-md) 0;
    }

    img {
        border-radius: var(--radius-md);
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .sidebar,
    .mobile-menu-btn,
    .sidebar-overlay {
        display: none !important;
    }

    .content {
        margin-left: 0;
    }

    .page {
        padding: 0;
        max-width: 100%;
    }

    a {
        color: var(--text-primary);
        text-decoration: underline;
    }

    .hint, details, .embed-container {
        break-inside: avoid;
    }
}

/* ============================================
   Dark Mode
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-page: #0f172a;
        --bg-sidebar: #1e293b;
        --bg-sidebar-hover: #334155;
        --bg-code: #1e293b;
        --bg-code-dark: #0f172a;

        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-tertiary: #94a3b8;
        --text-link: #818cf8;
        --text-link-hover: #a5b4fc;

        --border: #334155;
        --border-light: #475569;
        --border-focus: #818cf8;

        --primary: #818cf8;
        --primary-hover: #a5b4fc;
        --primary-light: rgba(129, 140, 248, 0.15);

        --hint-info-bg: rgba(59, 130, 246, 0.15);
        --hint-info-border: #3b82f6;
        --hint-info-text: #93c5fd;

        --hint-warning-bg: rgba(245, 158, 11, 0.15);
        --hint-warning-border: #f59e0b;
        --hint-warning-text: #fcd34d;

        --hint-danger-bg: rgba(239, 68, 68, 0.15);
        --hint-danger-border: #ef4444;
        --hint-danger-text: #fca5a5;

        --hint-success-bg: rgba(34, 197, 94, 0.15);
        --hint-success-border: #22c55e;
        --hint-success-text: #86efac;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
        --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    }

    pre {
        background: #0f172a;
        border-color: #334155;
    }

    img {
        opacity: 0.95;
    }

    code {
        color: #f472b6;
        background: #334155;
        border-color: #475569;
    }

    ::selection {
        background: rgba(129, 140, 248, 0.4);
        color: #f1f5f9;
    }
}

/* ============================================
   Utility Classes
   ============================================ */
.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;
}

/* ============================================
   Animation Keyframes
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* Smooth page load */
.page {
    animation: fadeIn 0.3s ease;
}
