/* MediScan AI - Enterprise Clinical UI Design System */
:root {
    --font-heading: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Color Palette */
    --primary: #1055B7;
    --primary-hover: #0C4394;
    --primary-light: #EBF3FF;
    --navy-dark: #0B192C;
    --teal-accent: #00A896;
    --teal-light: #E6F7F5;

    --surface-bg: #F8FAFC;
    --surface-card: #FFFFFF;
    --surface-muted: #F1F5F9;

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;

    --border-subtle: #E2E8F0;
    --border-accent: #CBD5E1;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);
    --shadow-brand: 0 12px 30px rgba(16, 85, 183, 0.2);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-pill: 9999px;
}

/* Global Reset & Base */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background-color: var(--surface-bg);
    background-image: 
        radial-gradient(at 0% 0%, rgba(16, 85, 183, 0.03) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 168, 150, 0.04) 0px, transparent 50%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .brand-name {
    font-family: var(--font-heading);
}

.cursor-pointer {
    cursor: pointer;
}

/* Header & Navbar */
.app-header .navbar {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle) !important;
    padding: 0.75rem 0;
}

.navbar-brand {
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
    text-decoration: none !important;
    padding: 0;
    margin: 0;
}

.brand-logo-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    background: linear-gradient(135deg, var(--primary) 0%, #0088B4 100%);
    color: #fff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 4px 12px rgba(16, 85, 183, 0.25);
    flex-shrink: 0;
}

.brand-text-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.15;
}

.brand-name {
    font-weight: 800;
    font-size: 1.35rem;
    color: var(--navy-dark);
    letter-spacing: -0.02em;
    margin: 0;
    padding: 0;
}

.brand-accent {
    color: var(--primary);
}

.brand-tagline {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 1px;
}

.nav-link {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-secondary) !important;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary) !important;
    background: var(--primary-light);
}

/* App Main Content */
.app-main {
    flex: 1;
}

/* Shell & Hero Layout */
.prescription-shell {
    max-width: 960px;
    margin: 2rem auto 3.5rem;
    padding: 0 1rem;
}

.hero-title {
    font-size: clamp(1.75rem, 3.8vw, 2.5rem);
    font-weight: 800;
    color: var(--navy-dark);
    letter-spacing: -0.03em;
    line-height: 1.25;
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    font-size: clamp(0.95rem, 1.6vw, 1.1rem);
    color: var(--text-secondary);
    max-width: 680px;
    line-height: 1.6;
    margin-bottom: 1.75rem;
}

/* Main Workspace Card */
.enterprise-card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.enterprise-card__header {
    padding: 1.25rem 1.75rem;
    background: linear-gradient(180deg, #FFFFFF 0%, var(--surface-muted) 100%);
    border-bottom: 1px solid var(--border-subtle);
}

.header-meta h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    color: var(--navy-dark);
}

.header-meta p {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin: 0.2rem 0 0;
}

.enterprise-card__body {
    padding: 1.75rem;
}

/* Upload Picker (merged upload button) */
.intake-toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

/* Picker wrapper — keeps menu anchored to the button */
.upload-picker-wrapper {
    position: relative;
    flex: 1;
    min-width: 180px;
}

.btn-intake-option {
    width: 100%;
    padding: 0.85rem 1.25rem;
    border: 2px solid var(--border-subtle);
    background: var(--surface-card);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
    font-weight: 650;
    font-size: 0.95rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-intake-option:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-intake-option.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 85, 183, 0.15);
}

/* Chevron rotates when menu is open */
.upload-picker-chevron {
    transition: transform 0.2s ease;
    font-size: 0.85rem;
}

.upload-source-menu.open ~ * .upload-picker-chevron,
#btnUploadImage[aria-expanded="true"] .upload-picker-chevron {
    transform: rotate(180deg);
}

/* Dropdown source menu */
.upload-source-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    overflow: hidden;
    animation: menuSlideIn 0.18s ease;
}

.upload-source-menu.open {
    display: block;
}

@keyframes menuSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.upload-source-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.9rem 1.1rem;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
    color: var(--text-primary);
}

.upload-source-item:hover {
    background: var(--primary-light);
}

.upload-source-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.upload-source-item:hover .upload-source-icon {
    background: var(--primary);
    color: #fff;
}

