/* Design Tokens & Theme Variables */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    
    --accent-blue: #0070f3;
    --accent-blue-rgb: 0, 112, 243;
    --accent-cyan: #00dfd8;
    --accent-cyan-glow: rgba(0, 223, 216, 0.15);
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    
    --glow-shadow: 0 0 25px rgba(0, 112, 243, 0.25);
    --border-glow: rgba(0, 112, 243, 0.4);
    
    --transition-speed: 0.3s;
    --radius-lg: 16px;
    --radius-md: 10px;
}

/* Reset and Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem 1.5rem;
    line-height: 1.5;
    background-image: 
        radial-gradient(at 0% 0%, rgba(0, 112, 243, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 223, 216, 0.12) 0px, transparent 50%);
    background-attachment: fixed;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header Styles */
.app-header {
    text-align: center;
    padding: 1.5rem 0;
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.brain-icon {
    width: 2.75rem;
    height: 2.75rem;
    color: var(--accent-cyan);
    filter: drop-shadow(0 0 10px rgba(0, 223, 216, 0.5));
    animation: float 4s ease-in-out infinite;
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #c7d2fe, var(--accent-cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}


.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0.5rem auto 1.5rem auto;
    font-weight: 300;
}

.timeline-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 223, 216, 0.08);
    border: 1px solid rgba(0, 223, 216, 0.3);
    color: var(--accent-cyan);
    padding: 0.5rem 1.25rem;
    border-radius: 50px;
    font-size: 0.95rem;
    box-shadow: 0 0 15px rgba(0, 223, 216, 0.05);
}

input[type="date"] {
    width: 200%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 16px;
}

/* Card General Style */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    padding: 2rem;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}
.card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--glow-shadow);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.card-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.card-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Card: Upload */
/* Card: Upload */
.upload-card {
    display: flex;
    flex-direction: column;
}

.patient-modal{
    position:fixed;
    top:0;
    left:0;
    width:100%;
    height:100%;
    background:rgba(0,0,0,0.75);
    backdrop-filter:blur(8px);
    display:flex;
    justify-content:center;
    align-items:center;
    z-index:9999;
    animation:fadeIn .4s ease;
}

.patient-form-section{
    max-width:700px;
    width:90%;
    animation:popupScale .4s ease;
}

@keyframes popupScale{
    from{
        opacity:0;
        transform:scale(.8);
    }
    to{
        opacity:1;
        transform:scale(1);
    }
}

.patient-form-section h2{
    margin-bottom: 20px;
    text-align: center;
}

.patient-form-section input,
.patient-form-section select{
    width: 100%;
    padding: 14px;
    margin-bottom: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255,.1);
    background: #111827;
    color: white;
}

#btn-start{
    width:100%;
    padding:14px;
    border:none;
    border-radius:12px;
    cursor:pointer;
    font-weight:600;
    color:white;
    background:linear-gradient(
        135deg,
        var(--accent-blue),
        var(--accent-cyan)
    );
    transition:all .3s ease;
}


/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 0.75fr 1.5fr 1.15fr;
    gap: 1.5rem;
}

.upload-section, .visualization-section, .metrics-section {
    min-width: 0;
}

@media (max-width: 968px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Left: Drag & Drop Card */
.upload-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 350px;
    padding: 1.25rem; /* Reduced from 2rem */
}

.upload-section .btn {
    padding: 0.75rem 1rem; /* Fitted button padding */
    font-size: 0.85rem; /* Slightly smaller button font size to prevent overflow */
}

.dropzone {
    border: 2px dashed rgba(0, 112, 243, 0.3);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1rem; /* Reduced from 2rem 1.5rem */
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent-cyan);
    background: rgba(0, 223, 216, 0.03);
    box-shadow: 0 0 20px rgba(0, 223, 216, 0.05);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.cloud-icon-wrapper {
    background: rgba(0, 112, 243, 0.08);
    border-radius: 50%;
    width: 4.5rem;
    height: 4.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-speed);
}

.dropzone:hover .cloud-icon-wrapper {
    transform: scale(1.1);
}

.cloud-icon {
    width: 2.25rem;
    height: 2.25rem;
    color: var(--accent-blue);
}

.dropzone h3 {
    font-size: 1.15rem;
    font-weight: 500;
}

.dropzone p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn {
    font-family: inherit;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #0056b3);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 112, 243, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 112, 243, 0.4), var(--glow-shadow);
}

.file-preview-container {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
}

#file-name-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 1rem;
}

.btn-cancel {
    background: transparent;
    color: var(--accent-red);
    border: none;
    font-weight: 500;
    cursor: pointer;
}

.btn-cancel:hover {
    text-decoration: underline;
}

