/* ========== DOCS HERO ========== */

.docs-hero {
    padding: calc(var(--header-height) + 4rem) 1.5rem 4rem;
    padding-left: calc(280px + 1.5rem);
    text-align: center;
    background: linear-gradient(
        to bottom,
        var(--color-bg),
        var(--color-surface)
    );
}

.docs-hero-title {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.docs-hero-subtitle {
    font-size: 1.25rem;
    color: var(--color-muted);
    max-width: 600px;
    margin: 0 auto 1.5rem;
}

/* ========== SEARCH ========== */

.docs-search-container {
    position: relative;
    max-width: 480px;
    margin: 0 auto;
}

.docs-search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-muted);
    pointer-events: none;
    z-index: 1;
}

.docs-search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    font-size: 0.9375rem;
    font-family: var(--font-sans);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    color: var(--color-text);
    outline: none;
    transition: border-color 0.2s;
}

.docs-search-input:focus {
    border-color: var(--color-primary);
}

.docs-search-input::placeholder {
    color: var(--color-muted);
}

.docs-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.docs-search-result {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
    transition: background 0.2s;
    cursor: pointer;
}

.docs-search-result:hover {
    background: rgba(223, 25, 29, 0.05);
}

.docs-search-result:last-child {
    border-bottom: none;
}

.docs-search-result-title {
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.9375rem;
}

.docs-search-result-section {
    font-size: 0.75rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.125rem;
}

.docs-search-result-snippet {
    font-size: 0.8125rem;
    color: var(--color-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.docs-search-empty {
    padding: 1rem;
    text-align: center;
    color: var(--color-muted);
    font-size: 0.875rem;
}

/* ========== DOCS LAYOUT ========== */

.docs-container {
    min-height: calc(100vh - var(--header-height));
    position: relative;
}

/* ========== SIDEBAR ========== */

.docs-sidebar {
    width: 280px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 10;
    transition: transform 0.3s ease;
}

.docs-sidebar-header {
    padding: 2rem 1.5rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.docs-sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

.docs-nav {
    padding: 1rem 0;
}

.docs-nav-section {
    margin-bottom: 1.5rem;
}

.docs-nav-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    padding: 0.5rem 1.5rem;
    margin: 0;
}

.docs-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.docs-nav-item {
    margin: 0;
}

.docs-nav-link {
    display: block;
    padding: 0.625rem 1.5rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.docs-nav-link:hover {
    background: rgba(223, 25, 29, 0.05);
    border-left-color: var(--color-primary);
    color: var(--color-primary);
    padding-left: 1.75rem;
}

.docs-nav-link.active {
    background: rgba(223, 25, 29, 0.1);
    border-left-color: var(--color-primary);
    color: var(--color-primary);
    font-weight: 600;
}

.docs-nav-home {
    font-weight: 600;
    padding-bottom: 0.75rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--color-border);
}

/* Sidebar Overlay (mobile) */
.docs-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.docs-sidebar-overlay.active {
    opacity: 1;
}

/* Mobile Sidebar Toggle */
.docs-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    background: var(--color-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(223, 25, 29, 0.4);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.docs-sidebar-toggle span {
    width: 20px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}

.docs-sidebar-toggle.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.docs-sidebar-toggle.active span:nth-child(2) {
    opacity: 0;
}

.docs-sidebar-toggle.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ========== MAIN CONTENT ========== */

.docs-content {
    margin-left: 280px;
    padding: 3rem;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.docs-article {
    max-width: 900px;
    margin: 0 auto;
    color: var(--color-text);
}

/* Loading State */
.docs-loading {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--color-muted);
}

.docs-loading::before {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    margin: 0 auto 1rem;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: docs-spin 0.8s linear infinite;
}

@keyframes docs-spin {
    to { transform: rotate(360deg); }
}

/* ========== TABLE OF CONTENTS ========== */

.docs-toc {
    width: 220px;
    position: fixed;
    top: calc(var(--header-height) + 2rem);
    right: 2rem;
    max-height: calc(100vh - var(--header-height) - 4rem);
    overflow-y: auto;
    display: none;
}

.docs-toc.visible {
    display: block;
}

.docs-toc-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    margin-bottom: 0.75rem;
}

.docs-toc-nav {
    display: flex;
    flex-direction: column;
}

.docs-toc-link {
    display: block;
    padding: 0.25rem 0;
    padding-left: 0.75rem;
    font-size: 0.8125rem;
    color: var(--color-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all 0.2s;
    line-height: 1.4;
}

.docs-toc-link--sub {
    padding-left: 1.5rem;
    font-size: 0.75rem;
}

.docs-toc-link:hover {
    color: var(--color-text);
}

.docs-toc-link.active {
    color: var(--color-primary);
    border-left-color: var(--color-primary);
}

/* ========== PREV/NEXT NAVIGATION ========== */

.docs-prev-next {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
}

.docs-prev-next-link {
    display: block;
    padding: 1rem 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    text-decoration: none;
    transition: all 0.2s;
    background: var(--color-surface);
}

.docs-prev-next-link:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.docs-prev-next-next {
    text-align: right;
}

.docs-prev-next-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    margin-bottom: 0.25rem;
}

.docs-prev-next-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary);
}

