/**
 * Ampla Theme — OJS Override Styles
 *
 * Resolves conflicts between OJS's default pkp_* classes
 * and INSPINIA's Bootstrap 5 layout system.
 * Loaded with STYLE_SEQUENCE_LATE priority (after app.min.css).
 */

/* ═══════ Ampla CSS Custom Properties ═══════ */

:root {
    /* Spacing scale (consistent across all pages) */
    --ampla-gap: 1rem;
    --ampla-gap-sm: 0.5rem;
    --ampla-gap-lg: 1.5rem;
    --ampla-gap-xl: 2rem;

    /* Card styling */
    --ampla-card-radius: var(--bs-border-radius);
    --ampla-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);

    /* Typography */
    --ampla-font-size-sm: 0.8125rem;
    --ampla-font-size-base: 0.875rem;

    /* Accent colors (inherits from Bootstrap, overridable per skin) */
    --ampla-accent: var(--bs-primary);
    --ampla-accent-rgb: var(--bs-primary-rgb);

    /* Semantic surfaces */
    --ampla-surface: var(--bs-body-bg);
    --ampla-surface-alt: var(--bs-tertiary-bg);
    --ampla-text-primary: var(--bs-body-color);
    --ampla-text-secondary: var(--bs-secondary-color);
    --ampla-border: var(--bs-border-color);
}

/* Dark mode adjustments */
[data-bs-theme="dark"] {
    --ampla-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    --ampla-surface-alt: var(--bs-tertiary-bg);
}

/* ═══════ Reset OJS default layout classes ═══════ */

.pkp_structure_page,
.pkp_structure_content,
.pkp_structure_main,
.pkp_structure_sidebar {
    display: block;
    margin: 0;
    padding: 0;
    float: none;
    width: auto;
    max-width: none;
}

.pkp_structure_head,
.pkp_structure_footer {
    display: block;
    margin: 0;
    padding: 0;
}

/* Hide OJS default navigation (replaced by INSPINIA sidenav/topbar) */
.pkp_navigation_primary_wrapper,
.pkp_navigation_user_wrapper,
.pkp_head_wrapper {
    display: none !important;
}

/* ═══════ Content area ═══════ */
/* .content-page layout is handled by INSPINIA _layout.scss */

.content-page > .container-fluid {
    padding-top: 0;
    padding-bottom: var(--ampla-gap-xl);
}

/* ═══════ Page title & breadcrumb ═══════ */
/* .page-title-head is styled by INSPINIA _layout.scss */
/* Ensure it sticks right below topbar with no gap */

/* ═══════ Cards ═══════ */
/* .card, .card-header, .card-body are styled by INSPINIA _card.scss */
/* No overrides needed */

/* ═══════ Article page ═══════ */

.article-details {
    margin-bottom: var(--ampla-gap-lg);
}

.article-details .article-title {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 0.75rem;
    color: var(--ampla-text-primary);
}

.article-details .authors {
    color: var(--ampla-text-secondary);
    margin-bottom: var(--ampla-gap);
}

.article-details .abstract {
    line-height: 1.75;
    color: var(--ampla-text-primary);
}

.article-details .keywords .keyword,
.article-details .badge.bg-light {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    margin: 0.125rem;
    border-radius: var(--ampla-card-radius);
    background-color: var(--ampla-surface-alt);
    color: var(--ampla-text-primary);
    font-size: var(--ampla-font-size-sm);
}

.article-details .orcid-link {
    color: #a6ce39;
    text-decoration: none;
    margin-left: 0.125rem;
}

.article-details .orcid-link:hover {
    color: #8aad2e;
}

/* ═══════ Galley links ═══════ */

