/* Prevent FOUC (Flash of Unstyled Content) */
body {
    visibility: hidden;
}

body.loaded {
    visibility: visible;
}

/* CSS custom properties */
:root {
    --primary-color: #0056b3;
    /* A trustworthy blue */
    --secondary-color: #007bff;
    --background-color: #f4f7f6;
    --surface-color: #ffffff;
    --text-color: #333;
    --border-color: #dee2e6;
    --header-height: 160px;
}

/* Smooth scroll for anchor links */
html {
    scroll-behavior: smooth;
}

/* General Body & Reset Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', 'Arial', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 100vw;
    margin: 0 auto;
    padding: calc(var(--header-height) + 20px) 20px 20px 20px;
}

/* Header and Patient Info */
header {
    background-color: var(--surface-color);
    padding: 10px 20px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    border-bottom: 2px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Language Selector */
.language-selector {
    display: flex;
    gap: 6px;
    background: rgba(0, 86, 179, 0.08);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid rgba(0, 86, 179, 0.2);
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    color: #666;
}

.lang-btn:hover {
    background: rgba(0, 86, 179, 0.1);
    transform: translateY(-1px);
}

.lang-btn.active {
    background: linear-gradient(135deg, #0056b3, #007bff);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 86, 179, 0.3);
}

.lang-btn .flag {
    font-size: 18px;
    line-height: 1;
}

.lang-btn .lang-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    letter-spacing: 0.5px;
}

.lang-btn.active .lang-text {
    font-weight: 600;
}

/* Export Button */
.export-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #0056b3, #007bff);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 86, 179, 0.3);
}

.export-btn:hover {
    background: linear-gradient(135deg, #004494, #0056b3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 86, 179, 0.4);
}

.export-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 86, 179, 0.3);
}

.export-btn:disabled {
    background: linear-gradient(135deg, #ccc, #999);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.export-icon {
    font-size: 18px;
    line-height: 1;
}

.export-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Export button loading state */
.export-btn.loading {
    opacity: 0.7;
    cursor: wait;
}

.export-btn.loading .export-icon {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Download Button */
.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #28a745, #20c997);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    font-weight: 500;
    color: white;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
    text-decoration: none;
    margin-top: 10px;
}

.download-btn:hover {
    background: linear-gradient(135deg, #218838, #1aa179);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.4);
}

.download-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.download-icon {
    font-size: 16px;
    line-height: 1;
}

.download-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    letter-spacing: 0.3px;
    font-weight: 600;
}

header h1 {
    color: var(--primary-color);
    font-size: 1.8em;
}

#search-bar {
    padding: 8px 12px 8px 40px;
    border: 2px solid var(--primary-color);
    border-radius: 25px;
    width: 600px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg>');
    background-repeat: no-repeat;
    background-position: 15px center;
    background-size: 16px;
    box-shadow: 0 0 10px rgba(0, 86, 179, 0.3), 0 0 20px rgba(0, 86, 179, 0.2);
    transition: all 0.3s ease;
}

#search-bar:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.4), 0 0 25px rgba(0, 123, 255, 0.3);
    transform: scale(1.02);
}

/* Clear Button - absolutely positioned to overlap search bar right edge */
.search-clear-btn {
    position: absolute;
    right: 385px;
    /* Adjust based on search bar width (600px) and header layout */
    top: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    color: #666;
    transition: all 0.2s ease;
    padding: 0;
    z-index: 1000;
}

.search-clear-btn:hover {
    background: rgba(0, 0, 0, 0.3);
    color: #333;
    transform: scale(1.1);
}

.search-clear-btn:active {
    transform: scale(0.95);
}

/* Search Navigation */
.search-navigation {
    display: none;
    align-items: center;
    gap: 10px;
    margin-left: 15px;
}

.match-counter {
    font-size: 0.9em;
    color: var(--text-color);
    font-weight: 500;
    padding: 4px 10px;
    background: rgba(0, 86, 179, 0.1);
    border-radius: 12px;
    white-space: nowrap;
}

.nav-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: bold;
}

.nav-search-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 86, 179, 0.3);
}

.nav-search-btn:active {
    transform: translateY(0);
}

/* Search Highlights */
.search-highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.search-highlight.current {
    background-color: #ff9800;
    color: #fff;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.3);
    font-weight: 600;
}

/* Tab Badges */
.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 2px 6px;
    margin-left: 8px;
    background: #e53935;
    color: white;
    font-size: 0.75em;
    font-weight: 600;
    border-radius: 10px;
    line-height: 1;
}

.tab-button.active .tab-badge {
    background: #ff5252;
}

