/* ============================================================
   JLIVE — Article Viewer Styles
   MDPI-inspired academic article layout
   ============================================================ */

/* ── Breadcrumb ── */
.article-breadcrumb {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    padding: 14px 0;
    margin-top: var(--nav-height);
}

.article-breadcrumb .container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-500);
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

.article-breadcrumb a {
    color: var(--teal);
    text-decoration: none;
    transition: color 0.2s;
}

.article-breadcrumb a:hover {
    color: var(--teal-hover);
    text-decoration: underline;
}

.article-breadcrumb span {
    color: var(--gray-700);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 400px;
}

.article-breadcrumb svg {
    opacity: 0.4;
    flex-shrink: 0;
}

/* ── Article Header ── */
.article-header-section {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 40px 0 32px;
}

.article-header-section .container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* Badges */
.article-badges {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-oa {
    background: #e6f7f0;
    color: #0d7c4e;
    border: 1px solid #b7e8d2;
}

.badge-type {
    background: #fff3e0;
    color: #c66900;
    border: 1px solid #ffe0b2;
}

/* Title */
.article-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.35;
    margin-bottom: 20px;
    letter-spacing: -0.01em;
}

/* Authors */
.article-authors {
    margin-bottom: 16px;
    line-height: 1.8;
    font-size: 15px;
    color: var(--gray-700);
}

.author-name {
    font-weight: 500;
    color: var(--navy);
    white-space: nowrap;
}

.author-sup {
    font-size: 10px;
    vertical-align: super;
    color: var(--teal);
    margin-left: 1px;
    font-weight: 600;
}

.author-icon {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: 2px;
    cursor: pointer;
    opacity: 0.65;
    transition: opacity 0.2s;
}

.author-icon:hover {
    opacity: 1;
}

.author-icon svg {
    width: 14px;
    height: 14px;
}

.author-icon.orcid-icon svg {
    fill: #A6CE39;
}

.author-icon.mail-icon svg {
    stroke: var(--teal);
}

.author-separator {
    color: var(--gray-400);
    margin: 0 2px;
}

/* Affiliations */
.article-affiliations {
    margin-bottom: 12px;
    padding-left: 0;
}

.affiliation-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
    margin-bottom: 4px;
}

.affiliation-num {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    color: var(--teal);
    min-width: 14px;
}

/* Correspondence */
.article-correspondence {
    font-size: 12.5px;
    color: var(--gray-500);
    margin-bottom: 20px;
    font-style: italic;
}

/* Citation */
.article-citation {
    font-size: 14px;
    color: var(--gray-700);
    margin-bottom: 14px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-left: 3px solid var(--teal);
    border-radius: 0 6px 6px 0;
    line-height: 1.6;
}

.article-citation .journal-name {
    font-style: italic;
    font-weight: 600;
    color: var(--navy);
}

.article-citation .doi-link {
    color: var(--teal);
    text-decoration: none;
    word-break: break-all;
}

.article-citation .doi-link:hover {
    text-decoration: underline;
}

/* Dates */
.article-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--gray-600);
    padding: 10px 16px;
    background: #f0fafb;
    border-radius: 6px;
    border: 1px solid #d8f0f2;
}

.date-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.date-label {
    font-weight: 600;
    color: var(--navy);
}

.date-separator {
    color: var(--gray-300);
    margin: 0 4px;
}

/* Special Issue */
.article-special-issue {
    font-size: 13px;
    color: var(--teal);
    margin-bottom: 20px;
}

.article-special-issue a {
    color: var(--teal);
    text-decoration: underline;
}

/* Action Buttons */
.article-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.action-btn-group {
    position: relative;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.action-btn-primary {
    background: var(--navy);
    color: var(--white);
}

.action-btn-primary:hover {
    background: var(--navy-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(10, 31, 68, 0.25);
}

.action-btn-secondary {
    background: var(--white);
    color: var(--navy);
    border: 1.5px solid var(--gray-300);
}

.action-btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--teal);
    color: var(--teal);
    transform: translateY(-1px);
}

.chevron-icon {
    transition: transform 0.2s;
}

.action-btn-group.open .chevron-icon {
    transform: rotate(180deg);
}