.upload-source-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    line-height: 1.3;
}

.upload-source-text strong {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--navy-dark);
}

.upload-source-text small {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.upload-source-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 0;
}

/* Upload Drop Zone */
.drop-zone {
    border: 2px dashed #B0C4DE;
    border-radius: var(--radius-md);
    background: #FAFCFF;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(0.995);
}

.drop-zone__icon-wrapper {
    width: 60px;
    height: 60px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.75rem;
    margin-bottom: 1rem;
    transition: transform 0.2s ease;
}

.drop-zone:hover .drop-zone__icon-wrapper {
    transform: translateY(-4px);
    background: var(--primary);
    color: #fff;
}

.drop-zone__title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--navy-dark);
    margin-bottom: 0.25rem;
}

.drop-zone__hint {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.drop-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Compact Selected Image Preview Bar with Icon */
.selected-preview-card {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    background: var(--surface-card);
    margin-top: 1rem;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.selected-preview-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.preview-icon-wrapper {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.preview-filename {
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--navy-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Form Action Bar */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.btn-enterprise-submit {
    min-width: 220px;
    height: 52px;
    padding: 0 1.75rem;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    font-weight: 700;
    font-size: 1.02rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    box-shadow: var(--shadow-brand);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
}

.btn-enterprise-submit:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 16px 35px rgba(16, 85, 183, 0.35);
}

.btn-enterprise-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Live WebRTC Camera Modal */
.camera-modal .modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    background: #0D1117;
    color: #fff;
}

.camera-modal .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.25rem 1.5rem;
}

.camera-modal .modal-title {
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
}

.camera-viewport-container {
    position: relative;
    width: 100%;
    height: 420px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#cameraVideo, #cameraCanvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-viewfinder-overlay {
    position: absolute;
    inset: 20px;
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px;
}

.viewfinder-corner {
    width: 24px;
    height: 24px;
    border-color: var(--teal-accent);
    border-style: solid;
}

.camera-controls-bar {
    padding: 1.25rem;
    background: #161B22;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.btn-shutter {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid var(--primary);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    color: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2);
    transition: transform 0.15s ease, background 0.2s ease;
    margin: 0 auto;
}

.btn-shutter:hover {
    transform: scale(1.08);
    background: var(--primary-light);
}

.btn-shutter:active {
    transform: scale(0.92);
}

/* Results Display Modal */
.results-modal .modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
    overflow: hidden;
}

.results-modal .modal-header {
    background: linear-gradient(135deg, var(--navy-dark) 0%, #172B4D 100%);
    color: #fff;
    padding: 1.5rem 1.75rem;
    border: none;
}

.results-modal .modal-title {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
}

.results-modal .modal-body {
    padding: 2rem;
    background: var(--surface-bg);
}

.results-card {
    background: #fff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.result-badge-counter {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    background: var(--teal-light);
    color: #007A6D;
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: var(--radius-pill);
    margin-bottom: 1.25rem;
}

.test-items-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.test-item-card {
    padding: 0.85rem 1.15rem;
    background: var(--surface-muted);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-weight: 650;
    font-size: 0.98rem;
    color: var(--navy-dark);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.doctor-notes-box {
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    font-size: 0.92rem;
    color: #92400E;
    margin-top: 1rem;
}

.modal-footer-custom {
    padding: 1.25rem 1.75rem;
    background: #fff;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Footer Styling */
.app-footer {
    background: var(--navy-dark);
    color: #94A3B8;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: auto;
    font-size: 0.88rem;
}

.footer-brand {
    color: #fff;
    font-size: 0.95rem;
}

/* Responsive Rules for Mobile and Tablet Devices */
@media (max-width: 768px) {
    .prescription-shell {
        margin-top: 1.25rem;
        margin-bottom: 2rem;
    }

    .enterprise-card__header {
        padding: 1rem 1.25rem;
    }

    .enterprise-card__body {
        padding: 1.25rem;
    }

    .intake-toolbar {
        flex-direction: column;
    }

    .btn-intake-option {
        width: 100%;
    }

    .action-bar {
        justify-content: stretch;
    }

    .btn-enterprise-submit {
        width: 100%;
    }

    .camera-viewport-container {
        height: 320px;
    }

    .modal-footer-custom {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-footer-custom .btn {
        width: 100%;
    }
}
