/* Pacific Referral Intake — Internal Tool UI */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e2e5ea;
    --text: #1a1d23;
    --text-secondary: #5f6672;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accept: #059669;
    --accept-bg: #d1fae5;
    --transfer: #dc2626;
    --transfer-bg: #fee2e2;
    --escalate: #d97706;
    --escalate-bg: #fef3c7;
    --info: #2563eb;
    --info-bg: #dbeafe;
    --pending: #6b7280;
    --pending-bg: #f3f4f6;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Navigation */
.topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}

.nav-links { display: flex; gap: 0.25rem; }

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-links a:hover { background: var(--bg); color: var(--text); }
.nav-links a.active { background: var(--primary); color: white; }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem; }

/* Page header */
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.subtitle { color: var(--text-secondary); margin-top: 0.25rem; }
.back-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-block;
    margin-bottom: 0.5rem;
}
.back-link:hover { text-decoration: underline; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.8rem; background: var(--bg); color: var(--primary); border: 1px solid var(--border); }
.btn-small:hover { background: var(--primary); color: white; }

/* Upload area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: var(--surface);
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: #f0f4ff;
}

.upload-icon { color: var(--text-secondary); margin-bottom: 1rem; }
.upload-text { font-size: 1.1rem; font-weight: 600; }
.upload-sub { color: var(--text-secondary); font-size: 0.85rem; margin-top: 0.25rem; }

/* File list */
.file-list {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow);
}

.file-list h3 { font-size: 0.95rem; margin-bottom: 0.75rem; }
.file-list ul { list-style: none; margin-bottom: 1rem; }
.file-list li { padding: 0.4rem 0; color: var(--text-secondary); font-size: 0.9rem; }

/* Progress */
.progress-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    box-shadow: var(--shadow);
    margin-top: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-sub { color: var(--text-secondary); font-size: 0.85rem; margin-top: 0.5rem; }

/* Result cards */
.result-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
}

.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.filename { font-weight: 600; font-size: 0.95rem; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-lg { font-size: 0.85rem; padding: 0.3rem 0.9rem; }
.badge-admit { background: #d1fae5; color: #065f46; font-weight: 700; }
.badge-accept { background: var(--accept-bg); color: var(--accept); }
.badge-transfer { background: var(--transfer-bg); color: var(--transfer); }
.badge-escalate { background: var(--escalate-bg); color: var(--escalate); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-review { background: #fef3c7; color: #92400e; }
.badge-admin { background: #ffedd5; color: #9a3412; }
.badge-red { background: #fee2e2; color: #991b1b; font-weight: 700; }
.badge-pending { background: var(--pending-bg); color: var(--pending); }
.badge-error { background: var(--transfer-bg); color: var(--transfer); }
.badge-default { background: var(--pending-bg); color: var(--pending); }

/* Queue */
.queue-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.search-box input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    width: 280px;
    outline: none;
}

.search-box input:focus { border-color: var(--primary); }

.filter-tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }

.filter-btn {
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.filter-btn:hover { background: var(--bg); }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Queue table */
.queue-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.queue-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.queue-table td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

.queue-table tr:last-child td { border-bottom: none; }
.queue-table tr:hover { background: #f8f9fb; }
.filename-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Loading & empty */
.loading { text-align: center; padding: 3rem; color: var(--text-secondary); }
.empty-state { text-align: center; padding: 3rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-state p { margin-bottom: 1rem; color: var(--text-secondary); }
.error-text { color: var(--transfer); }

/* Review page */
.status-banner {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.status-main, .final-status-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.status-label { font-weight: 600; font-size: 0.9rem; color: var(--text-secondary); }
.confidence-label { font-size: 0.85rem; color: var(--text-secondary); margin-left: 1rem; }
.reviewed-info { font-size: 0.8rem; color: var(--text-secondary); margin-left: auto; }

.review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .review-grid { grid-template-columns: 1fr; }
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }

.field-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.field-row { display: flex; justify-content: space-between; padding: 0.3rem 0; }
.field-label { font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }
.field-value { font-size: 0.85rem; font-weight: 600; text-align: right; max-width: 60%; }

.explanation-text {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    padding: 1rem;
    border-radius: 6px;
}

/* Rules lists */
.rules-list { list-style: none; }
.rules-list li {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.rules-list.failed li { background: var(--transfer-bg); color: var(--transfer); }
.rules-list.warning li { background: var(--escalate-bg); color: var(--escalate); }
.rules-list.info li { background: var(--info-bg); color: var(--info); }
.rules-list.green li { background: #d1fae5; color: #065f46; }
.rules-list.red li { background: #fee2e2; color: #991b1b; font-weight: 600; }

/* Rule detail table */
.rule-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.rule-table th { text-align: left; padding: 0.5rem; color: var(--text-secondary); font-weight: 600; border-bottom: 1px solid var(--border); }
.rule-table td { padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.rule-pass td { background: #f0fdf4; }
.rule-fail td { background: #fef2f2; }
.pass-icon { color: var(--accept); font-weight: 700; font-size: 0.75rem; }
.fail-icon { color: var(--transfer); font-weight: 700; font-size: 0.75rem; }

/* Decision form */
.decision-note {
    background: var(--escalate-bg);
    color: var(--escalate);
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.decision-form { display: flex; flex-direction: column; gap: 0.75rem; }
.decision-form label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }

.decision-form select,
.decision-form input,
.decision-form textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}

.decision-form select:focus,
.decision-form input:focus,
.decision-form textarea:focus { border-color: var(--primary); }

/* Audit log */
.audit-log { display: flex; flex-direction: column; gap: 0.4rem; }
.audit-entry {
    display: flex;
    gap: 0.75rem;
    padding: 0.4rem 0;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.audit-action { font-weight: 600; text-transform: uppercase; font-size: 0.7rem; background: var(--bg); padding: 0.15rem 0.5rem; border-radius: 4px; }
.audit-time { color: var(--text-secondary); }
.audit-actor { color: var(--text-secondary); margin-left: auto; }

/* Utility */
ul { list-style-position: inside; }
ul li { font-size: 0.85rem; padding: 0.2rem 0; }
