/*
 * Lung250M-4B Medical Visualization Platform Styles
 * Modern, professional medical aesthetic
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
    --color-primary: #0284c7;
    --color-primary-light: #38bdf8;
    --color-primary-dark: #0369a1;
    
    --color-lung-inspire: #3b82f6;
    --color-lung-expire: #ef4444;
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

/* ==========================================================================
   Navigation
   ========================================================================== */
.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    color: #0f172a;
    background-color: #f1f5f9;
}

.nav-link.active {
    color: var(--color-primary);
    background-color: #e0f2fe;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
    color: #64748b;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    color: #0f172a;
    background-color: #f1f5f9;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    background-color: var(--color-primary);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: white;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.btn-view {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: white;
    color: #0f172a;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-normal);
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.stat-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.stat-label {
    font-size: 0.875rem;
    color: #ffffff !important;
    margin-top: 0.5rem;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   View Toggle
   ========================================================================== */
.view-btn {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    color: #64748b;
    transition: all var(--transition-fast);
}

.view-btn:hover {
    color: #0f172a;
}

.view-btn.active {
    background-color: white;
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Case Cards
   ========================================================================== */
.case-card {
    background: white;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid #e2e8f0;
    transition: all var(--transition-normal);
}

.case-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: #cbd5e1;
}

.case-thumbnail {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: #f8fafc;
}

.case-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.case-card:hover .case-thumbnail img {
    transform: scale(1.05);
}

.case-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 50%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 1.5rem;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.case-card:hover .case-overlay {
    opacity: 1;
}

.case-card:hover .btn-view {
    opacity: 1;
    transform: translateY(0);
}

.case-badges {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-3d {
    background: rgba(59, 130, 246, 0.9);
    color: white;
}

.badge-animation {
    background: rgba(168, 85, 247, 0.9);
    color: white;
}

.badge-complete {
    background: rgba(16, 185, 129, 0.9);
    color: white;
}

.badge-partial {
    background: rgba(245, 158, 11, 0.9);
    color: white;
}

.badge-missing {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

.case-info {
    padding: 1rem;
}

.case-title {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}

.case-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.case-tag {
    padding: 0.125rem 0.5rem;
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.625rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

/* ==========================================================================
   Capability Cards
   ========================================================================== */
.capability-card {
    padding: 1.5rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-xl);
    transition: all var(--transition-normal);
}

.capability-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.capability-icon {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

/* ==========================================================================
   Sidebar Cards
   ========================================================================== */
.card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    color: #0f172a;
    display: flex;
    align-items: center;
}

.card-body {
    padding: 1.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-md);
    color: #64748b;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.nav-item:hover {
    background: #f8fafc;
    color: #0f172a;
}

.nav-item.active {
    background: #e0f2fe;
    color: var(--color-primary);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 0.875rem;
    color: #64748b;
}

.stat-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
}

/* ==========================================================================
   Visualization Sections
   ========================================================================== */
.viz-section {
    scroll-margin-top: 6rem;
}

.section-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
}

.section-desc {
    font-size: 0.875rem;
    color: #64748b;
    margin-top: 0.5rem;
}

.viz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.viz-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.viz-item:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-lg);
}

.viz-image {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: #f8fafc;
}

.viz-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.viz-item:hover .viz-image img {
    transform: scale(1.02);
}

.viz-embed {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.viz-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.viz-image:hover .viz-overlay,
.viz-embed:hover .viz-overlay {
    opacity: 1;
}

.viz-caption {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.viz-tag {
    padding: 0.25rem 0.5rem;
    background: #e0f2fe;
    color: var(--color-primary-dark);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.viz-name {
    font-size: 0.75rem;
    color: #64748b;
    font-family: 'JetBrains Mono', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================================================
   Modal
   ========================================================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    padding: 1rem;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform var(--transition-normal);
    padding: 1.5rem;
}

.modal.active .modal-content {
    transform: scale(1);
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox img {
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--radius-lg);
}

.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-caption {
    color: white;
    margin-top: 1rem;
    font-size: 0.875rem;
    opacity: 0.8;
}

/* ==========================================================================
   Error Pages
   ========================================================================== */
.error-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.error-code {
    font-size: 6rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ==========================================================================
   Hero Animation
   ========================================================================== */
.hero-animation {
    width: 100%;
    height: 75vh;
    min-height: 500px;
    max-height: 800px;
    border: none;
    background: #0f172a;
    overflow: auto;
    display: block;
}

/* Plotly iframe scaling - makes fixed-size Plotly charts fit container */
.plotly-scaled-iframe {
    width: 1400px;  /* Plotly default width */
    height: 1000px; /* Plotly default height */
    border: none;
    background: transparent;
    transform-origin: top left;
    transform: scale(calc(100% / 1400 * 100)); /* Will be overridden by JS */
}

.animation-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none; /* Allow mouse events to pass through to iframe */
}

.viz-embed-wrapper:hover .animation-overlay {
    opacity: 1;
    pointer-events: auto; /* Re-enable clicks on overlay when visible */
}

.play-button {
    width: 5rem;
    height: 5rem;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-primary);
    box-shadow: var(--shadow-xl);
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.viz-embed-wrapper:hover .play-button {
    transform: scale(1);
}

/* ==========================================================================
   2x2 Overview Grid
   ========================================================================== */
.viz-grid-2x2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.viz-grid-2x2 .viz-item {
    min-height: 300px;
}

.viz-grid-2x2 .viz-image-large,
.viz-grid-2x2 .viz-embed-wrapper {
    aspect-ratio: 16/10;
}

.viz-image-large {
    position: relative;
    overflow: hidden;
    background: #f8fafc;
}

.viz-image-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.viz-image-large:hover img {
    transform: scale(1.03);
}

.viz-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    overflow: hidden;
    display: block;
}

/* ==========================================================================
   Special HTML Visualizations (comprehensive.html, 360.html)
   ========================================================================== */
.viz-special-wrapper {
    width: 100%;
    height: 65vh;
    min-height: 450px;
    max-height: 700px;
    background: #0f172a;
    border-radius: var(--radius-xl);
    overflow: hidden;
    position: relative;
}

.viz-special-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    overflow: auto;
    display: block;
    /* Enable scrolling within iframe */
}

/* Hero animation iframe */
.viz-embed-wrapper .hero-animation {
    width: 100%;
    height: 100%;
    border: none;
    background: #0f172a;
    overflow: auto;
}

/* Adjust height for smaller screens */
@media (max-width: 1024px) {
    .viz-special-wrapper {
        height: 55vh;
        min-height: 380px;
    }
}

@media (max-width: 768px) {
    .viz-special-wrapper {
        height: 45vh;
        min-height: 320px;
    }
}

/* ==========================================================================
   Horizontal Scroll Grid (Point Clouds, Surfaces)
   ========================================================================== */
.viz-grid-scroll {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    scroll-snap-type: x mandatory;
}

.viz-grid-scroll .viz-item {
    flex: 0 0 auto;
    width: 500px;
    scroll-snap-align: start;
}

.viz-grid-scroll .viz-image-large {
    aspect-ratio: 16/12;
}

.viz-grid-scroll::-webkit-scrollbar {
    height: 8px;
}

.viz-grid-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: var(--radius-md);
}

.viz-grid-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: var(--radius-md);
}

.viz-grid-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 1024px) {
    .viz-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .error-code {
        font-size: 4rem;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    nav, footer, .btn-icon, .btn-primary, .btn-secondary {
        display: none !important;
    }
    
    .case-card {
        break-inside: avoid;
    }
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
