/* ============================================================
   Prostate Biopsy Portal - Shadow Mode System
   Clean medical/clinical aesthetic
   ============================================================ */

:root {
    --navy: #1B2A4A;
    --teal: #0891B2;
    --green: #059669;
    --red: #DC2626;
    --orange: #F59E0B;
    --accent: #7C3AED;
    --text: #1E293B;
    --muted: #64748B;
    --light: #F1F5F9;
    --lighter: #F8FAFC;
    --border: #E2E8F0;
    --white: #FFFFFF;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    background: var(--lighter);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---- NAVBAR ---- */
.navbar {
    background: var(--navy);
    color: var(--white);
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}
.admin-nav { background: #0F172A; }
.nav-brand {
    display: flex; align-items: center; gap: 0.5rem;
    font-weight: 700; font-size: 1.05rem;
}
.nav-icon { font-size: 1.3rem; }
.nav-links { display: flex; gap: 0.25rem; align-items: center; }
.nav-links a {
    color: rgba(255,255,255,0.7); text-decoration: none;
    padding: 0.4rem 0.8rem; border-radius: var(--radius);
    font-size: 0.9rem; transition: all 0.2s;
}
.nav-links a:hover, .nav-links a.active {
    color: var(--white); background: rgba(255,255,255,0.1);
}

/* ---- CONTAINER ---- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ---- HERO ---- */
.hero {
    max-width: 900px;
    margin: 0 auto;
    padding: 4rem 1.5rem 2rem;
    text-align: center;
}
.hero h1 {
    font-size: 2.5rem; font-weight: 800; color: var(--navy);
    line-height: 1.2; margin-bottom: 0.75rem;
}
.hero .accent { color: var(--teal); }
.hero-sub { font-size: 1.1rem; color: var(--muted); max-width: 500px; margin: 0 auto 2rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: 3rem; }

.stats-row {
    display: flex; align-items: center; justify-content: center;
    gap: 0.5rem; flex-wrap: wrap;
}
.stat-card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.2rem 1.5rem;
    text-align: center; min-width: 180px; box-shadow: var(--shadow);
}
.stat-icon { font-size: 2rem; margin-bottom: 0.3rem; }
.stat-label { font-weight: 700; color: var(--navy); font-size: 1rem; }
.stat-desc { color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }
.stat-arrow { font-size: 1.5rem; color: var(--teal); font-weight: 700; }

/* ---- PAGE HEADER ---- */
.page-header {
    margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.75rem; font-weight: 700; color: var(--navy); }
.page-header p { color: var(--muted); margin-top: 0.25rem; }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 1.2rem; border-radius: var(--radius);
    font-size: 0.9rem; font-weight: 600; text-decoration: none;
    border: none; cursor: pointer; transition: all 0.2s;
}
.btn-icon { font-size: 1.1em; }
.btn-primary { background: var(--teal); color: var(--white); }
.btn-primary:hover { background: #0E7490; }
.btn-secondary { background: var(--light); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline { background: transparent; color: var(--white); border: 1px solid rgba(255,255,255,0.3); }
.btn-outline:hover { background: rgba(255,255,255,0.1); }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.82rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- CARDS ---- */
.upload-card, .diagnosis-card, .section-card, .table-card, .agreement-bar-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    position: relative;
    margin-bottom: 1.5rem;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 1.1rem; color: var(--navy); }

/* ---- DROPZONE ---- */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1.5rem;
    display: flex; align-items: center; justify-content: center;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--teal); background: #F0FDFA;
}
.dropzone-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.dropzone-text { font-weight: 600; color: var(--text); font-size: 1.05rem; }
.dropzone-sub { color: var(--muted); font-size: 0.9rem; }
.dropzone-hint { color: var(--muted); font-size: 0.8rem; margin-top: 0.5rem; }

.preview-container { text-align: center; margin-bottom: 1.5rem; }
.preview-image {
    max-width: 100%; max-height: 300px; border-radius: var(--radius);
    border: 1px solid var(--border); margin-bottom: 0.5rem;
}