/* Download Dropdown */
.download-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 200px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
    z-index: 100;
    overflow: hidden;
    animation: dropdownFade 0.2s ease;
}

.action-btn-group.open .download-dropdown {
    display: block;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.download-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--gray-700);
    text-decoration: none;
    transition: background 0.15s;
}

.download-option:hover {
    background: var(--gray-50);
    color: var(--teal);
}

.download-option + .download-option {
    border-top: 1px solid var(--gray-100);
}

/* ── Article Content Layout ── */
.article-content-section {
    padding: 40px 0 80px;
    background: var(--white);
}

.article-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 48px;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    align-items: start;
}

/* ── Sidebar / ToC ── */
.article-sidebar {
    position: sticky;
    top: calc(var(--nav-height) + 24px);
    max-height: calc(100vh - var(--nav-height) - 48px);
    overflow-y: auto;
    order: 2;
}

.toc-container {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 20px;
}

.toc-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--gray-200);
}

.toc-title svg {
    opacity: 0.5;
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toc-link {
    display: block;
    padding: 7px 12px;
    font-size: 13px;
    color: var(--gray-600);
    text-decoration: none;
    border-radius: 6px;
    border-left: 2px solid transparent;
    transition: all 0.2s;
    line-height: 1.4;
}

.toc-link:hover {
    background: var(--white);
    color: var(--teal);
    border-left-color: var(--gray-300);
}

.toc-link.active {
    background: rgba(0, 140, 140, 0.06);
    color: var(--teal);
    font-weight: 600;
    border-left-color: var(--teal);
}

/* ── Article Body ── */
.article-body {
    order: 1;
    min-width: 0;
}

.article-section {
    margin-bottom: 36px;
    scroll-margin-top: calc(var(--nav-height) + 24px);
}

.section-heading {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gray-100);
}

.abstract-content {
    font-size: 15px;
    line-height: 1.75;
    color: var(--gray-700);
    text-align: justify;
}

/* Keywords */
.article-keywords {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 36px;
    padding: 16px 20px;
    background: var(--gray-50);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
}

.keywords-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-right: 4px;
}

.keyword-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12.5px;
    color: var(--teal);
    background: rgba(0, 140, 140, 0.07);
    border: 1px solid rgba(0, 140, 140, 0.15);
    transition: all 0.2s;
}

.keyword-pill:hover {
    background: rgba(0, 140, 140, 0.12);
    border-color: rgba(0, 140, 140, 0.3);
}

/* Section Content */
.section-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--gray-700);
}

.section-content p {
    margin-bottom: 14px;
    text-align: justify;
}

.section-content h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--navy);
    margin-top: 24px;
    margin-bottom: 12px;
}

.section-content ul,
.section-content ol {
    margin: 12px 0 16px 24px;
}

.section-content li {
    margin-bottom: 6px;
    line-height: 1.7;
}

.section-content strong {
    color: var(--navy);
}

.section-content em {
    font-style: italic;
}

.section-content sup {
    font-size: 0.75em;
    vertical-align: super;
}

/* ── Figures ── */
.article-figure {
    margin: 28px 0;
    padding: 20px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    text-align: center;
    scroll-margin-top: calc(var(--nav-height) + 24px);
}

.figure-placeholder {
    width: 100%;
    min-height: 200px;
    background: linear-gradient(135deg, #e8f4f8, #d4eef4, #e0f0ea);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 40px;
    color: var(--gray-500);
    position: relative;
    overflow: hidden;
}

.figure-placeholder::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 20px,
        rgba(0, 140, 140, 0.03) 20px,
        rgba(0, 140, 140, 0.03) 40px
    );
}

.figure-placeholder:hover {
    transform: scale(1.01);
}

.figure-placeholder svg {
    opacity: 0.3;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.figure-placeholder span {
    font-size: 13px;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.figure-caption {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--gray-600);
    text-align: left;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

.figure-caption strong {
    color: var(--navy);
}

/* ── Tables ── */
.article-table-wrapper {
    margin: 28px 0;
    scroll-margin-top: calc(var(--nav-height) + 24px);
}

.table-caption {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--gray-600);
    margin-bottom: 12px;
}

.table-caption strong {
    color: var(--navy);
}

.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
}

.table-scroll table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    line-height: 1.5;
}