.patient-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    padding-top: 10px;
}

.patient-info div {
    font-size: 0.95em;
}

.patient-info strong {
    color: var(--primary-color);
    margin-right: 8px;
}

/* Cards Grid Layout - Natural Height Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: min-content;
    grid-auto-flow: dense;
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.card.full-width {
    width: 100%;
    margin-bottom: 30px;
}

/* ========================================
   TABS SYSTEM
   ======================================== */

/* Tabs Container */
.tabs-container {
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
}

/* Tabs Navigation */
.tabs-navigation {
    display: flex;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tabs-navigation::-webkit-scrollbar {
    height: 4px;
}

.tabs-navigation::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.tabs-navigation::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

/* Tab Buttons */
.tab-button {
    flex: 1;
    min-width: 150px;
    padding: 16px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s ease;
    text-align: center;
    white-space: nowrap;
    position: relative;
}

.tab-button:hover {
    background: rgba(0, 86, 179, 0.05);
    color: var(--primary-color);
}

.tab-button.active {
    background: var(--surface-color);
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 3px 3px 0 0;
}

/* Tabs Content Area */
.tabs-content {
    position: relative;
    min-height: 400px;
}

/* Tab Panels */
.tab-panel {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease-in;
}

.tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Adjust existing card content styles within tabs */
.tab-panel h4:first-child {
    margin-top: 0;
}



.two-column-layout {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

.two-column-layout .card {
    flex: 1;
}

.two-column-layout .medication-legend {
    flex: 1;
}

.two-column-layout .data-section {
    flex: 2;
}

/* Symptoms Section Styles */
.symptoms-section {
    margin: 0;
}

/* Treatments Section (Traitements tab) */
.treatments-section {
    margin: 0;
}

.treatments-section table {
    width: 100%;
}

/* Severity Legend */
.severity-legend {
    background-color: #f8f9fa;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 25px;
}

.severity-legend h4 {
    color: var(--primary-color);
    margin: 0 0 12px 0;
    font-size: 1em;
    font-weight: 600;
}

.severity-legend .legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    font-size: 0.95em;
}

/* Severity Tags */
.severity-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 8px;
    font-size: 14px;
    vertical-align: middle;
}

.severity-tag.severity-high {
    background-color: rgba(220, 53, 69, 0.1);
}

.severity-tag.severity-moderate {
    background-color: rgba(255, 193, 7, 0.1);
}

.severity-tag.severity-mild {
    background-color: rgba(40, 167, 69, 0.1);
}

