/* Base Reset & Fonts */
:root {
    --primary-ifs: #005BBB;
    --primary-ifs-hover: #004a99;
    --primary-ifs-light: #E6F0FA;

    --primary-brc: #E84C22;
    --primary-brc-hover: #cc3d18;
    --primary-brc-light: #FDECE9;

    --text-main: #1E293B;
    --text-secondary: #64748B;
    --bg-app: #F8FAFC;
    --bg-surface: #FFFFFF;

    --border-color: #E2E8F0;
    --radius-sm: 6px;
    --radius-md: 10px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-app);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 20;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
}

.logo-ifs {
    background: linear-gradient(135deg, #005BBB, #003d82);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 91, 187, 0.3);
}

.logo-brc {
    background: linear-gradient(135deg, #E84C22, #c43d1a);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(232, 76, 34, 0.3);
}

.arrow {
    color: white;
    font-size: 1.5rem;
}

.header-text h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

.header-text p {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    margin: 0.25rem 0 0 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* .lang-toggle replaced by .header-btn.lang-btn */

.search-input {
    width: 280px;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.95);
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* ─── Header buttons (Guide + Lang) ─────────────────────────────────────── */
.header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: white;
    transition: all 0.2s;
    white-space: nowrap;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.header-btn.active-mode {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.7);
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 4px;
}

.lang-sep {
    opacity: 0.4;
}

.lang-en {
    opacity: 0.4;
}

/* ─── Guide dropdown ─────────────────────────────────────────────────────── */
.guide-wrapper {
    position: relative;
}

.guide-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 1rem;
    z-index: 100;
    min-width: 320px;
}

.guide-panel.open {
    display: block;
}

.guide-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.guide-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.guide-item:hover {
    background: var(--bg-app);
}

.guide-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.guide-text {
    display: flex;
    flex-direction: column;
    font-size: 0.82rem;
    color: var(--text-main);
}

.guide-text strong {
    font-size: 0.87rem;
    color: var(--text-main);
    margin-bottom: 1px;
}

.header-content h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-bar input {
    width: 350px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-ifs);
    box-shadow: 0 0 0 3px rgba(0, 91, 187, 0.1);
}

/* Main Layout */
.main-container {
    flex: 1;
    display: flex;
    gap: 0;
    /* Removing gap, using borders instead */
    overflow: hidden;
}

.column {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background-color: var(--bg-app);
}

.column:last-child {
    border-right: none;
}

.column-header {
    padding: 1rem;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.column-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Navigation buttons */
.nav-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.nav-btn:hover {
    background-color: var(--primary-ifs-light);
    border-color: var(--primary-ifs);
    color: var(--primary-ifs);
}

.brc-column .nav-btn:hover {
    background-color: var(--primary-brc-light);
    border-color: var(--primary-brc);
    color: var(--primary-brc);
}

.scrollable-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: 3rem;
}

/* --- ACCORDION DESIGN --- */

