/* Narwin Docs Frontend Styles */

.narwin-docs-wrapper {
    --narwin-sidebar-width: 280px;
    --narwin-toc-width: 240px;
    --narwin-accent: #0066cc;
    --narwin-text-primary: #1a1a1a;
    --narwin-text-secondary: #666;
    --narwin-border: #e5e7eb;
    --narwin-bg-secondary: #f9fafb;
    --narwin-bg-hover: #f3f4f6;
    
    display: flex;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--narwin-text-primary);
    line-height: 1.6;
    background: #fff;
}

.narwin-docs-wrapper * {
    box-sizing: border-box;
}

/* Mobile Header */
.narwin-docs-mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    border-bottom: 1px solid var(--narwin-border);
    padding: 1rem;
    align-items: center;
    justify-content: space-between;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-menu-toggle .hamburger {
    width: 24px;
    height: 2px;
    background: var(--narwin-text-primary);
    transition: transform 0.3s;
}

.mobile-title {
    font-weight: 600;
    flex: 1;
    text-align: center;
    padding: 0 1rem;
}

/* Sidebar */
.narwin-docs-sidebar {
    position: sticky;
    top: 0;
    left: 0;
    width: var(--narwin-sidebar-width);
    height: 100vh;
    background: var(--narwin-bg-secondary);
    border-right: 1px solid var(--narwin-border);
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--narwin-border);
    background: #fff;
}

.sidebar-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--narwin-text-primary);
}

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

/* Navigation */
.nav-list,
.nav-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-children {
    margin-left: 1.25rem;
    padding-left: 1rem;
    border-left: 1px solid var(--narwin-border);
    margin-top: 0.25rem;
}

.nav-item {
    position: relative;
}

.nav-item.has-children {
    display: flex;
    flex-wrap: wrap;
}

.nav-toggle {
    position: absolute;
    left: 0.5rem;
    top: 0.5rem;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--narwin-text-secondary);
    transition: color 0.2s;
}

.nav-toggle:hover {
    color: var(--narwin-text-primary);
}

.nav-chevron {
    display: block;
    transition: transform 0.2s;
}

.nav-item.expanded .nav-chevron {
    transform: rotate(90deg);
}

.nav-item.has-children .nav-link {
    padding-left: 2rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--narwin-text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-radius: 4px;
    margin: 2px 8px;
    flex: 1;
}

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

.nav-item.active > .nav-link {
    background: var(--narwin-accent);
    color: #fff;
    font-weight: 500;
}

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

.nav-icon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.nav-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main Content */
.narwin-docs-main {
    flex: 1;
    display: flex;
    min-width: 0;
}

.doc-content {
    flex: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.doc-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--narwin-border);
}

.doc-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.doc-icon img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.doc-title {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: var(--narwin-text-primary);
}

/* Document Body Styles */
.doc-body {
    color: var(--narwin-text-primary);
}

.doc-body h1,
.doc-body h2,
.doc-body h3,
.doc-body h4,
.doc-body h5,
.doc-body h6 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--narwin-text-primary);
    scroll-margin-top: 100px;
}

.doc-body h1 { font-size: 1.875rem; }
.doc-body h2 { font-size: 1.5rem; }
.doc-body h3 { font-size: 1.25rem; }

.doc-body p {
    margin: 1rem 0;
}

.doc-body a {
    color: var(--narwin-accent);
    text-decoration: none;
}

.doc-body a:hover {
    text-decoration: underline;
}

.doc-body ul,
.doc-body ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.doc-body li {
    margin: 0.5rem 0;
}

.doc-body code {
    background: var(--narwin-bg-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.875em;
    font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

.doc-body pre {
    background: var(--narwin-bg-secondary);
    border: 1px solid var(--narwin-border);
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.doc-body pre code {
    background: none;
    padding: 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.doc-body blockquote {
    border-left: 4px solid var(--narwin-accent);
    margin: 1.5rem 0;
    padding-left: 1rem;
    color: var(--narwin-text-secondary);
    font-style: italic;
}

.doc-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

.doc-body th,
.doc-body td {
    border: 1px solid var(--narwin-border);
    padding: 0.75rem;
    text-align: left;
}

.doc-body th {
    background: var(--narwin-bg-secondary);
    font-weight: 600;
}

.doc-body hr {
    border: none;
    border-top: 1px solid var(--narwin-border);
    margin: 2rem 0;
}

/* Callout Styles */
.doc-body .callout {
    display: flex;
    gap: 1rem;
    background: var(--narwin-bg-secondary);
    border: 1px solid var(--narwin-border);
    border-radius: 6px;
    padding: 1rem;
    margin: 1.5rem 0;
}

.callout-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.callout-content {
    flex: 1;
}

/* Todo Item Styles */
.doc-body .todo-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.doc-body .todo-item input[type="checkbox"] {
    margin-top: 0.25rem;
    flex-shrink: 0;
}

/* Toggle/Details Styles */
.doc-body details {
    border: 1px solid var(--narwin-border);
    border-radius: 6px;
    padding: 1rem;
    margin: 1rem 0;
}

.doc-body summary {
    cursor: pointer;
    font-weight: 600;
    margin: -1rem;
    padding: 1rem;
    background: var(--narwin-bg-secondary);
}

.doc-body details[open] summary {
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--narwin-border);
}

.toggle-content {
    padding-top: 1rem;
}

/* Columns */
.doc-body .columns {
    display: flex;
    gap: 2rem;
    margin: 1.5rem 0;
}

.doc-body .column {
    flex: 1;
}

/* Images */
.doc-body figure {
    margin: 1.5rem 0;
    text-align: center;
}

.doc-body figure img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid var(--narwin-border);
}

.doc-body figcaption {
    margin-top: 0.5rem;
    color: var(--narwin-text-secondary);
    font-size: 0.875rem;
}

/* Table of Contents */
.narwin-docs-toc {
    position: sticky;
    top: 2rem;
    width: var(--narwin-toc-width);
    padding: 2rem 1rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    flex-shrink: 0;
}

.toc-header {
    margin-bottom: 1rem;
}

.toc-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--narwin-text-secondary);
}

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

.toc-item {
    margin: 0.25rem 0;
}

.toc-level-3 {
    padding-left: 1rem;
}

.toc-link {
    display: block;
    padding: 0.375rem 0;
    color: var(--narwin-text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.toc-link:hover {
    color: var(--narwin-accent);
}

.toc-link.active {
    color: var(--narwin-accent);
    font-weight: 500;
}

/* Loading State */
.narwin-docs-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--narwin-border);
    border-top-color: var(--narwin-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Empty State */
.doc-empty {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--narwin-text-secondary);
}

/* Responsive Design */
@media (max-width: 1280px) {
    .narwin-docs-toc {
        display: none;
    }
}

@media (max-width: 768px) {
    .narwin-docs-wrapper {
        flex-direction: column;
    }
    
    .narwin-docs-mobile-header {
        display: flex;
    }
    
    .narwin-docs-sidebar {
        position: fixed;
        left: -100%;
        width: 80%;
        max-width: 320px;
        z-index: 200;
        transition: left 0.3s;
    }
    
    .narwin-docs-sidebar.mobile-open {
        left: 0;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .doc-content {
        padding: 1rem;
    }
    
    .doc-body .columns {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Print Styles */
@media print {
    .narwin-docs-sidebar,
    .narwin-docs-toc,
    .narwin-docs-mobile-header {
        display: none !important;
    }
    
    .narwin-docs-main {
        width: 100%;
    }
    
    .doc-content {
        max-width: none;
        padding: 0;
    }
}