.symptoms-section h4 {
    color: var(--primary-color);
    margin: 20px 0 15px 0;
    font-size: 1.1em;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.symptoms-section h4:first-child {
    margin-top: 0;
}

.symptoms-section .accordion {
    margin-bottom: 12px;
}

.symptoms-section .accordion-header {
    font-size: 1.05em;
    padding: 14px 18px;
}

.symptoms-section .accordion-content {
    padding: 0;
}

.symptoms-list {
    list-style: none;
    padding: 15px;
    margin: 0;
}

.symptoms-list li {
    padding: 12px 15px;
    margin-bottom: 10px;
    background-color: #ffffff;
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
    font-size: 0.95em;
    line-height: 1.6;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.symptoms-list li:hover {
    background-color: #f8f9fa;
    transform: translateX(3px);
}

.symptoms-list li:last-child {
    margin-bottom: 0;
}

.symptoms-list.resolved li {
    border-left-color: #28a745;
    background-color: #f8fff8;
    opacity: 0.8;
}

.symptoms-list.resolved li:hover {
    background-color: #e8f5e8;
}

.symptoms-list.recent li {
    border-left-color: #ffc107;
    background-color: #fffdf5;
}

.symptoms-list.recent li:hover {
    background-color: #fff8e1;
}

.symptoms-list.post-surgery li {
    border-left-color: #dc3545;
    background-color: #fff5f5;
}

.symptoms-list.post-surgery li:hover {
    background-color: #ffe6e6;
}

.symptoms-list.medication li {
    border-left-color: #6f42c1;
    background-color: #f8f5ff;
}

.symptoms-list.medication li:hover {
    background-color: #f0e6ff;
}


.three-column-layout {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.three-column-layout .medication-legend {
    flex: 1;
}

.three-column-layout .results-section {
    flex: 2;
}

.three-column-layout .data-section {
    flex: 1.5;
}

.data-section {
    margin: 20px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.data-section h4 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-size: 1.1em;
}

.results-section {
    margin: 20px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.results-section h4 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-size: 1.1em;
}

.results-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-item {
    padding: 10px;
    background-color: white;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
    font-size: 0.9em;
    line-height: 1.4;
    scroll-margin-top: calc(var(--header-height) + 16px);
}

.result-symbol {
    font-size: 1.5em;
    margin-right: 8px;
}

.result-symbol.colonoscopy {
    color: rgba(108, 117, 125, 1);
}

.result-symbol.irm {
    color: rgba(255, 99, 132, 1);
}

.result-symbol.video-capsule {
    color: rgba(54, 162, 235, 1);
}

.result-symbol.prelevement {
    color: rgba(255, 206, 86, 1);
}

.result-symbol.entero-irm {
    color: rgba(75, 192, 192, 1);
}

.minimal-repair-link {
    color: var(--primary-color);
    text-decoration: underline;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease;
}

.minimal-repair-link:hover {
    color: #003d82;
    text-decoration: underline;
}

.minimal-repair-link:active {
    color: #002855;
}

/* Accordion Styles */
.accordion {
    margin-bottom: 10px;
}

.accordion-header {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #495057;
    transition: background-color 0.2s ease;
}

.accordion-header>span:first-child {
    flex: 1;
}

.accordion-header:hover {
    background-color: #e9ecef;
}

.accordion-header::after {
    content: '+';
    font-size: 18px;
    font-weight: bold;
    transition: transform 0.2s ease;
}

/* Status Badge Styles */
.status-badge {
    font-size: 0.75em;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 12px;
    margin-left: 8px;
    margin-right: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.status-elevated {
    background-color: #dc3545;
    color: white;
}

.status-badge.status-normal {
    background-color: #28a745;
    color: white;
}

.accordion-header.active::after {
    content: '−';
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

.accordion-content.active {
    max-height: none;
    overflow: visible;
}

.accordion-content table {
    margin: 0;
    border-radius: 0;
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 20px;
    text-align: center;
}

.card-header h3 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
}

.card-content {
    padding: 20px;
}

.card-content h4 {
    color: var(--secondary-color);
    margin: 20px 0 15px 0;
    font-size: 1.1em;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.card-content h4:first-child {
    margin-top: 0;
}

.card-content p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.card-content ul {
    margin-bottom: 20px;
    padding-left: 20px;
}

.card-content li {
    margin-bottom: 8px;
}

/* Tables, Charts, and Images */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.9em;
}

th,
td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--primary-color);
}

.report-image {
    max-width: 150px;
    border-radius: 5px;
    margin: 5px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.report-image:hover {
    transform: scale(1.05);
}

/* Case summary card (top of Chronologie) – matches .results-section / .data-section */
.case-summary-wrapper {
    margin: 20px 0;
}

.case-summary-card {
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.case-summary-card > h4 {
    margin-top: 20px;
    margin-bottom: 8px;
}

.case-summary-card > .chart-container {
    margin-bottom: 8px;
}

.case-summary-inner .case-summary-title {
    margin: 0 0 18px 0;
    color: var(--primary-color);
    font-size: 1.1em;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

/* Narrative: short paragraph with breathing room */
.case-summary-narrative {
    margin-bottom: 22px;
    padding: 14px 16px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
}

.case-summary-narrative .case-summary-text {
    margin: 0;
    font-size: 0.95em;
    line-height: 1.65;
}

/* Key dates: horizontal timeline with alternating above/below */
.case-summary-key-dates-block {
    margin-bottom: 20px;
}

.case-summary-key-dates-label {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9em;
    margin-bottom: 22px;
    display: block;
    position: relative;
    z-index: 2;
    background-color: #f8f9fa;
    padding-bottom: 4px;
}

.case-summary-timeline--horizontal {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
    position: relative;
    padding: 52px 0 40px;
    gap: 8px;
}

.case-summary-timeline--horizontal::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    background: var(--border-color);
    transform: translateY(-50%);
    z-index: 0;
}

.case-summary-timeline-item {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 95px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
}

.case-summary-timeline-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-radius: 50%;
    background: var(--primary-color);
    flex-shrink: 0;
}

.case-summary-timeline-item--above .case-summary-timeline-item-body {
    position: absolute;
    bottom: calc(50% + 12px);
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    width: 110px;
    max-width: 110px;
    box-sizing: border-box;
}

.case-summary-timeline-item--below .case-summary-timeline-item-body {
    position: absolute;
    top: calc(50% + 12px);
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    width: 110px;
    max-width: 110px;
    box-sizing: border-box;
}

.case-summary-timeline-content {
    font-weight: 500;
    line-height: 1.3;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.case-summary-timeline-date {
    color: var(--text-color);
    opacity: 0.9;
    margin-top: 2px;
}

.case-summary-timeline-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    display: block;
    min-width: 0;
    max-width: 100%;
}
.case-summary-timeline-link:hover {
    text-decoration: underline;
    color: var(--primary-color);
}

/* Biomarkers + treatment: 3-column grid, each cell is a mini card */
.case-summary-biomarkers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.case-summary-biomarker-cell {
    padding: 12px 14px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.case-summary-biomarker-label {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 6px;
}

.case-summary-biomarker-value {
    font-size: 1em;
    font-weight: 600;
}

.case-summary-biomarker-meta {
    font-size: 0.8em;
    color: var(--text-color);
    opacity: 0.9;
    margin-top: 2px;
}

/* Clinical context: subheading then horizontal wrap of label/value items */
.case-summary-context-heading {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9em;
    margin-bottom: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

.case-summary-context {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin: 0;
    padding: 0;
    font-size: 0.9em;
}

.case-summary-context-item {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}

.case-summary-context-item:not(:last-child)::after {
    content: '·';
    margin-left: 12px;
    color: var(--border-color);
    font-weight: bold;
}

.case-summary-context-label {
    font-weight: 600;
    color: var(--primary-color);
    flex-shrink: 0;
}

.case-summary-context-value {
    line-height: 1.4;
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
    margin: 15px 0;
}

.medication-legend {
    margin: 20px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.medication-legend h4 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-size: 1.1em;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-color {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.treatment-timeline {
    margin: 20px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.treatment-timeline h4 {
    margin: 0 0 20px 0;
    color: var(--primary-color);
    text-align: center;
}

.timeline-container {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    position: relative;
    padding: 20px 0;
    gap: 10px;
}

.timeline-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--border-color);
    z-index: 1;
}

.timeline-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    flex: 1;
}

.timeline-date {
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 0.9em;
}

.date-reference {
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 0.9em;
    text-align: center;
    padding: 8px 12px;
    background-color: var(--surface-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.timeline-content {
    background-color: var(--surface-color);
    padding: 10px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    text-align: center;
    width: 100%;
    min-width: 150px;
}

.treatment-period {
    padding: 8px;
    border-radius: 4px;
    color: white;
    font-weight: 500;
}

.treatment-period.budesonide {
    background-color: rgba(255, 193, 7, 0.8);
    border: 2px solid rgba(255, 193, 7, 1);
}

.treatment-period.pentasa {
    background-color: rgba(0, 123, 255, 0.8);
    border: 2px solid rgba(0, 123, 255, 1);
}

.treatment-gap {
    background-color: rgba(108, 117, 125, 0.1);
    border: 2px solid rgba(108, 117, 125, 0.3);
    color: var(--text-color);
}

.treatment-improvement {
    background-color: rgba(40, 167, 69, 0.1);
    border: 2px solid rgba(40, 167, 69, 0.5);
    color: var(--text-color);
}

.treatment-name {
    display: block;
    font-weight: bold;
    margin-bottom: 4px;
}

.treatment-duration {
    display: block;
    font-size: 0.8em;
    opacity: 0.9;
}

.improvement-detail {
    display: block;
    font-size: 0.8em;
    margin-top: 4px;
    color: var(--primary-color);
}



/* Timeline Section */
#timeline {
    position: relative;
    padding: 20px 0;
}

#timeline h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

#timeline::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    height: 100%;
    width: 4px;
    background: var(--border-color);
}

.timeline-item {
    margin-bottom: 20px;
    position: relative;
    padding-left: 50px;
    cursor: pointer;
}

.timeline-item::before {
    /* Dot on the timeline */
    content: '';
    position: absolute;
    left: 10px;
    top: 5px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface-color);
    border: 4px solid var(--secondary-color);
    z-index: 1;
}

.timeline-content {
    background: var(--surface-color);
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.timeline-date {
    font-weight: 500;
    color: var(--primary-color);
}

/* Categories for timeline items */
.timeline-item[data-category="Treatment"]::before {
    border-color: #28a745;
}

/* Green */
.timeline-item[data-category="Surgery"]::before {
    border-color: #dc3545;
}

/* Red */
.timeline-item[data-category="Test"]::before {
    border-color: #ffc107;
}

/* Yellow */
.timeline-item[data-category="Symptom"]::before {
    border-color: #17a2b8;
}

/* Teal */

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 30px;
    color: #6c757d;
    font-size: 0.9em;
}

/* Modal for images */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    justify-content: center;
    align-items: center;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-container {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-image-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    max-height: 80vh;
}

.modal-content {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.modal-content:hover {
    transform: scale(1.02);
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #ffffff;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-modal:hover,
.close-modal:focus {
    color: #ff6b6b;
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.modal-navigation {
    position: fixed;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 5;
    padding: 0 20px;
}

.nav-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 28px;
    padding: 20px 25px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s ease;
    pointer-events: auto;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 60px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.1);
}

.prev-btn {
    margin-left: 0;
}

.next-btn {
    margin-right: 0;
}

.modal-info {
    margin-top: 15px;
    color: white;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 14px;
    display: flex;
    gap: 20px;
    align-items: center;
}

#modalImageInfo {
    font-weight: 500;
}

#modalImageCounter {
    color: #cccccc;
    font-size: 12px;
}



/* Media Section Styles */
.media-accordion {
    margin-top: 20px;
}

.file-count {
    background-color: #e9ecef;
    color: #6c757d;
    font-size: 0.8em;
    padding: 2px 6px;
    border-radius: 12px;
    margin-left: 8px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px 0;
    width: 100%;
    box-sizing: border-box;
}

.media-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.media-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.media-thumbnail {
    width: 100%;
    height: 150px;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.media-thumbnail:hover {
    opacity: 0.9;
}

.media-info {
    padding: 10px;
    font-size: 0.9em;
    color: #495057;
    text-align: center;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

/* Video specific styles */
.video-item {
    position: relative;
}

.video-thumbnail {
    width: 100%;
    height: 150px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    border-radius: 8px 8px 0 0;
}

.play-button {
    font-size: 3em;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.video-thumbnail:hover .play-button {
    transform: scale(1.1);
}

.video-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px;
    font-size: 0.8em;
    text-align: center;
}

/* Video modal specific styles */
#videoModal .modal-content {
    max-width: 90%;
    max-height: 90%;
    width: auto;
    height: auto;
}

/* Pagination Styles */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    gap: 10px;
}

.pagination-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.pagination-button:hover:not(:disabled) {
    background-color: var(--secondary-color);
}

.pagination-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.pagination-info {
    background-color: #f8f9fa;
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    font-size: 14px;
    color: #495057;
}

.pagination-pages {
    display: flex;
    gap: 5px;
    align-items: center;
}

.page-number {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.page-number:hover {
    background-color: #e9ecef;
}

.page-number.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Paginated grids will have dynamic height based on content */
#entero-irm-grid,
#irm-abdomino-grid {
    min-height: 200px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px 0;
}

/* Ensure media grids don't overflow their containers */
.media-accordion .accordion-content {
    max-height: 0;
    overflow: hidden;
}

.media-accordion .accordion-content.active {
    max-height: 85vh;
    overflow-y: auto;
}



/* Two Column Layout for Normal Results */
.normal-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.normal-results-section {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid var(--border-color);
}

.normal-results-section h4 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-size: 1.1em;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.normal-results-section table {
    margin: 0;
    font-size: 0.9em;
}

.normal-results-section .result-item {
    margin: 0;
    padding: 10px;
    background-color: white;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
    font-size: 0.9em;
    line-height: 1.4;
}



/* Search Highlighting Styles */
.search-highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(255, 235, 59, 0.3);
}

.search-highlight.active {
    background-color: #ff9800;
    color: white;
    animation: searchPulse 0.5s ease-in-out;
}

@keyframes searchPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* Print Styles */
@media print {
    body {
        background-color: #fff;
    }

    header,
    footer,
    #search-bar {
        display: none;
    }

    .container {
        padding: 0;
        max-width: 100%;
    }

    .cards-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--border-color);
        page-break-inside: avoid;
    }

    .card-header {
        background: var(--primary-color) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }
}

/* Login page (auth) - app-matched styling */
body.login-page {
    visibility: visible;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #f4f7f6 0%, #e9ecef 100%);
}

body.login-page > * {
    visibility: visible;
}

.login-page .login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-page .login-card {
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    padding: 40px;
}

.login-page .login-card h1 {
    color: var(--primary-color);
    font-size: 1.8em;
    margin-bottom: 24px;
    text-align: center;
}

.login-page .login-form label {
    display: block;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 8px;
}

.login-page .login-form input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    box-sizing: border-box;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.login-page .login-form input[type="password"]:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 12px rgba(0, 123, 255, 0.3);
}

.login-page .login-form .login-btn {
    width: 100%;
    margin-top: 20px;
    padding: 12px 16px;
    justify-content: center;
}

.login-page .login-error {
    color: #dc3545;
    font-size: 0.95em;
    margin-top: 12px;
    text-align: center;
}