/* L1: Chapter / Section - The heavy lifters */
details.acc-l1 {
    margin-bottom: 0.75rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

details.acc-l1 > summary {
    padding: 0.75rem 1rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: white;
}

/* IFS Branding for L1 */
.ifs-column details.acc-l1>summary {
    background-color: white;
    color: var(--primary-ifs);
    border-left: 4px solid var(--primary-ifs);
}

.ifs-column details.acc-l1>summary:hover {
    background-color: var(--primary-ifs-light);
}

/* BRC Branding for L1 */
.brc-column details.acc-l1>summary {
    background-color: white;
    color: var(--primary-brc);
    border-left: 4px solid var(--primary-brc);
}

.brc-column details.acc-l1>summary:hover {
    background-color: var(--primary-brc-light);
}

/* L1 Arrow */
details.acc-l1>summary::after {
    content: '+';
    font-weight: 400;
    font-size: 1.2rem;
    color: #94A3B8;
}

details.acc-l1[open]>summary::after {
    content: '−';
}

/* L1 Content Area */
.acc-content-l1 {
    padding: 0.5rem;
    background-color: #F8FAFC;
    border-top: 1px solid var(--border-color);
}

/* L2: Nested Sections */
details.acc-l2 {
    margin-bottom: 0.5rem;
    background-color: transparent;
}

details.acc-l2>summary {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    list-style: none;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

details.acc-l2>summary:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* L2 Arrow (Leading) */
details.acc-l2>summary::before {
    content: '▶';
    font-size: 0.6rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

details.acc-l2[open]>summary::before {
    transform: rotate(90deg);
}

.acc-content-l2 {
    padding-left: 0.75rem;
    /* Indent items */
    padding-top: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}


/* --- REQUIREMENT ITEMS --- */
/* More compact, cleaner look */

.item-card {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    cursor: pointer;
    position: relative;
    transition: all 0.15s ease;
}

.item-card:hover {
    border-color: #94A3B8;
    background-color: #FFFFFF;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 2;
}

/* Meta Line */
.meta-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.ref-id {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    background-color: #F1F5F9;
    padding: 2px 6px;
    border-radius: 4px;
}

.ko-tag {
    font-size: 0.65rem;
    font-weight: 800;
    color: white;
    background-color: #EF4444;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Approximate correspondence indicator */
.approximate-indicator {
    font-size: 1rem;
    color: #F59E0B;
    margin-left: 6px;
    cursor: help;
    transition: transform 0.2s;
}

.approximate-indicator:hover {
    transform: scale(1.2);
}

/* Approximate active state - amber highlight */
.item-card.active.approximate-active {
    background-color: #FFFBEB;
    border-color: #F59E0B;
    box-shadow: 0 0 0 1px #F59E0B;
}

.item-card.active.approximate-active .ref-id {
    background-color: #F59E0B;
    color: white;
}

/* No match indicator (red) */
.no-match-indicator {
    font-size: 1rem;
    color: #EF4444;
    margin-left: 6px;
    cursor: help;
    transition: transform 0.2s;
}

.no-match-indicator:hover {
    transform: scale(1.2);
}

/* No match active state - red highlight */
.item-card.active.no-match-active {
    background-color: #FEF2F2;
    border-color: #EF4444;
    box-shadow: 0 0 0 1px #EF4444;
}

.item-card.active.no-match-active .ref-id {
    background-color: #EF4444;
    color: white;
}

.item-text {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-main);
}

/* --- ACTIVE STATES --- */
/* Strong visual cue when selected/linked */

.item-card.active {
    background-color: #FFF;
    box-shadow: 0 0 0 2px transparent;
}

/* IFS Active */
.ifs-card.active {
    border-color: var(--primary-ifs);
    background-color: #f0f7ff;
    box-shadow: 0 0 0 1px var(--primary-ifs);
}

.ifs-card.active .ref-id {
    background-color: var(--primary-ifs);
    color: white;
}

/* BRC Active */
.brc-card.active {
    border-color: var(--primary-brc);
    background-color: #fff5f2;
    box-shadow: 0 0 0 1px var(--primary-brc);
}

.brc-card.active .ref-id {
    background-color: var(--primary-brc);
    color: white;
}

/* Utility to ensure details marker is hidden in standard browsers */
details>summary::-webkit-details-marker {
    display: none;
}

/* ─── COMPARISON MODE ─────────────────────────────────────────────────────── */

/* Compare toggle button — active state */
.nav-btn.compare-btn {
    font-size: 1rem;
    font-weight: 700;
    padding: 4px 9px;
}

.nav-btn.compare-btn.active-mode {
    background-color: var(--primary-ifs);
    border-color: var(--primary-ifs);
    color: white;
}

.nav-btn.compare-btn.active-mode:hover {
    background-color: var(--primary-ifs-hover);
}

/* Compare status bar */
.compare-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 1rem;
    background-color: var(--primary-ifs-light);
    border-bottom: 1px solid var(--primary-ifs);
    font-size: 0.8rem;
    color: var(--primary-ifs);
    font-weight: 500;
}

.compare-bar.visible {
    display: flex;
}

.compare-clear-btn {
    background: none;
    border: 1px solid var(--primary-ifs);
    border-radius: 4px;
    color: var(--primary-ifs);
    font-size: 0.75rem;
    padding: 2px 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.compare-clear-btn:hover {
    background-color: var(--primary-ifs);
    color: white;
}

/* IFS card selected in comparison mode */
.ifs-card.selected {
    border-color: var(--primary-ifs);
    background-color: #dbeafe;
    box-shadow: 0 0 0 2px var(--primary-ifs);
}

.ifs-card.selected .ref-id {
    background-color: var(--primary-ifs);
    color: white;
}

.ifs-card.selected::after {
    content: '✓';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-ifs);
    background: white;
    border: 1px solid var(--primary-ifs);
    border-radius: 50%;
    width: 1.1rem;
    height: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ─── MOBILE TABS ─────────────────────────────────────────────────────────── */

.mobile-tabs {
    display: none; /* hidden on desktop */
}

.mobile-tab {
    flex: 1;
    padding: 0.65rem;
    border: none;
    border-bottom: 3px solid transparent;
    background: var(--bg-surface);
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-tab.active {
    color: var(--primary-ifs);
    border-bottom-color: var(--primary-ifs);
    background-color: var(--primary-ifs-light);
}

.mobile-tab:last-child.active {
    color: var(--primary-brc);
    border-bottom-color: var(--primary-brc);
    background-color: var(--primary-brc-light);
}

/* ─── RESPONSIVE — MOBILE ─────────────────────────────────────────────────── */

@media (max-width: 768px) {

    /* Body becomes scrollable on mobile */
    body {
        height: auto;
        min-height: 100dvh;
        overflow: auto;
    }

    /* Compact header */
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
        padding: 0.75rem 1rem;
    }

    .logo-section {
        font-size: 1.1rem;
    }

    .logo-ifs,
    .logo-brc {
        padding: 0.3rem 0.6rem;
    }

    .header-text p {
        display: none; /* hide subtitle on mobile */
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .search-input {
        width: 100%;
        flex: 1;
    }

    /* Guide panel full-width on mobile */
    .guide-panel {
        right: auto;
        left: 0;
        min-width: calc(100vw - 2rem);
        position: fixed;
        top: auto;
        margin-top: 0;
    }

    .guide-wrapper {
        position: static;
    }

    /* Show mobile tabs */
    .mobile-tabs {
        display: flex;
        border-bottom: 1px solid var(--border-color);
        background: var(--bg-surface);
        position: sticky;
        top: 0;
        z-index: 15;
    }

    /* Main layout stacks vertically */
    .main-container {
        flex-direction: column;
        overflow: visible;
        height: auto;
    }

    /* Each column takes full height (auto) when visible */
    .column {
        height: calc(100dvh - 180px);
        flex: none;
    }

    /* JS adds this class to hide a column on mobile */
    .mobile-hidden {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .logo-section {
        font-size: 0.95rem;
    }

    .header-text h1 {
        font-size: 1rem;
    }

    .column-header h2 {
        font-size: 0.95rem;
    }
}