/* ============================================= */
/* Etnias ET Document Reader - Overlay Panel     */
/* ============================================= */

#etnias-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 5000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-family: 'DM Sans', Verdana, Arial, sans-serif;
}

#etnias-overlay.active {
    display: flex;
    opacity: 1;
}

/* Backdrop */
#etnias-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
}

/* Reader Container */
#etnias-reader {
    position: relative;
    display: flex;
    width: 100%;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* ============================================= */
/* Sidebar Navigation                            */
/* ============================================= */
#etnias-sidebar {
    width: 280px;
    min-width: 280px;
    height: 100%;
    background: rgba(15, 15, 20, 0.97);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#etnias-sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

#etnias-sidebar-header h2 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: #e0e0e0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

#etnias-sidebar-header .subtitle {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    margin: 0;
    letter-spacing: 0.3px;
}

#etnias-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

#etnias-nav::-webkit-scrollbar {
    width: 4px;
}
#etnias-nav::-webkit-scrollbar-track {
    background: transparent;
}
#etnias-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.etnias-nav-item {
    display: flex;
    align-items: flex-start;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
    gap: 10px;
}

.etnias-nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.etnias-nav-item.active {
    background: rgba(97, 51, 255, 0.1);
    border-left-color: #6133ff;
}

.etnias-nav-item .nav-num {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    min-width: 20px;
    padding-top: 2px;
    flex-shrink: 0;
}

.etnias-nav-item.active .nav-num {
    color: #6133ff;
}

.etnias-nav-item .nav-title {
    font-size: 12px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.6);
    transition: color 0.2s;
}

.etnias-nav-item.active .nav-title,
.etnias-nav-item:hover .nav-title {
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================= */
/* Main Content Area                             */
/* ============================================= */
#etnias-content {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}

#etnias-content::-webkit-scrollbar {
    width: 5px;
}
#etnias-content::-webkit-scrollbar-track {
    background: transparent;
}
#etnias-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 3px;
}

/* Close Button */
#etnias-close {
    position: fixed;
    top: 16px;
    right: 24px;
    z-index: 5001;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(20, 20, 25, 0.9);
    color: rgba(255, 255, 255, 0.6);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    line-height: 1;
}

#etnias-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

/* ============================================= */
/* Section Content Styles                        */
/* ============================================= */
.etnias-section {
    max-width: 780px;
    margin: 0 auto;
    padding: 48px 40px 80px;
}

.etnias-section h1 {
    font-size: 24px;
    font-weight: 600;
    color: #e8e8f0;
    margin: 0 0 8px 0;
    letter-spacing: 0.3px;
    line-height: 1.3;
}

.etnias-section .section-number {
    font-size: 12px;
    color: #6133ff;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 6px;
    display: block;
}

.etnias-section .section-divider {
    width: 40px;
    height: 2px;
    background: #6133ff;
    margin: 20px 0 28px;
    border-radius: 1px;
}

.etnias-section p {
    font-size: 16.5px;
    line-height: 1.9;
    color: rgba(255, 255, 255, 0.72);
    margin: 0 0 16px 0;
    font-weight: 400;
}

