/* ======================== RESET & BASE ======================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(17, 24, 39, 0.9);

    --border: rgba(99, 179, 237, 0.12);
    --border-active: rgba(99, 179, 237, 0.35);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-blue: #38bdf8;
    --accent-teal: #2dd4bf;
    --accent-purple: #a78bfa;
    --accent-green: #34d399;
    --accent-amber: #fbbf24;
    --accent-red: #f87171;

    --gradient-main: linear-gradient(135deg, #38bdf8, #2dd4bf);
    --gradient-warm: linear-gradient(135deg, #fbbf24, #f97316);
    --gradient-purple: linear-gradient(135deg, #a78bfa, #818cf8);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(56, 189, 248, 0.15);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ======================== BACKGROUND EFFECTS ======================== */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(rgba(99, 179, 237, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 179, 237, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
}

.bg-glow-1 {
    width: 500px;
    height: 500px;
    top: -150px;
    right: -100px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.08), transparent 70%);
}

.bg-glow-2 {
    width: 400px;
    height: 400px;
    bottom: -100px;
    left: -100px;
    background: radial-gradient(circle, rgba(45, 212, 191, 0.06), transparent 70%);
}

/* ======================== HEADER ======================== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--gradient-main);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-primary);
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.logo-accent {
    color: var(--accent-teal);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-amber);
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.ready {
    background: var(--accent-green);
    animation: none;
}

.status-dot.error {
    background: var(--accent-red);
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ======================== MAIN ======================== */
.main {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

/* ======================== HERO ======================== */
.hero {
    text-align: center;
    padding: 60px 0 48px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    border-radius: 100px;
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.2);
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-blue);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -1px;
    margin-bottom: 16px;
}

.gradient-text {
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    max-width: 600px;
    margin: 0 auto;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* ======================== INPUT SECTION ======================== */
.input-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .input-section {
        grid-template-columns: 1fr;
    }
}

/* ======================== CARDS ======================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    backdrop-filter: blur(10px);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.card:hover {
    border-color: var(--border-active);
    box-shadow: var(--shadow-glow);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

/* ======================== DROPZONE ======================== */
.dropzone {
    border: 2px dashed rgba(99, 179, 237, 0.2);
    border-radius: var(--radius-md);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
    position: relative;
    overflow: hidden;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.04);
}

.dropzone-content {
    text-align: center;
    padding: 24px;
}

.dropzone-icon {
    color: var(--text-muted);
    margin-bottom: 12px;
    transition: color 0.3s, transform 0.3s;
}

.dropzone:hover .dropzone-icon {
    color: var(--accent-blue);
    transform: translateY(-4px);
}

.dropzone-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
}

.dropzone-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Preview */
.preview-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.image-preview {
    width: 100%;
    height: 200px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: #000;
}

.remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(248, 113, 113, 0.9);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.remove-btn:hover {
    transform: scale(1.15);
}

/* ======================== HISTORY INPUT ======================== */
.history-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    resize: vertical;
    transition: border-color 0.3s;
    line-height: 1.6;
}

.history-input::placeholder {
    color: var(--text-muted);
}

.history-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.08);
}

.input-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ======================== GENERATE BUTTON ======================== */
.generate-section {
    text-align: center;
    margin-bottom: 40px;
}

.generate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 220px;
    height: 52px;
    padding: 0 32px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--gradient-main);
    color: var(--bg-primary);
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.3s, opacity 0.3s;
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.3);
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(56, 189, 248, 0.4);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(0);
}

.generate-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-content,
.btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.generate-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 10px;
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(10, 14, 26, 0.3);
    border-top-color: var(--bg-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ======================== REPORT SECTION ======================== */
.report-section {
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.report-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-blue);
}

.report-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.report-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Report Grid */
.report-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 20px;
}

/* Report Cards */
.report-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: fadeInUp 0.5s ease both;
}

.report-card:nth-child(2) {
    animation-delay: 0.1s;
}

.report-card:nth-child(3) {
    animation-delay: 0.2s;
}

.report-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.report-card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.report-card-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.findings-icon {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-blue);
}

.impression-icon {
    background: rgba(52, 211, 153, 0.1);
    color: var(--accent-green);
}

.recommendations-icon {
    background: rgba(251, 191, 36, 0.1);
    color: var(--accent-amber);
}

