/* 111 Montgomery Offering Plan Viewer
   Brand: Luxury Editorial Real Estate
   Colors: Forest Green #0A322A, Ivory #FDFBF7, Gold #C9A962
*/

@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Source+Sans+3:ital,wght@0,300;0,400;0,600;0,700;1,400&display=swap');

:root {
    --green-deep: #0A322A;
    --green-medium: #0E4137;
    --green-light: #1A5D4A;
    --ivory: #FDFBF7;
    --ivory-warm: #FAF6F0;
    --gold: #C9A962;
    --gold-light: #D4BC7D;
    --text-dark: #1C1C1C;
    --text-muted: #6B6B6B;
    --text-light: #9A9A9A;
    --border-subtle: rgba(10, 50, 42, 0.1);
    --shadow-soft: 0 2px 20px rgba(10, 50, 42, 0.08);
    --shadow-hover: 0 4px 30px rgba(10, 50, 42, 0.12);
}

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

html {
    font-size: 16px;
}

body {
    font-family: 'Source Sans 3', -apple-system, sans-serif;
    display: flex;
    height: 100vh;
    background: var(--ivory);
    color: var(--text-dark);
    line-height: 1.6;
}

/* ============================================
   SIDEBAR - Dark Forest Green
   ============================================ */
.sidebar {
    width: 340px;
    background: var(--green-deep);
    overflow-y: auto;
    padding: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 30px rgba(10, 50, 42, 0.15);
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-track {
    background: var(--green-medium);
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--green-light);
    border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--gold);
}

/* Header area with branding */
.sidebar h1 {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--ivory);
    margin: 0;
    padding: 32px 24px 8px;
    position: relative;
}

.sidebar h1::before {
    content: '';
    position: absolute;
    top: 24px;
    left: 24px;
    right: 24px;
    height: 1px;
    background: linear-gradient(90deg, var(--gold) 0%, transparent 100%);
    opacity: 0.6;
}

.sidebar h2 {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 0;
    padding: 0 24px 24px;
    opacity: 0.9;
}

/* Search */
.search-container {
    padding: 0 16px 20px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: var(--ivory);
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201, 169, 98, 0.15);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}

/* Section groups */
.section-group {
    margin-bottom: 4px;
}

.section-group-title {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--gold);
    padding: 16px 24px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    transition: color 0.2s ease;
    position: relative;
}

.section-group-title:hover {
    color: var(--gold-light);
}

.section-group-title::before {
    content: '';
    width: 5px;
    height: 5px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.3s ease;
    margin-top: -2px;
}

.section-group.collapsed .section-group-title::before {
    transform: rotate(-45deg);
}

.section-group-content {
    display: block;
    padding-bottom: 8px;
}

.section-group.collapsed .section-group-content {
    display: none;
}

/* PDF links */
.pdf-link {
    display: grid;
    grid-template-columns: 1fr 36px 20px;
    align-items: center;
    gap: 8px;
    padding: 11px 24px;
    margin: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.9rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.25s ease;
    border-left: 2px solid transparent;
    position: relative;
}

.pdf-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--ivory);
    border-left-color: var(--gold);
}

.pdf-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--ivory);
    border-left-color: var(--gold);
    font-weight: 500;
}

.pdf-link .pages {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 400;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pdf-link.active .pages,
.pdf-link:hover .pages {
    color: rgba(255, 255, 255, 0.6);
}

/* PDF link name container */
.pdf-link-name {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* PDF-only tag for sections without text extraction */
.pdf-only-tag {
    flex-shrink: 0;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--gold);
    background: rgba(201, 169, 98, 0.15);
    padding: 2px 5px;
    border-radius: 3px;
}

/* Expand toggle button - clickable +/- */
.expand-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.expand-toggle::after {
    content: '+';
    font-size: 1.1rem;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.35);
    transition: all 0.2s ease;
}

.expand-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.expand-toggle:hover::after {
    color: rgba(255, 255, 255, 0.7);
}

.pdf-link.expanded .expand-toggle::after {
    content: '−';
    color: var(--gold);
}

/* Sub-level expand toggle */
.sub-expand-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sub-expand-toggle::after {
    content: '›';
    font-size: 0.9rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.4);
    transition: all 0.2s ease;
}

.sub-expand-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sub-expand-toggle:hover::after {
    color: rgba(255, 255, 255, 0.8);
}