.galley-link {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    font-size: var(--ampla-font-size-base);
    font-weight: 500;
    line-height: 1.5;
    color: #fff;
    background-color: var(--ampla-accent);
    border: 1px solid var(--ampla-accent);
    border-radius: var(--ampla-card-radius);
    text-decoration: none;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

.galley-link:hover,
.galley-link:focus {
    color: #fff;
    background-color: color-mix(in srgb, var(--ampla-accent) 85%, black);
    border-color: color-mix(in srgb, var(--ampla-accent) 85%, black);
    text-decoration: none;
}

/* ═══════ Issue TOC ═══════ */

.issue-toc .section,
.issue-toc-section {
    margin-bottom: var(--ampla-gap-lg);
}

.issue-toc .section-title,
.issue-toc-section h5 {
    font-size: 1.125rem;
    font-weight: 600;
    padding-bottom: var(--ampla-gap-sm);
    border-bottom: 1px solid var(--ampla-border);
    margin-bottom: 0.75rem;
    color: var(--ampla-text-primary);
}

/* ═══════ Search results ═══════ */

.search-results .search-result-item {
    padding: var(--ampla-gap) 0;
    border-bottom: 1px solid var(--ampla-border);
}

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

/* ═══════ Article summary in lists ═══════ */

.article-summary {
    padding: var(--ampla-gap);
    margin-bottom: var(--ampla-gap-sm);
    border: 1px solid var(--ampla-border);
    border-radius: var(--ampla-card-radius);
    background-color: var(--ampla-surface);
    transition: box-shadow 0.15s ease-in-out;
}

.article-summary:hover {
    box-shadow: var(--ampla-card-shadow);
}

.article-summary .article-summary-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.article-summary .article-summary-title a {
    color: var(--ampla-text-primary);
    text-decoration: none;
}

.article-summary .article-summary-title a:hover {
    color: var(--ampla-accent);
}

.article-summary .article-summary-authors {
    font-size: var(--ampla-font-size-base);
    color: var(--ampla-text-secondary);
    margin-bottom: 0.25rem;
}

/* ═══════ Pagination ═══════ */

.cmp_pagination {
    display: flex;
    justify-content: center;
    padding: var(--ampla-gap-lg) 0;
}

.cmp_pagination .page-link {
    padding: 0.375rem 0.75rem;
}

/* ═══════ Announcements ═══════ */

.announcement-summary {
    padding: var(--ampla-gap);
    margin-bottom: 0.75rem;
    border-left: 3px solid var(--ampla-accent);
    background-color: var(--ampla-surface-alt);
    border-radius: 0 var(--ampla-card-radius) var(--ampla-card-radius) 0;
}

/* Individual announcement detail page */
.announcement-full .announcement-date {
    color: var(--ampla-text-secondary);
    font-size: var(--ampla-font-size-base);
    margin-bottom: var(--ampla-gap);
}

.announcement-full .announcement-body {
    line-height: 1.7;
}

/* ═══════ Sidebar blocks as cards ═══════ */

.ojs-sidebar-block {
    margin-bottom: var(--ampla-gap);
}

.ojs-sidebar-block .card-header {
    font-weight: 600;
    font-size: var(--ampla-font-size-base);
}

.ojs-sidebar-block .card-body {
    font-size: var(--ampla-font-size-sm);
}

.ojs-sidebar-block ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.ojs-sidebar-block ul li {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--ampla-border);
}

.ojs-sidebar-block ul li:last-child {
    border-bottom: none;
}

.ojs-sidebar-block ul li a {
    text-decoration: none;
    color: var(--ampla-text-primary);
    transition: color 0.15s;
}

.ojs-sidebar-block ul li a:hover {
    color: var(--ampla-accent);
}

/* ═══════ Auth pages (login/register/reset) — INSPINIA card layout ═══════ */

.auth-box {
    min-height: 100vh;
    padding: 1.5rem 0;
    background-color: var(--bs-body-bg);
}

.auth-box .card {
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.08);
    border: none;
}

.auth-box .auth-brand img {
    max-height: 48px;
}

