/* ========================================
   MedLife Document Upload — Brand Styles
   ======================================== */

:root {
    --color-primary-dark: #002043;
    --color-accent: #024993;
    --color-cta: #009fe3;
    --color-cta-hover: #0088c6;
    --color-error: #e52322;
    --color-success: #28a745;
    --color-warning: #f0ad4e;
    --color-bg: #f5f7fa;
    --color-white: #ffffff;
    --color-text: #333333;
    --color-text-muted: #6c757d;
    --color-border: #dee2e6;
    --color-input-border: #ced4da;
    --color-input-focus: #009fe3;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 2px 8px rgba(0, 32, 67, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 32, 67, 0.12);
    --font: 'Source Sans 3', 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: var(--color-white);
    border-bottom: 2px solid var(--color-cta);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.logo {
    height: 32px;
    width: auto;
}

.nav {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.nav-link:hover {
    background: var(--color-bg);
}

.nav-link.active {
    background: var(--color-cta);
    color: var(--color-white);
}

/* Main */
.main {
    flex: 1;
    padding: 1.5rem 0 3rem;
}

/* Footer */
.footer {
    background: var(--color-primary-dark);
    color: rgba(255, 255, 255, 0.7);
    padding: 1.25rem 0;
    text-align: center;
    font-size: 0.8125rem;
}

/* Page section */
.page-section {
    position: relative;
}

.page-title {
    color: var(--color-primary-dark);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.375rem;
}

.page-subtitle {
    color: var(--color-text-muted);
    font-size: 0.9375rem;
    margin-bottom: 1.75rem;
    line-height: 1.5;
}

/* Card */
.card {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.card-title {
    color: var(--color-primary-dark);
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
}

.card-success {
    text-align: center;
    border: 2px solid var(--color-success);
}

.success-icon {
    width: 56px;
    height: 56px;
    background: var(--color-success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 auto 1rem;
}

/* Form */
.form-group {
    margin-bottom: 1.25rem;
}

.label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-primary-dark);
    margin-bottom: 0.5rem;
}

.input {
    width: 100%;
    padding: 0.75rem;
    font-family: var(--font);
    font-size: 1rem;
    border: 1.5px solid var(--color-input-border);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    min-height: 48px;
}

.input:focus {
    outline: none;
    border-color: var(--color-input-focus);
    box-shadow: 0 0 0 3px rgba(0, 159, 227, 0.15);
}

.input[readonly] {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.input-hint {
    display: block;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-top: 0.375rem;
}

/* File input */
.file-input-wrapper {
    position: relative;
}

.file-input {
    display: none;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 2px dashed var(--color-input-border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--color-accent);
    font-weight: 600;
    transition: border-color 0.2s, background 0.2s;
    text-align: center;
    min-height: 56px;
}

.file-input-label:hover {
    border-color: var(--color-cta);
    background: rgba(0, 159, 227, 0.04);
}

.file-input-label.has-file {
    border-color: var(--color-success);
    background: rgba(40, 167, 69, 0.04);
    color: var(--color-success);
}

.file-preview {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.file-preview img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.file-preview .file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview .file-remove {
    color: var(--color-error);
    cursor: pointer;
    font-weight: 700;
    font-size: 1.25rem;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 600;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
    text-decoration: none;
    line-height: 1.4;
    -webkit-appearance: none;
    min-height: 48px;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--color-cta);
    color: var(--color-white);
    border-color: var(--color-cta);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-cta-hover);
    border-color: var(--color-cta-hover);
}

.btn-outline {
    background: transparent;
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(2, 73, 147, 0.06);
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    min-height: 44px;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.0625rem;
    min-height: 52px;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Alerts */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-top: 1.25rem;
    line-height: 1.5;
}

.alert-error {
    background: rgba(229, 35, 34, 0.08);
    color: var(--color-error);
    border: 1px solid rgba(229, 35, 34, 0.2);
}

.alert-success {
    background: rgba(40, 167, 69, 0.08);
    color: var(--color-success);
    border: 1px solid rgba(40, 167, 69, 0.2);
}

.alert-info {
    background: rgba(0, 159, 227, 0.08);
    color: var(--color-accent);
    border: 1px solid rgba(0, 159, 227, 0.2);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    min-height: 28px;
}

.badge-missing {
    background: rgba(229, 35, 34, 0.1);
    color: var(--color-error);
}

.badge-pending {
    background: rgba(240, 173, 78, 0.15);
    color: #b8860b;
}

.badge-validated {
    background: rgba(40, 167, 69, 0.1);
    color: var(--color-success);
}

.badge-rejected {
    background: var(--color-error);
    color: var(--color-white);
}

.doc-hint {
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--color-error);
}

/* Item card */
.item-card {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--color-cta);
}

.item-header {
    margin-bottom: 1rem;
}

.item-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary-dark);
}

.item-beneficiary {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.doc-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem 0;
    border-top: 1px solid var(--color-border);
}

.doc-row:first-child {
    border-top: none;
}

.doc-info {
    flex: 1;
    min-width: 0;
}

.doc-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.doc-status {
    flex-shrink: 0;
    padding-top: 0.125rem;
}

/* Signature */
.signature-wrapper {
    border: 2px solid var(--color-input-border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    background: var(--color-white);
    overflow: hidden;
    touch-action: none;
}

.signature-wrapper canvas {
    width: 100%;
    height: 200px;
    display: block;
}

/* Text helpers */
.text-muted {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-cta);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    font-weight: 600;
}

/* Status page - item status */
.status-item-card {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.status-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.status-doc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0;
    border-top: 1px solid var(--color-border);
    min-height: 44px;
}

.status-doc-label {
    font-size: 0.875rem;
    color: var(--color-text);
}

/* Back link */
.back-link-wrapper {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.back-link {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    text-decoration: none;
    transition: color 0.2s;
    padding: 0.5rem;
    display: inline-block;
}

.back-link:hover {
    color: var(--color-cta);
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 0 1.25rem;
    }

    .header .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .nav {
        width: 100%;
    }

    .nav-link {
        flex: 1;
        text-align: center;
        justify-content: center;
    }

    .main {
        padding: 1.25rem 0 2.5rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .card, .item-card, .status-item-card {
        padding: 1.25rem;
    }

    .form-group {
        margin-bottom: 1.5rem;
    }

    .doc-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .doc-status {
        align-self: flex-start;
    }
}
