/* ============================================
   JAUMEMORY REFERENCE PAGE STYLES
   Tutorial-style documentation with accordions
   ============================================ */

/* Fix layout to prevent sidebar from being pushed off */
.docs-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: var(--space-8);
    max-width: var(--max-width-7xl);
    margin: 0 auto;
    padding: var(--space-8) var(--space-4);
    position: relative;
}

/* Ensure sidebar stays visible */
.docs-sidebar {
    position: sticky;
    top: calc(var(--navbar-height, 80px) + var(--space-4));
    height: fit-content;
    max-height: calc(100vh - var(--navbar-height, 80px) - var(--space-8));
    overflow-y: auto;
    flex-shrink: 0;
    min-width: 260px;
}

/* Fix content overflow - critical */
.docs-content {
    max-width: 100%;
    min-width: 0; /* Allow flex/grid items to shrink below content size */
    overflow-x: hidden;
}

/* Tool Section - Accordion Container */
.tool-section {
    margin-bottom: var(--space-6);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* Tool Header - Always Visible, Clickable */
.tool-section > h3 {
    margin: 0;
    padding: var(--space-4);
    cursor: pointer;
    user-select: none;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--duration-fast);
}

.tool-section > h3:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Accordion indicator */
.tool-section > h3::after {
    content: '▼';
    font-size: 0.8em;
    opacity: 0.6;
    transition: transform var(--duration-normal);
}

.tool-section.collapsed > h3::after {
    transform: rotate(-90deg);
}

/* Tool tagline */
.tool-tagline {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    font-weight: normal;
    padding: var(--space-2) var(--space-4);
    margin: 0;
    border-bottom: 1px solid var(--glass-border);
}

/* Accordion content wrapper */
.tool-content {
    max-height: 10000px; /* Large enough for any content */
    overflow: hidden;
    transition: max-height var(--duration-slow) ease-in-out;
}

.tool-section.collapsed .tool-content {
    max-height: 0;
}

/* Section blocks within tools */
.section-block {
    padding: var(--space-4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    overflow-x: auto; /* Allow horizontal scroll if absolutely needed */
}

.section-block:last-child {
    border-bottom: none;
}

.section-block h4 {
    margin-top: 0;
    margin-bottom: var(--space-3);
    font-size: var(--font-size-lg);
    color: var(--color-primary);
}

/* Problem/Solution Cards */
.problem-solution {
    display: grid;
    gap: var(--space-4);
    margin-top: var(--space-3);
}

.problem, .solution {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
}

.problem strong, .solution strong {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--color-primary);
}

/* Checklists */
.checklist {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.checklist label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast);
}

.checklist label:hover {
    background: rgba(255, 255, 255, 0.03);
}

.checklist input[type="checkbox"] {
    cursor: pointer;
}

/* How it works list */
.how-it-works {
    list-style: none;
    counter-reset: step-counter;
    padding-left: 0;
    margin-top: var(--space-3);
}

.how-it-works li {
    counter-increment: step-counter;
    position: relative;
    padding-left: var(--space-8);
    margin-bottom: var(--space-3);
}

.how-it-works li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 2rem;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: var(--font-size-sm);
}

/* Code blocks - CRITICAL FIX FOR OVERFLOW */
.section-block pre {
    margin: var(--space-3) 0;
    border-radius: var(--radius-md);
    overflow-x: auto; /* Allow scrolling within code blocks */
    max-width: 100%;
    background: rgba(0, 0, 0, 0.3);
    padding: var(--space-3);
}

.section-block pre code {
    display: block;
    white-space: pre; /* Preserve formatting */
    word-wrap: normal;
    overflow-wrap: normal;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.5;
}

/* Example blocks */
.example-block {
    margin-bottom: var(--space-4);
    border-left: 3px solid var(--color-primary);
    padding-left: var(--space-4);
}

.example-block.beginner {
    border-left-color: #4ade80;
}

.example-block.intermediate {
    border-left-color: #60a5fa;
}

.example-block.power-user {
    border-left-color: #a78bfa;
}

.example-block.real-world {
    border-left-color: #f59e0b;
}

.example-block h5 {
    margin-top: 0;
    margin-bottom: var(--space-2);
    font-size: var(--font-size-base);
}

/* Value list */
.value-list {
    list-style: none;
    padding-left: 0;
    margin-top: var(--space-3);
}

.value-list li {
    padding: var(--space-2) 0;
    padding-left: var(--space-6);
    position: relative;
}

.value-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--color-success);
    font-weight: bold;
    font-size: 1.2em;
}

/* Next tools grid */
.next-tools {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.next-tool {
    padding: var(--space-3);
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.next-tool strong {
    display: block;
    margin-bottom: var(--space-1);
    color: var(--color-primary);
}

.next-tool p {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* Pro tips */
.pro-tips {
    list-style: none;
    padding-left: 0;
    margin-top: var(--space-3);
}

.pro-tips li {
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-2);
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius-sm);
}

.pro-tips li strong {
    color: var(--color-primary);
}

/* Common mistakes table */
.mistakes-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-3);
    font-size: var(--font-size-sm);
    display: block;
    overflow-x: auto; /* Allow table to scroll horizontally if needed */
    max-width: 100%;
}

.mistakes-table thead {
    background: rgba(255, 255, 255, 0.05);
}

.mistakes-table th {
    padding: var(--space-2) var(--space-3);
    text-align: left;
    font-weight: var(--font-semibold);
    border-bottom: 2px solid var(--glass-border);
    white-space: nowrap; /* Prevent header wrapping */
}

.mistakes-table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: top;
}

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

/* Smooth scroll with offset for sticky navbar */
html {
    scroll-padding-top: calc(var(--navbar-height, 80px) + var(--space-4));
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .docs-layout {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .docs-sidebar {
        position: static;
        max-height: none;
        margin-bottom: var(--space-4);
    }

    .mistakes-table {
        font-size: var(--font-size-xs);
    }

    .mistakes-table th,
    .mistakes-table td {
        padding: var(--space-1) var(--space-2);
    }

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

/* API Table - prevent overflow */
.api-table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: var(--space-4) 0;
    display: block;
    overflow-x: auto;
}

.api-table thead {
    background: rgba(255, 255, 255, 0.05);
}

.api-table th,
.api-table td {
    padding: var(--space-3);
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.api-table code {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.2em 0.4em;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
}