/* ========== BACK TO TOP ========== */

.docs-back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.3s;
    z-index: 90;
    box-shadow: 0 4px 12px rgba(223, 25, 29, 0.3);
}

.docs-back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.docs-back-to-top:hover {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(223, 25, 29, 0.4);
}

/* ========== INDEX PAGE ========== */

.docs-index {
    padding-bottom: 2rem;
}

/* Highlights bar */
.docs-index-highlights {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.docs-index-highlight {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.25rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
}

.docs-index-highlight-value {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.docs-index-highlight-label {
    font-size: 0.8125rem;
    color: var(--color-muted);
    font-weight: 500;
}

/* Quick start banner */
.docs-index-quickstart {
    margin-bottom: 2.5rem;
}

.docs-index-quickstart-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: rgba(223, 25, 29, 0.05);
    border: 1px solid rgba(223, 25, 29, 0.2);
    border-radius: 0.75rem;
    text-decoration: none;
    transition: all 0.2s ease;
    color: var(--color-text);
}

.docs-index-quickstart-link:hover {
    border-color: var(--color-primary);
    background: rgba(223, 25, 29, 0.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(223, 25, 29, 0.1);
}

.docs-index-quickstart-link svg {
    color: var(--color-primary);
    flex-shrink: 0;
}

.docs-index-quickstart-link div {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.docs-index-quickstart-link strong {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.docs-index-quickstart-link span {
    font-size: 0.875rem;
    color: var(--color-muted);
}

/* Sections */
.docs-index-section {
    margin-bottom: 2.5rem;
}

.docs-index-section-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 1rem;
}

.docs-index-section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
}

.docs-index-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
    border-bottom: none;
    padding-bottom: 0;
}

/* Cards grid */
.docs-index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.docs-index-card {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
}

.docs-index-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.docs-index-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(223, 25, 29, 0.1);
    color: var(--color-primary);
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.docs-index-card-body {
    flex: 1;
    min-width: 0;
}

.docs-index-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 0.375rem;
}

.docs-index-card:hover .docs-index-card-title {
    color: var(--color-primary);
}

.docs-index-card-desc {
    font-size: 0.8125rem;
    color: var(--color-muted);
    margin: 0;
    line-height: 1.5;
}

.docs-index-card-arrow {
    display: inline-block;
    font-size: 0.875rem;
    color: var(--color-primary);
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.2s ease;
    flex-shrink: 0;
    align-self: center;
}

.docs-index-card:hover .docs-index-card-arrow {
    opacity: 1;
    transform: translateX(0);
}

@media (max-width: 768px) {
    .docs-index-highlights {
        grid-template-columns: repeat(2, 1fr);
    }

    .docs-index-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .docs-index-highlights {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .docs-index-highlight {
        padding: 1rem 0.75rem;
    }

    .docs-index-highlight-value {
        font-size: 1.5rem;
    }

    .docs-index-quickstart-link {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }

    .docs-index-quickstart-link .docs-index-card-arrow {
        display: none;
    }
}

/* ========== MARKDOWN CONTENT STYLES ========== */

.docs-article h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
    color: var(--color-text);
}

.docs-article h2 {
    font-size: 2rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}

.docs-article h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    color: var(--color-text);
}

.docs-article h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    color: var(--color-text);
}

.docs-article p {
    font-size: 1rem;
    line-height: 1.75;
    margin-bottom: 1.25rem;
    color: var(--color-text);
}

.docs-article ul,
.docs-article ol {
    margin: 1.25rem 0;
    padding-left: 2rem;
    color: var(--color-text);
}

.docs-article li {
    margin-bottom: 0.5rem;
    line-height: 1.75;
}