/* ---- FORMS ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block; font-size: 0.88rem; font-weight: 600;
    color: var(--text); margin-bottom: 0.3rem;
}
.optional { font-weight: 400; color: var(--muted); }
input[type="text"], textarea, select {
    width: 100%; padding: 0.6rem 0.8rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.95rem; font-family: inherit;
    transition: border-color 0.2s;
}
input[type="text"]:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,145,178,0.1);
}

/* ---- DIAGNOSIS BUTTONS ---- */
.diagnosis-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.diag-option { cursor: pointer; }
.diag-option input { display: none; }
.diag-option-content {
    border: 2px solid var(--border); border-radius: var(--radius);
    padding: 1rem; text-align: center; transition: all 0.2s;
}
.benign-option .diag-option-content:hover,
.benign-option.selected .diag-option-content {
    border-color: var(--green); background: #ECFDF5;
}
.cancer-option .diag-option-content:hover,
.cancer-option.selected .diag-option-content {
    border-color: var(--red); background: #FEE2E2;
}
.diag-option-icon { font-size: 1.8rem; display: block; margin-bottom: 0.3rem; }
.diag-option-label { font-weight: 700; font-size: 1.1rem; display: block; }
.diag-option-desc { font-size: 0.8rem; color: var(--muted); display: block; margin-top: 0.2rem; }

.gleason-section {
    background: var(--lighter); border-radius: var(--radius);
    padding: 1rem; margin-bottom: 1rem; border: 1px solid var(--border);
}
.gleason-section .form-grid { grid-template-columns: 1fr 1fr 1fr; }

/* ---- DIAGNOSE LAYOUT ---- */
.diagnose-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
.image-viewer-card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.image-viewer {
    background: #0F172A; padding: 0.5rem; text-align: center;
    min-height: 300px; display: flex; align-items: center; justify-content: center;
}
.image-viewer img { max-width: 100%; max-height: 400px; }
.image-meta {
    display: flex; justify-content: space-between; padding: 0.6rem 1rem;
    font-size: 0.82rem; color: var(--muted); border-top: 1px solid var(--border);
}
.image-notes {
    padding: 0.5rem 1rem 0.75rem; font-size: 0.85rem; color: var(--text);
    border-top: 1px solid var(--border);
}