.report-card-body {
    padding: 16px 20px;
}

.report-card-body ol,
.report-card-body ul {
    padding-left: 0;
    list-style: none;
}

.report-card-body li {
    position: relative;
    padding: 8px 0 8px 24px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(99, 179, 237, 0.05);
}

.report-card-body li:last-child {
    border-bottom: none;
}

.report-card-body li::before {
    position: absolute;
    left: 0;
    top: 10px;
    font-weight: 700;
    font-size: 13px;
}

.findings-card li::before {
    content: counter(finding) ".";
    counter-increment: finding;
    color: var(--accent-blue);
}

.findings-card ol {
    counter-reset: finding;
}

.impression-card li::before {
    content: "→";
    color: var(--accent-green);
}

.recommendations-card li::before {
    content: "•";
    color: var(--accent-amber);
}

/* No findings placeholder */
.no-data {
    font-size: 14px;
    color: var(--text-muted);
    font-style: italic;
    padding: 8px 0;
}

/* ======================== DISCLAIMER ======================== */
.disclaimer {
    background: rgba(248, 113, 113, 0.06);
    border: 1px solid rgba(248, 113, 113, 0.15);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    font-size: 13px;
    line-height: 1.6;
    color: rgba(248, 113, 113, 0.8);
    margin-bottom: 16px;
}

/* ======================== RAW OUTPUT ======================== */
.raw-output {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.raw-output summary {
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.raw-output summary:hover {
    color: var(--text-secondary);
}

.raw-text {
    padding: 16px 20px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

/* ======================== FOOTER ======================== */
.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 32px 24px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}

.footer strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.footer-disclaimer {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.7;
}

/* ======================== MEDICAL DOCUMENT / PDF STYLING ======================== */
.report-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.pdf-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: var(--accent-blue);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.2s;
}

.pdf-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    transform: translateY(-1px);
}

.pdf-btn:active {
    transform: translateY(0);
}

.medical-document {
    background: #ffffff;
    color: #111827;
    border-radius: var(--radius-md);
    padding: 40px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    position: relative;
    overflow: hidden;
}

.medical-document::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: var(--gradient-main);
}

.doc-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 24px;
    margin-bottom: 24px;
    text-align: center;
}

.doc-logo {
    font-size: 24px;
    font-weight: 800;
    color: #0ea5e9;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.doc-title {
    font-size: 18px;
    font-weight: 700;
    color: #334155;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.doc-date {
    font-size: 14px;
    color: #64748b;
}

.doc-patient-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 32px;
}

.info-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-group.full-width {
    grid-column: 1 / -1;
}

.info-label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 15px;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.5;
}

.doc-body {
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin-bottom: 40px;
}

.doc-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #0284c7;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #cbd5e1;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.doc-section-content {
    font-size: 15px;
    line-height: 1.7;
    color: #334155;
    padding-left: 8px;
}

.doc-section-content ol,
.doc-section-content ul {
    padding-left: 20px;
    margin: 8px 0;
}

.doc-section-content li {
    margin-bottom: 8px;
}

.impression-prose {
    font-size: 15px;
    line-height: 1.8;
    color: #334155;
    text-align: justify;
    margin: 4px 0;
}

.doc-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid #e2e8f0;
}

.doc-footer .disclaimer {
    max-width: 60%;
    margin: 0;
    background: transparent;
    border: none;
    padding: 0;
    font-size: 12px;
    color: #ef4444;
    font-weight: 500;
}

.doc-signature {
    text-align: right;
    width: 300px;
}

.sig-line {
    border-bottom: 1px solid #94a3b8;
    height: 40px;
    margin-bottom: 8px;
}

.sig-name {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
}

.sig-title {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 2px;
}

.sig-model {
    font-size: 11px;
    color: #94a3b8;
    font-style: italic;
}

/* ======================== RESPONSIVE ======================== */
@media (max-width: 640px) {
    .header-inner {
        height: 56px;
    }

    .hero {
        padding: 40px 0 32px;
    }

    .hero-title {
        font-size: 1.8rem;
    }

    .input-section {
        gap: 16px;
    }

    .card {
        padding: 16px;
    }

    .report-card-body {
        padding: 12px 16px;
    }
}