/* =============================================================
   NHS Reorder — Frontend Styles
   ============================================================= */

/* ── Two-column app layout ───────────────────────────────────── */
#nhs-reorder-app.nhs-two-col {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 2rem;
    align-items: start;
    max-width: 1140px;
}
@media (max-width: 900px) {
    #nhs-reorder-app.nhs-two-col {
        grid-template-columns: 1fr;
    }
    .nhs-col-requests {
        order: -1; /* past requests above form on mobile */
    }
}

/* ── Column headings ─────────────────────────────────────────── */
.nhs-col-heading h2 {
    font-size: 1.2rem;
    margin: 0 0 0.4rem;
    color: #1a1a2e;
    font-weight: 700;
}
.nhs-col-heading .nhs-intro {
    color: #555;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ── Section blocks ─────────────────────────────────────────── */
.nhs-section {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.nhs-section h3 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1a1a2e;
}
.nhs-section .description {
    color: #666;
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
}

/* ── Fields ─────────────────────────────────────────────────── */
.nhs-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.nhs-field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #444;
}
.nhs-field input[type="text"],
.nhs-field input[type="number"],
.nhs-field input[type="email"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.875rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.nhs-field input:focus { outline: none; border-color: #005eb8; box-shadow: 0 0 0 2px rgba(0,94,184,0.15); }

/* ── Medication rows ─────────────────────────────────────────── */
.nhs-med-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 8px;
    background: #f8f9fc;
    border: 1px solid #e8eaf0;
    border-radius: 5px;
    padding: 10px 8px;
}
.nhs-med-fields {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
@media (max-width: 680px) {
    .nhs-med-fields { grid-template-columns: 1fr 1fr; }
    .nhs-field--med { grid-column: span 2; }
}
.nhs-remove-row {
    background: none; border: 1px solid #ccc; border-radius: 4px;
    color: #999; cursor: pointer; font-size: 1rem; line-height: 1;
    padding: 6px 10px; flex-shrink: 0; transition: all 0.15s; align-self: flex-end;
}
.nhs-remove-row:hover { border-color: #c00; color: #c00; background: #fff0f0; }
.nhs-remove-row:disabled, .nhs-hidden { visibility: hidden; }
.nhs-add-btn { margin-top: 6px; font-size: 0.875rem !important; }

/* ── Autocomplete (medication search) ───────────────────────── */
.nhs-autocomplete-wrap { position: relative; }
.nhs-autocomplete-list {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 9999;
    background: #fff; border: 1px solid #ccc; border-top: none;
    border-radius: 0 0 4px 4px; max-height: 200px; overflow-y: auto;
    list-style: none; margin: 0; padding: 0; box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.nhs-autocomplete-list[hidden] { display: none; }
.nhs-ac-item {
    padding: 8px 12px; cursor: pointer; font-size: 0.85rem;
    border-bottom: 1px solid #f0f0f0; color: #222;
}
.nhs-ac-item:hover, .nhs-ac-item:focus { background: #f0f5ff; outline: none; }
.nhs-ac-item--loading, .nhs-ac-item--empty { color: #999; font-style: italic; cursor: default; }
.nhs-ac-item--loading:hover, .nhs-ac-item--empty:hover { background: #fff; }

/* ── GP Surgery Browsable Dropdown ──────────────────────────── */
#nhs-gp-select-wrap { position: relative; }
.nhs-gp-input-wrap { position: relative; display: flex; align-items: center; }
.nhs-gp-input-wrap input {
    width: 100%; padding: 9px 36px 9px 10px; border: 1px solid #ccc; border-radius: 4px;
    font-size: 0.875rem; box-sizing: border-box; cursor: pointer;
    transition: border-color 0.2s;
}
.nhs-gp-input-wrap input:focus { outline: none; border-color: #005eb8; box-shadow: 0 0 0 2px rgba(0,94,184,0.15); }
.nhs-gp-arrow {
    position: absolute; right: 10px; pointer-events: none; color: #888; font-size: 0.75rem;
}
.nhs-gp-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 9999;
    background: #fff; border: 1px solid #ccc; border-radius: 5px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.13); max-height: 280px; overflow: hidden;
    display: flex; flex-direction: column;
}
.nhs-gp-dropdown[hidden] { display: none; }
.nhs-gp-list {
    list-style: none; margin: 0; padding: 4px 0;
    overflow-y: auto; max-height: 280px;
}
.nhs-gp-item {
    padding: 9px 14px; cursor: pointer; font-size: 0.875rem;
    border-bottom: 1px solid #f5f5f5; color: #1d2327;
}
.nhs-gp-item strong { display: block; font-weight: 600; color: #1a1a2e; }
.nhs-gp-item small { display: block; font-size: 0.75rem; color: #888; margin-top: 2px; }
.nhs-gp-item:hover, .nhs-gp-item:focus { background: #f0f5ff; outline: none; }
.nhs-gp-item:last-child { border-bottom: none; }

/* ── GP selected tag ─────────────────────────────────────────── */
.nhs-selected-tag {
    display: inline-flex; align-items: center; gap: 8px;
    background: #e8f1fb; border: 1px solid #b3d0f5; border-radius: 20px;
    padding: 6px 14px; font-size: 0.875rem; color: #003d82; margin-top: 8px;
    max-width: 100%;
}
.nhs-selected-tag[hidden] { display: none; }
.nhs-selected-tag__label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nhs-selected-tag__remove { background: none; border: none; cursor: pointer; color: #888; font-size: 1.1rem; padding: 0; line-height: 1; }
.nhs-selected-tag__remove:hover { color: #c00; }

/* ── Radio buttons ───────────────────────────────────────────── */
.nhs-radio-group { display: flex; flex-direction: column; gap: 7px; }
.nhs-radio-label {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    font-size: 0.9rem; padding: 9px 12px; border: 1px solid #e0e0e0;
    border-radius: 5px; transition: border-color 0.15s; max-width: 400px;
}
.nhs-radio-label:has(input:checked) { border-color: #005eb8; background: #f0f5ff; }
.nhs-radio-label input[type="radio"] { accent-color: #005eb8; width: 16px; height: 16px; flex-shrink: 0; }

/* ── Exemptions ─────────────────────────────────────────────── */
#nhs-exemptions-wrap { margin-top: .75rem; padding-top: .75rem; border-top: 1px solid #ebebeb; }
#nhs-exemptions-wrap[hidden] { display: none; }
.nhs-exemption-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 6px; }
@media (max-width: 600px) { .nhs-exemption-grid { grid-template-columns: 1fr; } }
.nhs-exemption-item {
    display: flex; align-items: flex-start; gap: 7px; padding: 7px 10px;
    border: 1px solid #e0e0e0; border-radius: 4px; cursor: pointer; font-size: 0.8rem; line-height: 1.4;
}
.nhs-exemption-item:has(input:checked) { border-color: #005eb8; background: #f0f5ff; }
.nhs-exemption-item input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; accent-color: #005eb8; width: auto;}
.nhs-exemption-item strong { color: #005eb8; font-size: 0.85rem; white-space: nowrap; min-width: 16px; }

/* ── Submit ──────────────────────────────────────────────────── */
.nhs-submit-section { display: flex; flex-direction: column; gap: 10px; }

/* ── Messages ────────────────────────────────────────────────── */
.nhs-message { padding: 11px 15px; border-radius: 5px; font-size: 0.875rem; }
.nhs-message--success { background: #eafaf1; border: 1px solid #a3d9b1; color: #1a6630; }
.nhs-message--error   { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; }
.nhs-message--info    { background: #e8f4fd; border: 1px solid #93c5e9; color: #0c4a6e; }

/* ── Right col: Past Request Cards ──────────────────────────── */
.nhs-col-requests { position: sticky; top: 20px; }
.nhs-col-requests .nhs-col-heading h2 { margin-bottom: 0.75rem; }
.nhs-empty-requests {
    background: #fafafa; border: 2px dashed #ddd; border-radius: 6px;
    padding: 2rem; text-align: center; color: #999; font-size: 0.9rem;
}
.nhs-requests-list { display: flex; flex-direction: column; gap: 10px; max-height: 75vh; overflow-y: auto; }
.nhs-request-card {
    background: #fff; border: 1px solid #e5e5e5; border-radius: 6px;
    overflow: hidden; transition: box-shadow 0.15s;
}
.nhs-request-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.nhs-request-card__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; background: #f7f8fc; border-bottom: 1px solid #ebebeb;
}
.nhs-request-card__ref { font-size: 0.8125rem; font-family: monospace; color: #005eb8; }
.nhs-request-card__body { padding: 10px 14px; }
.nhs-request-card__body p { margin: 3px 0; font-size: 0.8125rem; color: #444; }
.nhs-request-card__body strong { color: #222; }
.nhs-request-card__meds { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nhs-request-card__date { color: #888 !important; font-size: 0.75rem !important; margin-top: 4px !important; }
.nhs-request-card__footer { padding: 8px 14px; background: #fafafa; border-top: 1px solid #ebebeb; }

/* ── Status badges ───────────────────────────────────────────── */
.nhs-status {
    display: inline-block; padding: 3px 9px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
.nhs-status--pending { background: #fff7e6; color: #b45309; border: 1px solid #fcd34d; }
.nhs-status--sent    { background: #e6f9f0; color: #065f46; border: 1px solid #6ee7b7; }

/* ── Single request view ─────────────────────────────────────── */
.nhs-view-header { margin-bottom: 1.5rem; }
.nhs-back-link { display: inline-block; font-size: 0.875rem; margin-bottom: 0.75rem; color: #005eb8; text-decoration: none; }
.nhs-back-link:hover { text-decoration: underline; }
.nhs-view-header h2 { margin: 0 0 0.5rem; font-size: 1.2rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nhs-ref-line { font-size: 0.875rem; color: #555; }
.nhs-view-sections { display: flex; flex-direction: column; gap: 1rem; }
.nhs-view-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.nhs-view-table th, .nhs-view-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #eee; }
.nhs-view-table th { background: #f5f5f5; font-weight: 600; font-size: 0.8125rem; color: #555; }
.nhs-exemption-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.nhs-exemption-list li { padding: 10px 0 5px !important; font-size: 0.875rem; border-bottom: 1px solid #f0f0f0; display: flex; gap: 8px; }
.nhs-ex-code {display: inline-block;
    background: #005eb8 !important;
    color: #fff;
    font-weight: 700;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px !important;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 2px;
    position: inherit !important;
    line-height: 25px !important;
    height: 28px !important;
    width: 28px !important;
    top: -4px !important;
    left: 0 !important; }
.nhs-muted { color: #999; font-size: 0.875rem; }
