/* ============================================================
   CardScope User Documentation — Theme-matched Styles
   Matches the main CardScope website at /website/styles.css
   ============================================================ */

/* ---------- CSS Variables (light) ---------- */
:root {
    --primary: #FFCB05;
    --secondary: #3D7DCA;
    --accent: #CC0000;
    --bg: #F8F8F8;
    --surface: #FFFFFF;
    --text: #2A2A2A;
    --text-light: #666666;
    --border: #E0E0E0;
    --sidebar-width: 280px;
    --header-height: 64px;
    --code-bg: #F0F0F0;
}

/* ---------- CSS Variables (dark) ---------- */
[data-theme="dark"] {
    --primary: #FFCB05;
    --secondary: #5A9FE8;
    --accent: #FF4444;
    --bg: #1A1A1A;
    --surface: #242424;
    --text: #E0E0E0;
    --text-light: #A0A0A0;
    --border: #333333;
    --code-bg: #2A2A2A;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    overflow-x: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */
.docs-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .docs-header {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.docs-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 24px;
    max-width: 100%;
}

.docs-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.docs-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Sidebar toggle (hamburger) */
.sidebar-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.sidebar-toggle span {
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}

/* Logo */
.docs-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.docs-logo:hover {
    text-decoration: none;
}

.docs-logo-img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.docs-logo-text {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.docs-logo-text strong {
    font-size: 20px;
    color: var(--secondary);
}

.docs-logo-text span {
    font-size: 14px;
    color: var(--text-light);
}

/* Header nav links — matches main site .nav-links */
.docs-header-nav {
    display: flex;
    list-style: none;
    gap: 32px;
    align-items: center;
}

.docs-header-nav a {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    transition: color 0.2s;
    white-space: nowrap;
}

.docs-header-nav a:hover {
    color: var(--secondary);
}

/* Account CTA button — matches main site .nav-cta */
.docs-nav-cta {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: 700;
}

.docs-nav-cta:hover {
    background: var(--secondary);
    border-color: var(--secondary);
    color: #fff !important;
}

/* Search */
.docs-search {
    position: relative;
}

.docs-search input {
    width: 240px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.docs-search input:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(61, 125, 202, 0.15);
}

.docs-search input::placeholder {
    color: var(--text-light);
}

/* Back link */
.back-to-site {
    color: var(--text-light);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.back-to-site:hover {
    color: var(--secondary);
}

/* Theme toggle */
.theme-toggle {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s;
}

.theme-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.docs-layout {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.docs-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.docs-nav {
    padding: 20px 0;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    padding: 10px 24px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-light);
}

.nav-link {
    display: block;
    padding: 7px 24px 7px 32px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s, color 0.15s, border-left-color 0.15s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: rgba(61, 125, 202, 0.06);
    color: var(--secondary);
}

.nav-link.active {
    background: rgba(61, 125, 202, 0.1);
    color: var(--secondary);
    border-left-color: var(--secondary);
    font-weight: 600;
}

.nav-link.search-hidden {
    display: none;
}

/* Sidebar backdrop (mobile overlay) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.docs-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 40px 48px 80px;
    max-width: 900px;
    min-height: calc(100vh - var(--header-height));
}

.docs-article {
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Loading spinner */
.loading-spinner {
    padding: 80px 0;
    text-align: center;
    color: var(--text-light);
    font-size: 16px;
}

/* ============================================================
   MARKDOWN RENDERED STYLES
   ============================================================ */
.docs-article h1 {
    font-size: 34px;
    margin-bottom: 12px;
    color: var(--text);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.docs-article h2 {
    font-size: 26px;
    margin-top: 40px;
    margin-bottom: 16px;
    color: var(--text);
}

.docs-article h3 {
    font-size: 20px;
    margin-top: 32px;
    margin-bottom: 12px;
    color: var(--secondary);
}

.docs-article h4 {
    font-size: 16px;
    margin-top: 24px;
    margin-bottom: 8px;
    color: var(--text);
}

.docs-article p {
    margin-bottom: 16px;
    color: var(--text);
    line-height: 1.75;
    font-size: 15px;
}

.docs-article ul,
.docs-article ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.docs-article li {
    margin-bottom: 6px;
    line-height: 1.7;
    font-size: 15px;
    color: var(--text);
}

.docs-article a {
    color: var(--secondary);
    text-decoration: none;
    font-weight: 500;
}

.docs-article a:hover {
    text-decoration: underline;
}

.docs-article strong {
    color: var(--text);
    font-weight: 600;
}

.docs-article code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.docs-article pre {
    background: var(--code-bg);
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.docs-article pre code {
    background: none;
    padding: 0;
    font-size: 13px;
    line-height: 1.6;
}

.docs-article blockquote {
    border-left: 4px solid var(--secondary);
    padding: 12px 20px;
    margin: 16px 0;
    background: rgba(61, 125, 202, 0.06);
    border-radius: 0 8px 8px 0;
}

.docs-article blockquote p {
    margin-bottom: 0;
    color: var(--text);
}

.docs-article hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

.docs-article img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    margin: 16px 0;
}

[data-theme="dark"] .docs-article img {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.docs-article table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
}

.docs-article th,
.docs-article td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.docs-article th {
    background: var(--surface);
    font-weight: 600;
    color: var(--text);
}

[data-theme="dark"] .docs-article th {
    background: var(--code-bg);
}

/* Callout boxes */
.callout {
    padding: 16px 20px;
    border-radius: 8px;
    margin: 16px 0;
    font-size: 14px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.callout-icon {
    font-size: 20px;
    flex-shrink: 0;
    line-height: 1.5;
}

.callout-tip {
    background: rgba(52, 199, 89, 0.1);
    border: 1px solid rgba(52, 199, 89, 0.3);
}

.callout-note {
    background: rgba(61, 125, 202, 0.1);
    border: 1px solid rgba(61, 125, 202, 0.3);
}

.callout-warning {
    background: rgba(255, 203, 5, 0.1);
    border: 1px solid rgba(255, 203, 5, 0.3);
}

/* Navigation at bottom of each article */
.page-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.page-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: background 0.2s, border-color 0.2s;
}

.page-nav a:hover {
    background: rgba(61, 125, 202, 0.06);
    border-color: var(--secondary);
    text-decoration: none;
}

.page-nav .prev::before {
    content: '←';
}

.page-nav .next::after {
    content: '→';
}

/* ============================================================
   SEARCH RESULTS OVERLAY
   ============================================================ */
.search-results-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    justify-content: center;
    align-items: flex-start;
    padding-top: 100px;
}

.search-results-overlay.active {
    display: flex;
}

.search-results-panel {
    background: var(--surface);
    border-radius: 12px;
    width: 600px;
    max-width: 90vw;
    max-height: 60vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.search-results-header h3 {
    font-size: 18px;
    color: var(--text);
}

.search-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-light);
    padding: 0 4px;
    line-height: 1;
}

.search-close:hover {
    color: var(--text);
}

.search-results-list {
    overflow-y: auto;
    padding: 12px;
}

.search-result-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:hover {
    background: rgba(61, 125, 202, 0.08);
}

.search-result-item h4 {
    font-size: 15px;
    color: var(--text);
    margin-bottom: 4px;
}

.search-result-item p {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.4;
}

.search-no-results {
    padding: 32px;
    text-align: center;
    color: var(--text-light);
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 900px) {
    .sidebar-toggle {
        display: flex;
    }

    .docs-sidebar {
        transform: translateX(-100%);
    }

    .docs-sidebar.open {
        transform: translateX(0);
    }

    .docs-content {
        margin-left: 0;
        padding: 24px 20px 60px;
    }

    .docs-search input {
        width: 160px;
    }

    .back-to-site {
        display: none;
    }

    .docs-header-nav {
        display: none;
    }

    .docs-article h1 {
        font-size: 26px;
    }

    .docs-article h2 {
        font-size: 22px;
    }

    .page-nav {
        flex-direction: column;
        gap: 12px;
    }

    .page-nav a {
        justify-content: center;
    }
}

@media (max-width: 500px) {
    .docs-search {
        display: none;
    }

    .docs-header-inner {
        padding: 0 12px;
    }

    .docs-content {
        padding: 16px 14px 60px;
    }
}