.sub-link.expanded .sub-expand-toggle::after {
    content: '›';
    transform: rotate(90deg);
    color: var(--gold);
}

/* Items without subs need to span the last column */
.pdf-link:not(.has-subs) .pages {
    grid-column: 2 / 4;
}

/* Subsections */
.subsections {
    display: none;
    margin: 0;
    padding: 4px 0 8px 0;
    background: rgba(0, 0, 0, 0.15);
}

.subsections.show {
    display: block;
}

.sub-link {
    display: block;
    padding: 7px 24px 7px 36px;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.sub-link:hover {
    color: var(--ivory);
    background: rgba(255, 255, 255, 0.05);
    border-left-color: rgba(201, 169, 98, 0.5);
}

.sub-link.active {
    color: var(--gold);
    background: rgba(201, 169, 98, 0.08);
    border-left-color: var(--gold);
}

.sub-link .num {
    color: var(--gold);
    font-weight: 600;
    margin-right: 6px;
    opacity: 0.8;
}

.sub-link.active .num {
    opacity: 1;
}

/* Child links (third level) */
.sub-children {
    display: none;
    padding: 4px 0;
    background: rgba(0, 0, 0, 0.1);
}

.sub-children.show {
    display: block;
}

.child-link {
    display: block;
    padding: 5px 24px 5px 48px;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.child-link:hover {
    color: rgba(255, 255, 255, 0.8);
    border-left-color: rgba(201, 169, 98, 0.3);
}

.child-link.active {
    color: var(--gold-light);
    border-left-color: var(--gold);
}

.child-link .num {
    color: var(--gold);
    font-weight: 600;
    margin-right: 4px;
    font-size: 0.7rem;
    opacity: 0.7;
}

.child-link.active .num {
    opacity: 1;
}

/* ============================================
   VIEWER - Light Editorial Style
   ============================================ */
.viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--ivory);
}

.viewer-header {
    padding: 16px 32px;
    background: white;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-soft);
    z-index: 10;
}

.viewer-header #header-text {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
}

.viewer-header .highlight {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 400;
    color: var(--green-deep);
    font-style: italic;
}

/* View toggle */
.view-toggle {
    display: flex;
    gap: 2px;
    background: var(--ivory-warm);
    padding: 3px;
    border-radius: 6px;
}

.toggle-btn {
    padding: 6px 16px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.25s ease;
}

.toggle-btn:hover {
    color: var(--green-deep);
}

.toggle-btn.active {
    background: var(--green-deep);
    color: white;
    box-shadow: 0 2px 8px rgba(10, 50, 42, 0.2);
}

/* Empty state */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 1.125rem;
    font-style: italic;
    padding: 40px;
    text-align: center;
}

.empty-state::before {
    content: '❧';
    font-size: 2.5rem;
    color: var(--green-light);
    opacity: 0.3;
    margin-bottom: 20px;
    font-style: normal;
}

/* PDF iframe */
iframe {
    flex: 1;
    border: none;
    background: white;
}

/* ============================================
   TEXT VIEWER - Magazine Editorial
   ============================================ */
#text-viewer {
    flex: 1;
    padding: 48px 64px 80px;
    background: var(--ivory);
    color: var(--text-dark);
    overflow-y: auto;
    display: none;
    line-height: 1.75;
    max-width: 100%;
}

#text-viewer::-webkit-scrollbar {
    width: 8px;
}

#text-viewer::-webkit-scrollbar-track {
    background: var(--ivory-warm);
}

#text-viewer::-webkit-scrollbar-thumb {
    background: rgba(10, 50, 42, 0.2);
    border-radius: 4px;
}

#text-viewer::-webkit-scrollbar-thumb:hover {
    background: var(--green-deep);
}

#text-viewer h1 {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 2rem;
    font-weight: 400;
    color: var(--green-deep);
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: none;
    position: relative;
    letter-spacing: -0.01em;
    max-width: none;
}

#text-viewer h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--gold-light));
}

#text-viewer .section {
    margin-bottom: 40px;
    scroll-margin-top: 24px;
    max-width: none;
    position: relative;
}

#text-viewer .section h2 {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--green-deep);
    margin-bottom: 16px;
    padding: 12px 0 12px 20px;
    border-left: 3px solid var(--gold);
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(90deg, rgba(201, 169, 98, 0.06) 0%, transparent 50%);
    position: relative;
}

