/* NarraMedic Stylesheet */

/* =====================
   CSS Variables
   ===================== */
:root {
    --primary: #1a56db;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary: #ffffff;
    --accent: #dc2626;
    --success: #22c55e;
    --text-dark: #1f2937;
    --text-muted: #6b7280;
    --bg-light: #f3f4f6;
    --bg-card: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

/* =====================
   Reset & Base
   ===================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-dark);
    background: var(--bg-light);
}

/* =====================
   Splash Screen
   ===================== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 1s ease;
}

.splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.splash-logo {
    position: relative;
    z-index: 1;
    max-width: 400px;
    width: 80%;
    height: auto;
    filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.3));
}

/* =====================
   Login Page
   ===================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.login-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.login-background .bg-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.login-container {
    position: relative;
    z-index: 10;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.login-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.login-header .tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--accent);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    text-align: center;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.btn-login {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.3);
}

.btn-login:active {
    transform: translateY(0);
}

/* =====================
   Home Page
   ===================== */
.home-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.home-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.home-background .bg-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.15;
}

/* Header */
.main-header {
    position: relative;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, rgba(26, 86, 219, 0.95) 0%, rgba(30, 64, 175, 0.95) 100%);
    box-shadow: var(--shadow);
}

.header-logo {
    height: 60px;
    width: auto;
}

.btn-logout {
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary);
    background: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.btn-logout:hover {
    background: var(--bg-light);
    transform: translateY(-1px);
}

/* Main Content */
.main-content {
    position: relative;
    z-index: 10;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.upload-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
}

.upload-zone {
    border: 2px dashed #d1d5db;
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--primary);
    background: rgba(26, 86, 219, 0.05);
}

.upload-zone.drag-over {
    border-style: solid;
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 1rem;
}

.upload-zone h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.upload-zone p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.upload-info {
    margin-top: 1rem;
    text-align: center;
}

.upload-info p {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* =====================
   Results Modal
   ===================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-backdrop.visible {
    display: flex;
    opacity: 1;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 1200px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-backdrop.visible .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    flex-shrink: 0;
}

.modal-logo {
    width: 40px;
    height: 40px;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    flex: 1;
    padding: 1.5rem;
    overflow: hidden;
    min-height: 0;
}

.results-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    height: 100%;
}

.column {
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.column > h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    padding: 1.25rem 1.25rem 0.75rem 1.25rem;
    border-bottom: 2px solid var(--primary);
    flex-shrink: 0;
}

/* Left Column - Parsed Fields */
.left-column .fields-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.left-column .fields-content::-webkit-scrollbar {
    display: none;
}

.fields-content {
    font-size: 0.9rem;
}

.field-section {
    margin-bottom: 1.5rem;
}

.field-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.field-row {
    margin-bottom: 0.375rem;
    line-height: 1.4;
}

.field-label {
    font-weight: 500;
    color: var(--text-muted);
}

.field-value {
    color: var(--text-dark);
}

.vitals-set {
    background: white;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--primary);
}

.vitals-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.vital-item {
    margin-right: 1rem;
    white-space: nowrap;
}

.med-row, .proc-row {
    background: white;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.375rem;
    font-size: 0.85rem;
}

.narrative-section {
    background: #fef3c7;
    padding: 1rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid #f59e0b;
}

.narrative-section h3 {
    color: #92400e;
    border-bottom-color: #f59e0b;
}

.narrative-text {
    color: var(--text-dark);
    line-height: 1.6;
}

/* Right Column - Generated Narrative */
.right-column .narrative-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.right-column .narrative-content::-webkit-scrollbar {
    display: none;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    margin-top: 1rem;
    color: var(--text-muted);
    font-weight: 500;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.narrative-result {
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    line-height: 1.7;
    color: var(--text-dark);
    white-space: pre-wrap;
    border-left: 4px solid var(--success);
}

.narrative-result.error {
    border-left-color: var(--accent);
    background: #fef2f2;
    color: var(--accent);
}

/* =====================
   Responsive
   ===================== */
@media (max-width: 900px) {
    .results-columns {
        grid-template-columns: 1fr;
    }

    .column {
        max-height: 40vh;
    }
}

@media (max-width: 600px) {
    .main-header {
        padding: 0.75rem 1rem;
    }

    .header-logo {
        height: 45px;
    }

    .login-card {
        padding: 1.5rem;
        margin: 1rem;
    }

    .upload-zone {
        padding: 2rem 1rem;
    }

    .modal-body {
        padding: 1rem;
    }
}

/* =====================
   Utility
   ===================== */
.hidden {
    display: none !important;
}