.table-scroll thead {
    background: var(--navy);
    color: var(--white);
}

.table-scroll th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    font-size: 12.5px;
    letter-spacing: 0.2px;
}

.table-scroll td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.table-scroll tbody tr:hover {
    background: var(--gray-50);
}

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

.table-scroll em {
    font-style: italic;
}

/* ── References ── */
.references-list {
    padding-left: 28px;
    font-size: 13.5px;
    line-height: 1.7;
    color: var(--gray-600);
}

.references-list li {
    margin-bottom: 10px;
    padding-left: 4px;
}

.references-list li::marker {
    color: var(--teal);
    font-weight: 600;
}

.references-list em {
    font-style: italic;
}

.references-list strong {
    font-weight: 600;
    color: var(--gray-700);
}

/* ── 404 State ── */
.article-not-found {
    text-align: center;
    padding: 120px 24px;
    margin-top: var(--nav-height);
}

.article-not-found svg {
    margin: 0 auto 20px;
    display: block;
    color: var(--gray-400);
}

.article-not-found h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--navy);
    margin-bottom: 8px;
}

.article-not-found p {
    color: var(--gray-500);
    font-size: 15px;
    margin-bottom: 24px;
}

.btn-back-archives {
    display: inline-flex;
    align-items: center;
    padding: 12px 24px;
    background: var(--teal);
    color: var(--white);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-back-archives:hover {
    background: var(--teal-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 140, 140, 0.25);
}

/* ── Back to Top ── */
.back-to-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--navy);
    color: var(--white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(10, 31, 68, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: all 0.3s ease;
    z-index: 999;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--teal);
    transform: translateY(-2px);
}

/* ── Cite Toast ── */
.cite-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--navy);
    color: var(--white);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 28px rgba(10, 31, 68, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9999;
}

.cite-toast.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ── Figure Lightbox ── */
.figure-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.figure-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.lightbox-close:hover {
    opacity: 1;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 85vh;
    text-align: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 75vh;
    border-radius: 8px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
}

.lightbox-caption {
    color: #ccc;
    font-size: 14px;
    margin-top: 16px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

/* ── Mobile ToC Toggle ── */
.toc-mobile-toggle {
    display: none;
    position: fixed;
    bottom: 32px;
    left: 32px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--teal);
    color: var(--white);
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 140, 140, 0.3);
    z-index: 999;
    transition: all 0.2s;
}

.toc-mobile-toggle:hover {
    transform: translateY(-2px);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .article-layout {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .article-sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        max-height: 100vh;
        padding: 0;
        order: unset;
    }

    .article-sidebar.mobile-open {
        display: flex;
        align-items: flex-end;
        justify-content: center;
    }

    .article-sidebar.mobile-open .toc-container {
        width: 100%;
        max-width: 100%;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        padding: 24px;
        overflow-y: auto;
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .toc-mobile-toggle {
        display: flex;
    }

    .article-body {
        order: unset;
    }

    .article-title {
        font-size: 1.4rem;
    }

    .article-dates {
        flex-direction: column;
        gap: 4px;
    }

    .date-separator {
        display: none;
    }

    .article-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .action-btn {
        justify-content: center;
    }
}

@media (max-width: 640px) {
    .article-header-section {
        padding: 24px 0 20px;
    }

    .article-title {
        font-size: 1.2rem;
    }

    .section-heading {
        font-size: 1.15rem;
    }

    .article-content-section {
        padding: 24px 0 60px;
    }

    .article-layout {
        padding: 0 16px;
    }

    .article-breadcrumb .container {
        padding: 0 16px;
    }

    .article-header-section .container {
        padding: 0 16px;
    }

    .table-scroll {
        font-size: 12px;
    }

    .table-scroll th,
    .table-scroll td {
        padding: 7px 10px;
    }
}

/* ── Print Styles ── */
@media print {
    .navbar,
    .mobile-menu,
    .article-sidebar,
    .article-actions,
    .back-to-top,
    .toc-mobile-toggle,
    .footer {
        display: none !important;
    }

    .article-breadcrumb {
        border-bottom: 1px solid #ccc;
    }

    .article-layout {
        grid-template-columns: 1fr;
    }

    .article-body {
        font-size: 12pt;
    }

    .section-content {
        font-size: 11pt;
    }
}