.etnias-section p strong {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.etnias-section p em {
    color: rgba(255, 255, 255, 0.55);
    font-style: italic;
}

/* ============================================= */
/* Blockquote citations                          */
/* ============================================= */
.etnias-quote {
    margin: 24px 0;
    padding: 18px 22px 18px 26px;
    border-left: 3px solid rgba(139, 122, 255, 0.55);
    border-radius: 0 8px 8px 0;
    background: rgba(139, 122, 255, 0.06);
    color: rgba(255, 255, 255, 0.65);
}

.etnias-quote p {
    font-size: 15.5px;
    line-height: 1.85;
    color: rgba(255, 255, 255, 0.65);
    margin: 0 0 10px 0;
    font-style: italic;
}

.etnias-quote p:last-child {
    margin-bottom: 0;
}

.etnias-quote .quote-source {
    display: block;
    margin-bottom: 8px;
    font-style: normal;
}

.etnias-quote .quote-source .ref-link {
    font-size: 11px;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

/* ============================================= */
/* Math & Equations                               */
/* ============================================= */
.etnias-eq {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;
    font-size: 13px;
    color: rgba(200, 180, 255, 0.9);
    background: rgba(139, 122, 255, 0.08);
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.etnias-result {
    display: block;
    margin: 16px 0;
    padding: 10px 16px;
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(139, 122, 255, 0.1);
    border-left: 3px solid rgba(139, 122, 255, 0.5);
    border-radius: 0 4px 4px 0;
}

.etnias-model-title {
    display: block;
    margin: 16px 0 4px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(200, 180, 255, 0.85);
    letter-spacing: 0.5px;
}

.etnias-math-block {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    padding: 20px;
    background: rgba(139, 122, 255, 0.06);
    border: 1px solid rgba(139, 122, 255, 0.15);
    border-radius: 8px;
}

.etnias-math-model {
    flex: 1;
    min-width: 0;
}

.etnias-math-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(200, 180, 255, 0.9);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(139, 122, 255, 0.2);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.etnias-math-eq {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    padding: 6px 0;
    letter-spacing: 0.3px;
}

/* ============================================= */
/* Data Table                                     */
/* ============================================= */
.etnias-table-wrapper {
    margin: 20px 0;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(139, 122, 255, 0.15);
}

.etnias-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
}

.etnias-table thead tr:first-child th {
    padding: 10px 12px;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-align: center;
    border-bottom: 1px solid rgba(139, 122, 255, 0.2);
}

.table-woam-header {
    background: rgba(139, 92, 246, 0.15);
    color: rgba(200, 180, 255, 0.95);
}

.table-imoo-header {
    background: rgba(99, 179, 237, 0.12);
    color: rgba(180, 210, 255, 0.95);
}

.etnias-table thead tr:nth-child(2) th {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.etnias-table tbody td {
    padding: 7px 12px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.75);
}

.etnias-table tbody tr:hover {
    background: rgba(139, 122, 255, 0.06);
}

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

/* Highlight the n=9 row (reference sphere) */
.etnias-table tbody tr:nth-child(10) td {
    background: rgba(139, 122, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
    font-weight: 500;
}

/* ============================================= */
/* Images — native size, click to expand         */
/* ============================================= */
.etnias-section {
    text-align: left;
}

.etnias-image-container {
    margin: 24px auto;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    position: relative;
    display: block;
    width: fit-content;
    max-width: 100%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.etnias-image-container:hover {
    border-color: rgba(139, 122, 255, 0.3);
    box-shadow: 0 4px 24px rgba(139, 122, 255, 0.1);
}

.etnias-image-container img {
    display: block;
    max-width: 320px;
    max-height: 320px;
    width: auto;
    height: auto;
}

.etnias-image-container .img-expand-hint {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.5);
    font-size: 16px;
    line-height: 24px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

.etnias-image-container:hover .img-expand-hint {
    opacity: 1;
}

/* ─── Image gallery ─── */
.etnias-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin: 32px 0 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.etnias-gallery .etnias-image-container {
    margin: 0;
    width: 100%;
}

.etnias-gallery .etnias-image-container img {
    max-width: 100%;
    max-height: 240px;
}

/* Two-image row */
.etnias-images-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 24px 0;
}

/* ============================================= */
/* Lightbox                                      */
/* ============================================= */
#etnias-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 6000;
    display: none;
    align-items: center;
    justify-content: center;
}

#etnias-lightbox.active {
    display: flex;
}

#lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    cursor: pointer;
}

#lightbox-img {
    position: relative;
    z-index: 1;
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

#lightbox-close {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 6001;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(20, 20, 25, 0.9);
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    line-height: 1;
}

#lightbox-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ============================================= */
/* Reference links                               */
/* ============================================= */
.ref-link {
    color: #8b7aff;
    text-decoration: none;
    font-weight: 500;
    font-family: 'DM Mono', 'SF Mono', 'Consolas', monospace;
    font-size: 0.88em;
    border-bottom: 1px solid rgba(139, 122, 255, 0.25);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ref-link:hover {
    color: #b3a4ff;
    border-bottom-color: rgba(139, 122, 255, 0.6);
    text-shadow: 0 0 8px rgba(139, 122, 255, 0.3);
}

.ref-link::before {
    content: '\25B9';
    margin-right: 2px;
    font-size: 0.7em;
    opacity: 0.5;
}

/* ============================================= */
/* Table styles                                  */
/* ============================================= */
.etnias-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 13px;
}

.etnias-table th,
.etnias-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.65);
}

.etnias-table th {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255, 255, 255, 0.02);
}

.etnias-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Loading state */
.etnias-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: rgba(255, 255, 255, 0.3);
    font-size: 14px;
}

/* ============================================= */
/* Responsive                                    */
/* ============================================= */
@media (max-width: 900px) {
    #etnias-sidebar {
        width: 220px;
        min-width: 220px;
    }
    .etnias-section {
        padding: 32px 24px 60px;
    }
    .etnias-section h1 {
        font-size: 20px;
    }
    .etnias-image-container img {
        max-width: 260px;
        max-height: 260px;
    }
}

@media (max-width: 640px) {
    #etnias-sidebar {
        position: absolute;
        width: 100%;
        height: auto;
        max-height: 40vh;
        bottom: 0;
        top: auto;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        z-index: 2;
    }

    #etnias-reader {
        flex-direction: column-reverse;
    }

    #etnias-sidebar:not(.collapsed) {
        max-height: 40vh;
    }
    #etnias-sidebar.collapsed {
        max-height: 48px;
        overflow: hidden;
    }

    .etnias-section {
        padding: 24px 18px 50vh;
    }

    .etnias-images-row {
        grid-template-columns: 1fr;
    }

    .etnias-image-container img {
        max-width: 200px;
        max-height: 200px;
    }

    #etnias-close {
        top: 10px;
        right: 12px;
    }
}