#text-viewer .section h2 .copy-btn {
    cursor: pointer;
    font-size: 0.875rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    order: -1;
    margin-left: -52px;
    opacity: 0;
    background: white;
    box-shadow: var(--shadow-soft);
}

#text-viewer .section:hover h2 .copy-btn {
    opacity: 0.6;
}

#text-viewer .section h2 .copy-btn:hover {
    opacity: 1;
    background: var(--green-deep);
    color: white;
}

#text-viewer .section h2 .copy-btn.copied {
    opacity: 1;
    background: var(--green-light);
    color: white;
}

#text-viewer .section p {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 1rem;
    margin-bottom: 16px;
    text-align: justify;
    color: var(--text-dark);
    line-height: 1.8;
}

#text-viewer .section .ref {
    color: var(--green-medium);
    font-style: italic;
}

#text-viewer .section .ref a {
    color: var(--green-deep);
    text-decoration: none;
    border-bottom: 1px solid var(--gold);
    transition: all 0.2s ease;
}

#text-viewer .section .ref a:hover {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

#text-viewer .subsection {
    margin-top: 28px;
    margin-bottom: 20px;
    scroll-margin-top: 24px;
}

#text-viewer .subsection h3 {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 1rem;
    font-weight: 400;
    font-style: italic;
    color: var(--green-medium);
    margin-bottom: 12px;
    padding-left: 20px;
    border-left: 2px solid rgba(201, 169, 98, 0.4);
}

/* ============================================
   SEARCH RESULTS DROPDOWN
   ============================================ */
.search-results {
    position: absolute;
    top: calc(100% - 8px);
    left: 16px;
    right: 16px;
    background: var(--green-medium);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 0 6px 6px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.search-results.show {
    display: block;
}

.search-result {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-result:hover {
    background: rgba(255, 255, 255, 0.08);
}

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

.search-result-title {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 0.8rem;
    color: var(--gold);
    margin-bottom: 4px;
}

.search-result-section {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.search-result-snippet {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
}

.search-result-snippet mark {
    background: var(--gold);
    color: var(--green-deep);
    padding: 1px 4px;
    border-radius: 2px;
    font-weight: 600;
}

/* ============================================
   HIGHLIGHT ANIMATION
   ============================================ */
@keyframes highlight-pulse {
    0%, 100% {
        background: linear-gradient(90deg, rgba(201, 169, 98, 0.06) 0%, transparent 50%);
    }
    50% {
        background: linear-gradient(90deg, rgba(201, 169, 98, 0.2) 0%, rgba(201, 169, 98, 0.05) 100%);
    }
}

#text-viewer .section.highlight-target > h2 {
    animation: highlight-pulse 0.8s ease-in-out 3;
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

#sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .sidebar {
        width: 300px;
    }

    #text-viewer {
        padding: 40px 40px 60px;
    }
}

/* ============================================
   HEADER ACTIONS & LOGOUT
   ============================================ */
.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logout-btn {
    padding: 6px 14px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: 'Source Sans 3', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: var(--green-deep);
    color: var(--ivory);
    border-color: var(--green-deep);
}

/* ============================================
   DATA TABLES
   ============================================ */
.table-container {
    margin: 1.5rem 0;
    overflow-x: auto;
}

.table-container h4 {
    font-family: 'Libre Baskerville', serif;
    font-size: 1rem;
    color: var(--green-deep);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: white;
    box-shadow: var(--shadow-soft);
    border-radius: 4px;
    overflow: hidden;
}

.data-table thead {
    background: var(--green-deep);
    color: var(--ivory);
}

.data-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table tbody tr:hover {
    background: var(--ivory-warm);
}

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

@media (max-width: 900px) {
    .sidebar {
        width: 260px;
    }

    .sidebar h1 {
        font-size: 1.25rem;
        padding: 24px 16px 8px;
    }

    .sidebar h2 {
        padding: 0 16px 20px;
    }

    .pdf-link {
        padding: 10px 16px;
        font-size: 0.8rem;
    }

    #text-viewer {
        padding: 32px 24px 48px;
    }

    #text-viewer h1 {
        font-size: 1.5rem;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .sidebar {
        display: none;
    }

    .viewer {
        width: 100%;
    }

    .viewer-header {
        display: none;
    }

    #text-viewer {
        padding: 0;
        background: white;
    }
}