/* ---- ALREADY DIAGNOSED ---- */
.already-diagnosed { text-align: center; padding: 2rem 1rem; }
.diag-badge {
    display: inline-block; padding: 0.6rem 2rem; border-radius: var(--radius);
    font-size: 1.3rem; font-weight: 800; letter-spacing: 0.05em; margin-bottom: 1rem;
}
.diag-benign { background: #ECFDF5; color: var(--green); }
.diag-cancer { background: #FEE2E2; color: var(--red); }
.diag-notes { color: var(--muted); font-style: italic; }

/* ---- SUCCESS CARD ---- */
.success-card { text-align: center; padding: 2rem 1rem; }
.success-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.success-card h2 { color: var(--green); margin-bottom: 0.5rem; }
.case-id-display { font-size: 1.1rem; margin-bottom: 0.5rem; }
.case-id-display strong { color: var(--navy); font-family: monospace; font-size: 1.2rem; }
.success-actions { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }

/* ---- LOADING ---- */
.loading-overlay {
    position: absolute; inset: 0; background: rgba(255,255,255,0.9);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: var(--radius); z-index: 10;
}
.spinner {
    width: 40px; height: 40px; border: 3px solid var(--border);
    border-top-color: var(--teal); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin-bottom: 0.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- TABLES ---- */
.data-table {
    width: 100%; border-collapse: collapse; font-size: 0.88rem;
}
.data-table thead { background: var(--navy); }
.data-table th {
    color: var(--white); padding: 0.6rem 0.75rem;
    text-align: left; font-weight: 600; font-size: 0.82rem;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.data-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: var(--lighter); }
.data-table code { font-size: 0.82rem; color: var(--navy); font-weight: 600; }

/* ---- PILLS & BADGES ---- */
.badge {
    display: inline-block; padding: 0.15rem 0.6rem; border-radius: 20px;
    font-size: 0.78rem; font-weight: 600;
}
.badge-done { background: #D1FAE5; color: var(--green); }
.badge-pending { background: #FEF3C7; color: #92400E; }
.diag-pill {
    display: inline-block; padding: 0.15rem 0.6rem; border-radius: 4px;
    font-size: 0.8rem; font-weight: 700; letter-spacing: 0.03em;
}
.pill-benign { background: #D1FAE5; color: var(--green); }
.pill-cancer { background: #FEE2E2; color: var(--red); }
.pill-error { background: #FEF3C7; color: var(--orange); }
.text-muted { color: var(--muted); }

.match-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%; font-weight: 700; font-size: 0.85rem;
}
.match-agree { background: #D1FAE5; color: var(--green); }
.match-disagree { background: #FEE2E2; color: var(--red); }
.match-pending { background: #F1F5F9; color: var(--muted); }

/* ---- MINI STATS ---- */
.mini-stats {
    display: flex; gap: 0.75rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.mini-stat {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.75rem 1.25rem;
    text-align: center; flex: 1; min-width: 80px; box-shadow: var(--shadow);
}
.mini-stat-num { font-size: 1.5rem; font-weight: 800; color: var(--navy); display: block; }
.mini-stat-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.mini-stat.pending .mini-stat-num { color: var(--orange); }
.mini-stat.benign .mini-stat-num { color: var(--green); }
.mini-stat.cancer .mini-stat-num { color: var(--red); }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 4rem 2rem; }
.empty-icon { font-size: 4rem; margin-bottom: 1rem; }
.empty-state h2 { color: var(--navy); margin-bottom: 0.5rem; }
.empty-state p { color: var(--muted); margin-bottom: 1.5rem; }

/* ---- FOOTER ---- */
.footer {
    text-align: center; padding: 1.5rem; color: var(--muted);
    font-size: 0.82rem; margin-top: 2rem;
}

/* ============================================================
   ADMIN DASHBOARD
   ============================================================ */
.admin-body { background: #0F172A; }
.admin-body .container { max-width: 1200px; }
.admin-header { margin-bottom: 1.5rem; }
.admin-header h1 { color: var(--white); font-size: 1.75rem; }
.admin-header p { color: rgba(255,255,255,0.6); }

.admin-metrics {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem; margin-bottom: 1.5rem;
}
.metric-card {
    background: #1E293B; border-radius: var(--radius);
    padding: 1rem; text-align: center; border: 1px solid #334155;
}
.metric-value { font-size: 2rem; font-weight: 800; color: var(--white); }
.metric-label { font-size: 0.78rem; color: rgba(255,255,255,0.6); text-transform: uppercase; letter-spacing: 0.05em; }
.metric-sub { font-size: 0.72rem; color: rgba(255,255,255,0.4); margin-top: 0.2rem; }
.metric-agree .metric-value { color: #34D399; }
.metric-flag .metric-value { color: var(--orange); }
.metric-miss .metric-value { color: #F87171; }

.admin-body .section-card {
    background: #1E293B; border-color: #334155; color: var(--white);
}
.admin-body .section-card h2 { color: var(--white); margin-bottom: 0.5rem; }
.admin-body .section-desc { color: rgba(255,255,255,0.6); margin-bottom: 1rem; font-size: 0.9rem; }
.admin-body .table-card { background: #1E293B; border-color: #334155; }
.admin-body .data-table thead { background: #0F172A; }
.admin-body .data-table td { border-color: #334155; color: rgba(255,255,255,0.85); }
.admin-body .data-table tbody tr:hover { background: #334155; }
.admin-body .data-table code { color: #93C5FD; }
.admin-body .text-muted { color: rgba(255,255,255,0.4); }
.disagree-row { background: rgba(220,38,38,0.05); }
.critical-section { border-color: var(--red) !important; border-width: 2px; }
.row-agree { }
.row-disagree td { background: rgba(220,38,38,0.06); }
.row-pending td { opacity: 0.7; }

/* Agreement bar */
.agreement-bar-card { background: #1E293B; border-color: #334155; }
.agreement-bar-card h3 { color: var(--white); margin-bottom: 0.75rem; }
.agreement-bar {
    display: flex; height: 36px; border-radius: var(--radius); overflow: hidden; margin-bottom: 0.75rem;
}
.agree-segment {
    background: #059669; color: white; display: flex;
    align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 700;
}
.flag-segment {
    background: var(--orange); color: white; display: flex;
    align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 700;
}
.miss-segment {
    background: var(--red); color: white; display: flex;
    align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 700;
}
.agreement-legend { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: rgba(255,255,255,0.6); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.agree-dot { background: #059669; }
.flag-dot { background: var(--orange); }
.miss-dot { background: var(--red); }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .hero h1 { font-size: 1.8rem; }
    .stats-row { flex-direction: column; }
    .stat-arrow { transform: rotate(90deg); }
    .form-grid, .gleason-section .form-grid { grid-template-columns: 1fr; }
    .diagnose-layout { grid-template-columns: 1fr; }
    .diagnosis-buttons { grid-template-columns: 1fr; }
    .admin-metrics { grid-template-columns: repeat(2, 1fr); }
    .data-table { font-size: 0.78rem; }
    .navbar { padding: 0 1rem; }
    .container { padding: 1rem; }
}
