/**
 * SmartCane Documentation Viewer - Styles
 * Inherits from theme.css for consistent branding
 */

:root {
    /* SmartCane colors (inherited from theme.css) */
    --smartcane-teal: #008080;
    --smartcane-dark: #003d3d;
    --smartcane-light: #e8f5f5;
    --text-dark: #333;
    --text-light: #666;
    --border-color: #ddd;
    --code-bg: #f5f5f5;
    --accent-color: #0088cc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: #fff;
    color: var(--text-dark);
    line-height: 1.6;
}

/* ===== HEADER ===== */
.navbar-header {
    background: linear-gradient(135deg, var(--smartcane-teal) 0%, var(--smartcane-dark) 100%);
    color: white;
    padding: 2rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 0.75rem;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.back-button:hover {
    background-color: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
}

.back-button:active {
    background-color: rgba(255, 255, 255, 0.35);
}

.navbar-content {
    flex: 1;
}

.navbar-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.navbar-subtitle {
    font-size: 0.95rem;
    opacity: 0.95;
    font-weight: 300;
}

/* ===== MAIN CONTAINER ===== */
.doc-container {
    display: flex;
    height: calc(100vh - 140px); /* Account for header and scrollbar */
    max-width: 1400px;
    margin: 0 auto;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 280px;
    background-color: #f9f9f9;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #f0f8f8 0%, #f9f9f9 100%);
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h2 {
    font-size: 1.1rem;
    color: var(--smartcane-dark);
    font-weight: 600;
}

/* Search Box */
.search-box {
    padding: 1rem 1rem 0.5rem;
}

.search-box input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    background-color: white;
    color: var(--text-dark);
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
    border-color: var(--smartcane-teal);
    box-shadow: 0 0 0 3px rgba(0, 128, 128, 0.1);
}

.search-box input::placeholder {
    color: #999;
}

/* Navigation */
.doc-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

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

.doc-nav li {
    transition: background-color 0.2s ease;
}

.doc-link {
    display: block;
    padding: 0.75rem 1.25rem;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.95rem;
    border-left: 4px solid transparent;
    transition: all 0.2s ease;
    word-break: break-word;
}

.doc-link:hover {
    background-color: #f0f0f0;
    border-left-color: var(--smartcane-teal);
    color: var(--smartcane-teal);
    padding-left: 1.5rem;
}

.doc-link.active {
    background-color: var(--smartcane-light);
    border-left-color: var(--smartcane-teal);
    color: var(--smartcane-dark);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background-color: #f5f5f5;
    text-align: center;
    color: #999;
    font-size: 0.85rem;
    position: sticky;
    bottom: 0;
}

.loading {
    padding: 1rem;
    color: #999;
    text-align: center;
    font-style: italic;
    font-size: 0.9rem;
}

/* ===== MAIN CONTENT ===== */
.doc-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 2.5rem;
    background-color: white;
}

.welcome-message {
    max-width: none;
    margin: 0 auto;
}

.welcome-message h1 {
    color: var(--smartcane-dark);
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

.welcome-message p {
    margin-bottom: 1rem;
    color: var(--text-light);
    line-height: 1.8;
}

.welcome-message ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-light);
    line-height: 1.8;
}

.welcome-message code {
    background-color: var(--code-bg);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #d73a49;
    font-size: 0.9em;
}

/* ===== MARKDOWN RENDERING ===== */
.markdown-body {
    max-width: 100%;
    margin: 0 auto;
}

/* Headings */
.markdown-body h1 {
    color: var(--smartcane-dark);
    font-size: 2em;
    margin: 1.5em 0 0.5em;
    padding-bottom: 0.3em;
    border-bottom: 2px solid var(--border-color);
    line-height: 1.25;
}

.markdown-body h2 {
    color: var(--smartcane-teal);
    font-size: 1.5em;
    margin: 1.3em 0 0.4em;
    padding-bottom: 0.2em;
    border-bottom: 1px solid #eee;
    line-height: 1.25;
}

.markdown-body h3 {
    color: var(--text-dark);
    font-size: 1.2em;
    margin: 1.1em 0 0.3em;
    line-height: 1.25;
}

.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    color: var(--text-dark);
    margin: 1em 0 0.3em;
    line-height: 1.25;
}

/* Paragraphs and text */
.markdown-body p {
    margin-bottom: 1em;
    line-height: 1.8;
    color: var(--text-dark);
}

/* Lists */
.markdown-body ul,
.markdown-body ol {
    margin-bottom: 1em;
    margin-left: 2em;
}

.markdown-body li {
    margin-bottom: 0.5em;
    line-height: 1.7;
    color: var(--text-dark);
}