.auth-box .auth-overlay {
    background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.65) 100%);
}

.auth-box .card-side-img {
    background-size: cover;
    background-position: center;
}

.auth-box .input-group-text {
    border-right: 0;
}

.auth-box .input-group .form-control {
    border-left: 0;
}

.auth-box .input-group .form-control:focus {
    box-shadow: none;
    border-color: var(--bs-border-color);
}

.auth-box .input-group:focus-within {
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.15);
    border-radius: var(--bs-border-radius);
}

.auth-box .input-group:focus-within .input-group-text,
.auth-box .input-group:focus-within .form-control {
    border-color: var(--bs-primary);
}

/* Register form — no height constraint, full page display */
.ampla-auth-register {
    max-height: none;
    overflow-y: visible;
}

/* OJS form error styling within auth context */
.auth-box .pkp_form_error {
    margin-bottom: 1rem;
}

/* ALTCHA widget in auth */
.auth-box .altcha_wrapper {
    border: none;
    padding: 0;
    margin: 0;
}

/* ═══════ Error pages ═══════ */

.error-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.error-page h1 {
    font-size: 4rem;
    font-weight: 700;
    color: var(--ampla-accent);
}

/* ═══════ Empty states ═══════ */

.ampla-empty-state {
    text-align: center;
    padding: var(--ampla-gap-xl) var(--ampla-gap);
    color: var(--ampla-text-secondary);
}

.ampla-empty-state i {
    font-size: 2.5rem;
    margin-bottom: var(--ampla-gap);
    display: block;
    opacity: 0.5;
}

/* ═══════ Language selector — INSPINIA style (img flags) ═══════ */
/* Uses <img> with height="18" and class="rounded" — same as INSPINIA original */
/* No custom CSS needed — Bootstrap rounded + height attr handle styling */

/* ═══════ Topbar ═══════ */
/* Topbar layout is handled by INSPINIA _topbar.scss — flat flex children */

/* ═══════ Sidenav divider ═══════ */

.sidenav-divider {
    border-color: rgba(255, 255, 255, 0.1);
    margin: 0.5rem 1rem;
    opacity: 1;
}

[data-menu-color="light"] .sidenav-divider {
    border-color: rgba(0, 0, 0, 0.08);
}

/* ═══════ Sidenav menu — INSPINIA style supplements ═══════ */
/*
 * menu-icon, menu-text, menu-arrow, side-nav-link, side-nav-title,
 * sub-menu, side-nav-item — all styled by INSPINIA app.min.css.
 * Only OJS-specific overrides below.
 */

/* Sidenav logo alignment — controlled by data-logo-align attribute */
.sidenav-menu > a.logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

html[data-logo-align="start"] .sidenav-menu > a.logo {
    justify-content: flex-start;
}

html[data-logo-align="end"] .sidenav-menu > a.logo {
    justify-content: flex-end;
}

/* Hide OJS default pkp_nav_list styling */
.sidenav-menu .pkp_nav_list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Sidenav user name */
.sidenav-menu .sidenav-user-name {
    font-size: 0.9375rem;
}

/* ═══════ Sidenav user avatar ═══════ */

.ampla-avatar {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: block;
}

.ampla-avatar-placeholder {
    width: 64px;
    height: 64px;
    background-color: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
    display: inline-flex;
}

[data-bs-theme="dark"] .ampla-avatar {
    border-color: rgba(255, 255, 255, 0.2);
}

