/* 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 {
    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;
}

.lang-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lang-en {
    opacity: 0.6;
}

.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);
}

/* Help Banner */
.help-banner {
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
}

.help-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.help-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.help-icon {
    font-size: 1.1rem;
}

.help-text {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    color: var(--text-main);
}

.help-text strong {
    font-size: 0.85rem;
    color: var(--text-main);
}

.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;
}