/* Middle: Visualization Card */
.visualization-section {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.visualization-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-visual {
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
}

.placeholder-visual svg {
    width: 4.5rem;
    height: 4.5rem;
    color: rgba(255, 255, 255, 0.1);
}

.placeholder-visual p {
    font-size: 0.9rem;
    max-width: 250px;
}

.visual-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

.image-box {
    text-align: center;
}

.image-box h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.image-box img {
    width: 100%;
    max-height: 280px; /* Increased from 180px so brain scans are larger */
    object-fit: contain;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Right: Metrics & Diagnosis Card */
.metrics-section h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.metrics-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.metric-item .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-item .value {
    font-weight: 700;
}

.badge {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.25rem 0.75rem;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge.valid {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge.invalid {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.highlight {
    color: var(--accent-cyan);
    text-shadow: 0 0 10px rgba(0, 223, 216, 0.3);
}

/* Simple CSS Bar Charts */
.charts-container {
    display: flex;
    gap: 1.25rem;
}

.chart-box {
    flex: 1;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chart-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.bar-chart-visual {
    display: flex;
    width: 100%;
    height: 120px;
    gap: 1rem;
}

.bar-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    width: 25px;
    text-align: right;
    padding-right: 4px;
}

.bar-columns {
    flex: 1;
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    padding-bottom: 2px;
}

.bar-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 25px;
    height: 100%;
    justify-content: flex-end;
}

.bar-fill {
    width: 16px;
    background: linear-gradient(to top, var(--accent-blue), var(--accent-cyan));
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: height 1.2s cubic-bezier(0.1, 1, 0.1, 1);
    box-shadow: 0 0 10px rgba(0, 112, 243, 0.2);
}

.bar-tooltip {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    background: var(--bg-secondary);
    padding: 2px 4px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.bar-fill:hover .bar-tooltip {
    opacity: 1;
}

.bar-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 4px;
    text-align: center;
}

.compare-bars .bar-column {
    width: 20px;
}

.fallback-bar {
    background: linear-gradient(to top, #4b5563, #9ca3af);
    box-shadow: none;
}

.gemini-bar {
    background: linear-gradient(to top, #1d4ed8, #60a5fa);
}

.hybrid-bar {
    background: linear-gradient(to top, #0f766e, var(--accent-cyan));
    box-shadow: 0 0 10px rgba(0, 223, 216, 0.3);
}

/* Pipeline Section */
.pipeline-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem 2.5rem;
}

@media (max-width: 768px) {
    .pipeline-section {
        flex-direction: column;
        gap: 1.5rem;
        align-items: flex-start;
    }
    
    .pipeline-arrow {
        transform: rotate(90deg);
        align-self: center;
    }
}

.step {
    display: flex;
    align-items: center;
    gap: 1rem;
    opacity: 0.4;
    transition: opacity var(--transition-speed) ease;
}

.step.active {
    opacity: 1;
}

.step-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition: all var(--transition-speed);
}

.step.active .step-icon {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: var(--glow-shadow);
    color: white;
}

.step-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.step-info p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.pipeline-arrow svg {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--text-secondary);
}

/* Report Section */
.report-section {
    animation: fadeIn 0.5s ease;
}

.report-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .report-layout {
        grid-template-columns: 1fr;
    }
}

/* PDF Paper Styling */
.report-paper-wrapper {
    overflow-x: auto;
}

.report-paper {
    background: #ffffff;
    color: #1f2937;
    border-radius: 8px;
    padding: 3rem 2.5rem;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    min-height: 600px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.report-hospital-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.hospital-logo {
    width: 3.5rem;
    height: 3.5rem;
    color: var(--accent-blue);
}

.hospital-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
}

.hospital-info p {
    font-size: 0.8rem;
    color: #4b5563;
}

.hospital-info small {
    font-size: 0.7rem;
    color: #9ca3af;
}

.divider {
    height: 2px;
    background: #e5e7eb;
    margin: 1.5rem 0;
}

.report-content {
    font-family: 'JetBrains Mono', monospace;
    white-space: pre-wrap;
    font-size: 0.825rem;
    color: #374151;
}

/* Action Card */
.report-action-card {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
}

.action-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.pdf-file-icon {
    width: 5rem;
    height: 5rem;
    color: var(--accent-cyan);
    filter: drop-shadow(0 0 15px rgba(0, 223, 216, 0.3));
}

.report-action-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

.report-action-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-pdf {
    background: linear-gradient(135deg, var(--accent-cyan), #00b0aa);
    color: var(--bg-primary);
    box-shadow: 0 4px 15px rgba(0, 223, 216, 0.2);
}

.btn-pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 223, 216, 0.4), 0 0 20px rgba(0, 223, 216, 0.2);
}

/* Ablation Study Section */
.ablation-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.section-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.table-container {
    overflow-x: auto;
}

.ablation-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.ablation-table th {
    padding: 1rem;
    background: rgba(255,255,255,0.03);
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
}

.ablation-table td {
    padding: 1.2rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.highlight-row {
    background: rgba(0, 223, 216, 0.05);
    color: var(--accent-cyan);
    font-weight: 600;
}

.highlight-row td {
    border-bottom: 1px solid rgba(0, 223, 216, 0.3);
}

/* App Footer */
.app-footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 26, 0.85);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.3s ease;
}


.loader-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner {
    width: 3.5rem;
    height: 3.5rem;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-blue);
    border-right-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-content h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.loader-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Animations */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.history-modal{
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.75);
    display:none;
    justify-content:center;
    align-items:center;
    z-index:9999;
}

.history-popup{
    width:700px;
    max-width:90%;
    position:relative;
}

.close-history{
    position:absolute;
    right:20px;
    top:15px;
    cursor:pointer;
    font-size:22px;
}

.btn-history-open{
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 9999;

    padding: 14px 20px;
    border: none;
    border-radius: 50px;

    background: linear-gradient(
        135deg,
        #0070f3,
        #00dfd8
    );

    color: white;
    font-weight: 600;
    cursor: pointer;

    box-shadow: 0 0 20px rgba(0,223,216,.4);
}

.btn-history-open:hover{
    transform: translateY(-3px);
}

/* Animasi Tombol cari */
#btn-search-history{
    transition:.2s;
    background:linear-gradient(
        135deg,
        #0070f3,
        #00dfd8
    );
    color:white;
    border:none;
    padding:12px 20px;
    border-radius:10px;
    cursor:pointer;
}

#btn-search-history:hover{
    transform:translateY(-2px);
    box-shadow:0 0 15px rgba(0,223,216,.5);
}

#btn-search-history:active{
    transform:scale(.92);
}