.docs-article li > ul,
.docs-article li > ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.docs-article a {
    color: var(--color-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.docs-article a:hover {
    border-bottom-color: var(--color-primary);
}

.docs-article code {
    background: var(--color-surface);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.875em;
    color: var(--color-accent);
    border: 1px solid var(--color-border);
}

.docs-article pre {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.5rem 0;
    max-width: 100%;
}

.docs-article pre code {
    background: none;
    padding: 0;
    border: none;
    color: var(--color-text);
    font-size: 0.875rem;
    line-height: 1.6;
}

.docs-article blockquote {
    border-left: 4px solid var(--color-primary);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--color-muted);
}

.docs-article blockquote p {
    margin-bottom: 0.75rem;
}

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

.docs-article .table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.5rem 0;
}

.docs-article table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.docs-article table th,
.docs-article table td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    text-align: left;
}

.docs-article table th {
    background: var(--color-surface);
    font-weight: 600;
    color: var(--color-text);
}

.docs-article table td {
    color: var(--color-text);
}

.docs-article table tbody tr:hover {
    background: rgba(223, 25, 29, 0.05);
}

.docs-article hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2rem 0;
}

.docs-article img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem 0;
}

/* Alert/Callout Styles */
.docs-article .alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    border-left: 4px solid;
}

.docs-article .alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: var(--color-text);
}

.docs-article .alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: #f59e0b;
    color: var(--color-text);
}

.docs-article .alert-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: #22c55e;
    color: var(--color-text);
}

.docs-article .alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: var(--color-text);
}

/* ========== FOOTER OVERRIDE ========== */

.footer {
    margin-left: 280px;
}

/* ========== RESPONSIVE ========== */

/* Wide screens: show TOC */
@media (min-width: 1281px) {
    .docs-back-to-top {
        right: calc(220px + 3rem);
    }
}

@media (max-width: 1280px) {
    .docs-toc {
        display: none !important;
    }
}

@media (max-width: 1024px) {
    .docs-content {
        padding: 2.5rem 2rem;
    }

    .docs-hero {
        padding-left: calc(280px + 1rem);
    }
}

@media (max-width: 768px) {
    .docs-hero {
        padding: calc(var(--header-height) + 2.5rem) 1.5rem 3rem;
    }

    .docs-hero-title {
        font-size: 2rem;
    }

    .docs-hero-subtitle {
        font-size: 1rem;
    }

    .docs-search-container {
        max-width: 100%;
    }

    .docs-sidebar {
        transform: translateX(-100%);
    }

    .docs-sidebar.active {
        transform: translateX(0);
    }

    .docs-sidebar-overlay.active {
        display: block;
    }

    .docs-sidebar-toggle {
        display: flex;
    }

    .docs-content {
        margin-left: 0;
        padding: 2rem 1.5rem;
    }

    .docs-article h1 {
        font-size: 2rem;
    }

    .docs-article h2 {
        font-size: 1.5rem;
    }

    .docs-article h3 {
        font-size: 1.25rem;
    }

    .docs-article table {
        font-size: 0.875rem;
    }

    .docs-article table th,
    .docs-article table td {
        padding: 0.5rem 0.625rem;
        white-space: normal;
    }

    .docs-article pre {
        padding: 1rem;
        font-size: 0.8125rem;
    }

    .docs-back-to-top {
        bottom: 6rem;
    }

    .footer {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .docs-hero-title {
        font-size: 1.75rem;
    }

    .docs-hero-subtitle {
        font-size: 0.9375rem;
    }

    .docs-content {
        padding: 1.5rem 1rem;
    }

    .docs-article h1 {
        font-size: 1.75rem;
    }

    .docs-article h2 {
        font-size: 1.375rem;
    }

    .docs-article pre {
        padding: 0.875rem;
        border-radius: 6px;
    }

    .docs-article pre code {
        font-size: 0.8125rem;
    }

    .docs-prev-next {
        grid-template-columns: 1fr;
    }

    .docs-prev-next-next {
        text-align: left;
    }
}

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Heading anchor links */
.docs-article h2:hover .header-anchor,
.docs-article h3:hover .header-anchor,
.docs-article h4:hover .header-anchor {
    opacity: 1;
}

.header-anchor {
    opacity: 0;
    margin-left: 0.5rem;
    color: var(--color-muted);
    text-decoration: none;
    font-weight: 400;
    transition: opacity 0.2s;
}

.header-anchor:hover {
    color: var(--color-primary);
}