[data-bs-theme="dark"] .ampla-avatar-placeholder {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ═══════ Sidenav user stats accordion ═══════ */

.ampla-stats-toggle {
    text-decoration: none;
    color: inherit;
    padding: 0.25rem 0;
    cursor: pointer;
    transition: opacity 0.15s;
    font-size: 0.875rem;
    overflow: hidden;
}

.ampla-stats-toggle > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.ampla-stats-toggle:hover {
    color: inherit;
    opacity: 0.85;
}

.ampla-stats-toggle .ampla-stats-arrow {
    transition: transform 0.2s;
}

.ampla-stats-toggle[aria-expanded="true"] .ampla-stats-arrow {
    transform: rotate(180deg);
}

.ampla-stats-toggle[aria-expanded="true"] .ampla-stats-badges .badge {
    display: none;
}

.ampla-stats-badges .badge {
    font-size: 0.65rem;
    padding: 0.2em 0.45em;
    font-weight: 600;
    background-color: rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
}

.ampla-stats-badges .badge.text-warning {
    color: #ffc107 !important;
}

/* ═══════ Sidenav user stats ═══════ */

.sidenav-user-stats {
    font-size: var(--ampla-font-size-sm);
}

.sidenav-user-stats .rounded {
    min-height: 46px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.sidenav-user-stats .fs-11 {
    font-size: 0.625rem;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.sidenav-user-stats .fw-bold {
    font-size: 1rem;
    line-height: 1.2;
}

/* ═══════ Footer ═══════ */
/* .footer is styled by INSPINIA _footer.scss (margin-top: auto, border-top, bg) */
/* No overrides needed */

/* ═══════ Print styles ═══════ */

@media print {
    .sidenav-menu,
    .app-topbar,
    .footer,
    .ojs-sidebar-block,
    .page-title-head .breadcrumb,
    .galley-buttons,
    .btn {
        display: none !important;
    }

    .content-page {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
    }

    .card-header {
        background: none !important;
        border-bottom: 1px solid #ccc !important;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    a[href^="#"]::after,
    a[href^="javascript"]::after,
    .article-summary-title a::after {
        content: none;
    }
}

/* ═══════ OJS form elements in Bootstrap context ═══════ */

.pkp_form input[type="text"],
.pkp_form input[type="email"],
.pkp_form input[type="password"],
.pkp_form input[type="url"],
.pkp_form input[type="search"],
.pkp_form textarea,
.pkp_form select {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: var(--ampla-font-size-base);
    line-height: 1.5;
    color: var(--ampla-text-primary);
    background-color: var(--ampla-surface);
    border: 1px solid var(--ampla-border);
    border-radius: var(--ampla-card-radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.pkp_form input:focus,
.pkp_form textarea:focus,
.pkp_form select:focus {
    border-color: var(--ampla-accent);
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(var(--ampla-accent-rgb), 0.25);
}

.pkp_form label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    font-size: var(--ampla-font-size-base);
    color: var(--ampla-text-primary);
}

.pkp_form .pkp_button,
.pkp_form button[type="submit"] {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    font-size: var(--ampla-font-size-base);
    font-weight: 500;
    color: #fff;
    background-color: var(--ampla-accent);
    border: 1px solid var(--ampla-accent);
    border-radius: var(--ampla-card-radius);
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

.pkp_form .pkp_button:hover,
.pkp_form button[type="submit"]:hover {
    background-color: color-mix(in srgb, var(--ampla-accent) 85%, black);
    border-color: color-mix(in srgb, var(--ampla-accent) 85%, black);
}

/* ═══════ Responsive — INSPINIA breakpoint parity ═══════ */

/* Smooth margin transitions for sidebar mode changes */
.content-page {
    transition: margin-inline-start 0.25s ease-in-out;
}

.app-topbar {
    transition: margin-inline-start 0.25s ease-in-out;
}

/* Ultra-small screens (≤375px) — hide topbar logo */
@media (max-width: 375px) {
    .logo-topbar {
        display: none !important;
    }
}

/* Small screens (≤576px) — dropdown width constraint */
@media (max-width: 576px) {
    .app-topbar .dropdown {
        position: static;
    }

    .app-topbar .dropdown .dropdown-menu {
        width: 90%;
        margin-left: 5%;
    }
}

/* Mobile (≤767px) — typography + layout */
@media (max-width: 767.98px) {
    .page-title-head {
        flex-direction: column;
        align-items: flex-start !important;
        gap: var(--ampla-gap-sm);
    }

    .page-title-head .breadcrumb {
        font-size: 0.75rem;
    }

    .article-details .article-title {
        font-size: 1.25rem;
    }

    .error-page h1 {
        font-size: 3rem;
    }

    /* Sidenav overlay backdrop handled by JS (ampla-sidenav-backdrop) */

    /* Auth card adjustments */
    .auth-box {
        min-height: auto;
        padding: 1rem 0;
    }

    .auth-box .card-body {
        padding: 1.5rem !important;
    }

    /* Sidenav stats compact on mobile */
    .sidenav-user-stats .rounded {
        min-height: 40px;
    }
}

/* Tablet (768–1140px) — condensed sidebar adjustments */
@media (min-width: 768px) and (max-width: 1140px) {
    /* Hide user stats in condensed mode (too narrow) */
    html[data-sidenav-size='condensed'] .sidenav-user-stats {
        display: none;
    }

    /* Hide user info text in condensed mode */
    html[data-sidenav-size='condensed'] .ampla-user-info {
        display: none;
    }

    /* Hide dashboard link in condensed mode */
    html[data-sidenav-size='condensed'] .sidenav-user + .sidenav-user-stats + a {
        display: none;
    }
}

/* Scrollable layout mode (≥992px) */
@media (min-width: 992px) {
    html[data-layout-position='scrollable'] .content-page {
        position: relative;
        min-height: max-content;
    }

    html[data-layout-position='scrollable'] .sidenav-menu {
        position: absolute;
    }

    html[data-layout-position='scrollable'] .logo,
    html[data-layout-position='scrollable'] .app-topbar {
        position: static;
    }
}

/* Boxed layout mode (≥1400px) */
@media (min-width: 1400px) {
    html[data-layout-width='boxed'] body {
        background-color: var(--bs-tertiary-bg);
    }

    html[data-layout-width='boxed'] .wrapper {
        margin: 0 auto;
        max-width: 1340px;
        box-shadow: var(--bs-box-shadow);
    }
}

/* 사이트 홈 아이콘 — topbar */
.ampla-home-icon {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    object-fit: cover;
    background: #fff;
    padding: 1px;
}

/* ═══════ 저널 인덱스 — 히어로 배너 ═══════ */
.ampla-journal-hero {
    position: relative;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ampla-journal-hero-gradient {
    background: linear-gradient(135deg, var(--bs-primary), #1e2a3a);
}
.ampla-journal-hero-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}
.ampla-journal-hero-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
}
.ampla-journal-hero-content {
    z-index: 1;
}
@media (max-width: 767.98px) {
    .ampla-journal-hero { min-height: 160px; }
    .ampla-journal-hero-content h1 { font-size: 1.5rem !important; }
}

/* ═══════ 저널 인덱스 — Highlights 캐러셀 ═══════ */
.ampla-highlight-card {
    background: var(--bs-tertiary-bg);
}
.ampla-highlight-card .card-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
}
#ampla-highlights-carousel .carousel-control-prev,
#ampla-highlights-carousel .carousel-control-next {
    width: 5%;
    opacity: 0.6;
}
#ampla-highlights-carousel .carousel-control-prev:hover,
#ampla-highlights-carousel .carousel-control-next:hover {
    opacity: 1;
}

/* ═══════ 논문 요약 — 초록/키워드 강화 ═══════ */
.article-summary-abstract {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}
.article-summary-keywords .badge {
    font-weight: 500;
    font-size: 0.7rem;
}
.article-summary {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bs-border-color);
}
.article-summary:last-child {
    border-bottom: 0;
}
.article-summary-title a {
    text-decoration: none;
    color: var(--bs-heading-color);
}
.article-summary-title a:hover {
    color: var(--bs-primary);
}
