/* Echo Response — FastAPI + HTMX UI */

* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, sans-serif; margin: 0; padding: 0; background: #f8fafc; }

/* Nav */
.nav-main {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.nav-brand { color: white; text-decoration: none; font-weight: 700; }
.nav-links { display: flex; gap: 1rem; }
.nav-links a { color: rgba(255,255,255,0.9); text-decoration: none; }
.nav-links a:hover { color: white; text-decoration: underline; }
.nav-user { margin-left: auto; opacity: 0.9; }
.nav-main button {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
}

/* Content */
.content {
    padding: max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right));
    max-width: 1200px;
    margin: 0 auto;
}
.caption { font-size: 0.9rem; color: #64748b; }
.error { color: #dc2626; }
.warning { color: #d97706; }
.info { color: #0284c7; background: #e0f2fe; padding: 0.75rem; border-radius: 8px; }

/* Buttons */
button, .btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
button:hover, .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
button[type="submit"] { min-height: 48px; }

/* Forms */
form { margin: 1rem 0; }
label { display: block; margin-top: 1rem; font-weight: 500; color: #334155; }
input[type="text"], input[type="password"], select, textarea {
    width: 100%;
    max-width: 400px;
    min-height: 48px;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 0.25rem;
}
textarea { min-height: 120px; max-width: 600px; }
.form-actions { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }

/* Card classes */
.ePCR-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    padding: 1.5rem;
    margin: 1rem 0;
    border: 1px solid #e2e8f0;
}
.ePCR-card-action {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    border-radius: 16px;
    box-shadow: 0 6px 24px rgba(14, 165, 233, 0.35);
    padding: 1.5rem;
    margin: 1rem 0;
    border: none;
}
.ePCR-card-patient {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    padding: 1.25rem;
    margin: 0.75rem 0;
    border-left: 4px solid #0ea5e9;
}
.ePCR-card-cad {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    border-radius: 16px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
    padding: 1.5rem;
    margin: 1rem 0;
}

/* Sticky shift header */
.ePCR-sticky-header {
    position: sticky;
    top: 0;
    z-index: 999;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    padding: 0.5rem 1rem;
    margin: 0 -1rem 1rem -1rem;
    border-radius: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    font-size: 0.9rem;
}

/* Call cards (dispatch queue) */
.call-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    border-radius: 16px;
    padding: 1.25rem;
    margin: 0.75rem 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.call-info { flex: 1; }
.call-meta { font-size: 0.9rem; opacity: 0.95; }
.call-address { font-size: 1.2rem; font-weight: 700; }
.call-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.call-actions form { margin: 0; }
.call-actions button {
    background: rgba(255,255,255,0.25);
    border: 1px solid rgba(255,255,255,0.5);
}

/* Login */
.login-card {
    max-width: 400px;
    margin: 3rem auto;
    padding: 2rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.login-card h1 { margin-top: 0; }

/* Shift form */
.shift-form {
    max-width: 500px;
    margin: 2rem 0;
}
.shift-form .form-actions { display: flex; gap: 1rem; }

/* Footer */
.footer {
    margin-top: 2rem;
    padding: 1rem;
    font-size: 0.85rem;
    color: #64748b;
}

@media (max-width: 768px) {
    .call-card { flex-direction: column; align-items: stretch; }
    input, select, textarea { min-height: 48px !important; font-size: 16px !important; }
}

/* Vital status dots: grey=no history, green=in range, yellow=differs, red=warning */
.vital-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    min-width: 14px;
    min-height: 14px;
    border-radius: 50%;
    margin: 0 3px;
    vertical-align: middle;
    border: 1.5px solid rgba(0,0,0,0.2);
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
    flex-shrink: 0;
}
.vital-dot-grey { background: #94a3b8; }
.vital-dot-green { background: #22c55e; }
.vital-dot-yellow { background: #eab308; }
.vital-dot-red { background: #ef4444; }
.vital-field { position: relative; }
.vital-field .vital-stat { font-size: 0.8rem; color: #64748b; display: block; margin-top: 0.25rem; }

/* Contextual History Panel — 60/40 split, hidden by default */
.intake-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 20px;
    transition: all 0.3s ease;
    align-items: flex-start;
}
.form-column { flex: 0 1 60%; min-width: 0; transition: flex 0.3s ease; }
.form-column.form-full-width { flex: 1 1 100%; }
.history-column {
    flex: 0 1 40%;
    min-width: 280px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid #0056b3;
    transition: all 0.3s ease;
}
.history-column.hidden { display: none !important; }
@media (max-width: 768px) {
    .intake-container { flex-direction: column; flex-wrap: wrap; }
    .history-column { min-width: unset; flex: 1 1 auto; }
}
.history-toggle-btn {
    margin-bottom: 15px;
    cursor: pointer;
    background: #e9ecef;
    border: 1px solid #ccc;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
}
.history-toggle-btn:hover { background: #dee2e6; }
.history-column .ePCR-card { margin: 0 0 1rem 0; }
.history-column table { width: 100%; font-size: 0.85rem; border-collapse: collapse; }
.history-column th, .history-column td { padding: 0.35rem 0.5rem; text-align: left; border-bottom: 1px solid #e2e8f0; }
.history-column th { font-weight: 600; color: #475569; }

/* Expandable section above forms (alternative, starts collapsed) */
.history-above {
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4fc 100%);
    border-radius: 8px;
    border: 1px solid #b8d4e8;
    border-left: 4px solid #0056b3;
    box-shadow: 0 1px 3px rgba(0,86,179,0.08);
}
.history-above summary {
    cursor: pointer;
    padding: 12px 18px;
    font-weight: 600;
    font-size: 1rem;
    user-select: none;
    list-style: none;
}
.history-above summary::-webkit-details-marker { display: none; }
.history-above summary::before { content: "▶ "; font-size: 0.85em; color: #0056b3; }
.history-above[open] summary::before { content: "▼ "; }
.history-above .history-content {
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    max-height: 60vh;
    overflow-y: auto;
}
.history-above .ePCR-card { margin: 0 0 1rem 0; }
.history-above table { width: 100%; font-size: 0.85rem; border-collapse: collapse; }
.history-above th, .history-above td { padding: 0.35rem 0.5rem; text-align: left; border-bottom: 1px solid #e2e8f0; }
.history-above th { font-weight: 600; color: #475569; }

/* Vitals delta indicator dots (no text, color only) */
.dot-stable, .dot-low-change, .dot-high-change, .dot-unknown {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
}
.dot-stable, .vital-delta-dot.dot-stable { background-color: #198754; }
.dot-low-change, .vital-delta-dot.dot-low-change { background-color: #f59e0b; }
.dot-high-change, .vital-delta-dot.dot-high-change { background-color: #dc2626; }
.dot-unknown, .vital-delta-dot.dot-unknown { background-color: #adb5bd; }
.vital-delta-dot { margin-left: 6px; }