/* Links */
.markdown-body a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.markdown-body a:hover {
    text-decoration: underline;
    border-bottom-color: var(--accent-color);
}

/* Code blocks */
.markdown-body code {
    background-color: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', 'Monaco', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: #d73a49;
    word-break: break-word;
}

.markdown-body pre {
    background-color: var(--code-bg);
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 1rem;
    margin: 1.5em 0;
    overflow-x: auto;
    line-height: 1.5;
}

.markdown-body pre code {
    background-color: transparent;
    padding: 0;
    color: #333;
    font-size: 0.9em;
}

.markdown-body .code-block {
    color: #333;
}

/* Tables */
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5em 0;
    border: 1px solid var(--border-color);
}

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

.markdown-body table th {
    background-color: var(--smartcane-light);
    color: var(--smartcane-dark);
    font-weight: 600;
}

.markdown-body table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.markdown-body table tr:hover {
    background-color: #f0f0f0;
}

/* Blockquotes */
.markdown-body blockquote {
    border-left: 4px solid var(--smartcane-teal);
    padding-left: 1em;
    margin-left: 0;
    margin-bottom: 1em;
    color: var(--text-light);
    font-style: italic;
}

/* Horizontal rules */
.markdown-body hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 2rem 0;
}

/* Mermaid diagrams */
.markdown-body svg {
    max-width: 100%;
    height: auto;
    margin: 1.5rem 0;
}

/* Mermaid wrapper and zoom controls */
.mermaid-wrapper {
    margin: 2rem 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: transparent;
    display: flex;
    flex-direction: column;
}

.mermaid-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: #f9f9f9;
    border-bottom: 1px solid var(--border-color);
    border-radius: 6px 6px 0 0;
    align-items: center;
}

.zoom-btn {
    padding: 0.5rem 0.75rem;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-dark);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.zoom-btn:hover {
    background-color: var(--smartcane-light);
    border-color: var(--smartcane-teal);
    color: var(--smartcane-dark);
}

.zoom-btn:active {
    background-color: #d4eae9;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
    margin: 0 0.5rem;
}

.zoom-hint {
    font-size: 0.85rem;
    color: #999;
    white-space: nowrap;
    user-select: none;
}

.mermaid-zoom-container {
    padding: 1rem;
    overflow: auto;
    min-height: 300px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    cursor: auto;
    background-color: transparent;
}

.mermaid-zoom-container .mermaid {
    margin: 0;
    display: inline-block;
    transition: transform 0.3s ease;
    background-color: transparent;
}

.markdown-body .mermaid {
    max-width: none;
    height: auto;
    margin: 0;
}

/* Error message */
.error-message {
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 4px;
    padding: 1.5rem;
    color: #c33;
    max-width: 900px;
    margin: 2rem auto;
    text-align: center;
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .doc-container {
        height: calc(100vh - 160px);
    }
    
    .sidebar {
        width: 250px;
    }
    
    .doc-content {
        padding: 1.5rem 2rem;
    }
    
    .markdown-body {
        font-size: 0.95rem;
    }
}

@media (max-width: 768px) {
    .doc-container {
        flex-direction: column;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .doc-content {
        padding: 1rem 1.5rem;
    }
    
    .navbar-header {
        padding: 1.5rem 1rem;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .back-button {
        align-self: flex-start;
    }
    
    .navbar-header h1 {
        font-size: 1.4rem;
    }
    
    .markdown-body h1 {
        font-size: 1.5em;
    }
    
    .markdown-body h2 {
        font-size: 1.3em;
    }
    
    .search-box {
        display: none;
    }
    
    .mermaid-toolbar {
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    
    .zoom-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }
    
    .toolbar-separator {
        display: none;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .navbar-header {
        padding: 1rem 0.75rem;
        gap: 0.75rem;
    }
    
    .back-button {
        min-width: 40px;
        height: 40px;
        padding: 0 0.5rem;
        font-size: 0.85rem;
    }
    
    .sidebar {
        max-height: 40vh;
    }
    
    .doc-content {
        padding: 1rem;
    }
    
    .markdown-body {
        font-size: 0.9rem;
    }
    
    .doc-link {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    
    .markdown-body h1 {
        font-size: 1.3em;
    }
    
    .markdown-body h2 {
        font-size: 1.1em;
    }
    
    .mermaid-toolbar {
        flex-wrap: wrap;
        gap: 0.3rem;
    }
    
    .zoom-btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .toolbar-separator {
        display: none;
    }
    
    .mermaid-zoom-container {
        min-height: 150px;
        padding: 0.5rem;
    }
}
