/* ReSiRai - Study status and reminder indicators. */

/* --- Status badge on a Study card in the patient record --- */
.study-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-inline-start: 8px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.study-status-badge.status-1 { background: #fff6e6; color: var(--warning); }
.study-status-badge.status-3 { background: var(--brand-100); color: var(--brand-700); }
/* A follow-up whose date has passed needs attention now. */
.study-status-badge.overdue {
    background: var(--danger-soft);
    color: var(--danger);
    box-shadow: inset 0 0 0 1px #f7d2ce;
}

/* --- Open / completed counts in the patient list --- */
.study-count-open {
    color: var(--warning);
    font-weight: 800;
}
.study-count-done {
    color: var(--muted);
}
/* The whole row gets a hint when the patient still has open work. */
.patient-list-row.has-open-studies td:first-child {
    box-shadow: inset 3px 0 0 var(--brand-500);
}

/* --- Reminder filters under the search box --- */
.patient-reminder-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}
.patient-reminder-filters .checkbox-row { margin-top: 0; }

/* The open filter is the more common one, so it reads as an action. */
#patientsSection #openStudiesOnly:checked + span,
#patientsSection #dueFollowUpOnly:checked + span {
    color: var(--brand-700);
    font-weight: 700;
}

/* --- Study status form fields --- */
.study-status-select {
    max-width: 340px;
}
.study-followup-field {
    padding: 12px;
    border: 1px solid var(--brand-200);
    border-radius: var(--radius-sm);
    background: var(--brand-25);
}

/* --- Grouped study form ---
   The fields were one flat grid, so the eye had no path and the important status
   sat at the bottom. They are grouped into titled cards now. */
.study-form-card {
    margin-bottom: 16px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.study-form-card-title {
    margin: 0 0 14px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--border);
    color: var(--heading);
    font-size: var(--fs-sm);
    font-weight: 800;
}
/* A single column reads better than a stretched two-column grid: the labels are
   Persian and the controls are short. */
.study-form-card .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 760px;
}
.study-form-card .form-field.full-width { grid-column: 1 / -1; }

/* The status badge next to the study title in the panel header. */
.study-details-badge { display: flex; align-items: center; }
.study-details-badge:empty { display: none; }

/* Keep the whole form from stretching across a wide monitor. */
#studyDetailsForm, #newStudyForm { max-width: 900px; }

@media (max-width: 700px) {
    .study-form-card { padding: 12px; }
    .study-form-card .form-grid { grid-template-columns: 1fr; max-width: none; }
    .study-form-card .form-field.full-width { grid-column: auto; }
}

/* --- One-click completion on a study card --- */
.study-complete-button {
    background: linear-gradient(135deg, #12a06c, #0e7d55);
    color: #ffffff;
    font-weight: 700;
}
.study-complete-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #0e8e57, #0b6b49);
}
.study-complete-button:disabled { opacity: .65; }

/* --- Message offer bar ---
   Shown after an action worth telling the patient about. It is a bar, not a
   dialog, so it informs without blocking, and it never sends anything by itself. */
.message-offer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid var(--brand-200);
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--brand-50), #fff);
    box-shadow: var(--shadow);
    animation: toastIn 0.22s ease;
}
.message-offer-text {
    flex: 1 1 260px;
    color: var(--heading);
    font-size: var(--fs-sm);
    font-weight: 700;
}
.message-offer-send {
    background: linear-gradient(135deg, #1685ff, #0f67d8);
}
.message-offer button { min-height: 38px; }

/* --- Attention centre on the dashboard ---
   The clinic has three reasons to reach a patient: an upcoming visit, a due
   follow-up, or money owed. They are listed together so nothing is forgotten. */
.dashboard-attention-panel {
    margin-bottom: 12px;
    border-color: var(--brand-200);
    background: linear-gradient(135deg, var(--brand-50), #fff);
}
.attention-list { display: grid; gap: 8px; }

.attention-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
}
.attention-row.attention-appointment { border-inline-start: 4px solid var(--brand-450); }
.attention-row.attention-followup { border-inline-start: 4px solid var(--warning); }
.attention-row.attention-balance { border-inline-start: 4px solid var(--danger); }

.attention-text { display: grid; gap: 2px; min-width: 0; }
.attention-text strong { color: var(--heading); font-size: var(--fs-sm); }
.attention-text small { color: var(--muted); font-size: var(--fs-xs); }

.attention-send {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 6px 14px;
    background: linear-gradient(135deg, #1685ff, #0f67d8);
    font-size: var(--fs-xs);
    font-weight: 700;
}
.attention-empty {
    padding: 16px;
    border: 1px dashed var(--border-strong, #c3dae1);
    border-radius: var(--radius-sm);
    color: var(--muted);
    text-align: center;
    font-size: var(--fs-xs);
}

@media (max-width: 700px) {
    .attention-row { flex-direction: column; align-items: stretch; }
    .attention-send { width: 100%; min-height: 44px; }
}

/* ==========================================================
   Collapsible study rows
   A card rendered everything at once, making each study tall enough to need its
   own scrolling. The header now carries a one-line summary and the body opens on
   demand, so several studies fit on screen.
   ========================================================== */
.study-collapsible-header {
    cursor: pointer;
    user-select: none;
}
.study-collapsible-header:hover { background: #eef6ff; }
.study-collapsible-header:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: -2px;
}

.study-header-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    min-width: 0;
}
.study-header-main h4 { margin: 0; }
.study-header-main time {
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 500;
}

/* The summary is what makes a collapsed list scannable. */
.study-summary-line {
    flex: 1 0 100%;
    margin: 2px 0 0;
    color: var(--muted);
    font-size: var(--fs-xs);
    line-height: 1.7;
}

.study-toggle-button {
    min-width: 74px;
    font-weight: 700;
}
.study-scroll-card.study-open .study-toggle-button {
    background: #eef2f6;
    color: #334155;
}

/* The body keeps the spacing it had when it was always visible. */
.study-scroll-body { padding: 12px; }
.study-scroll-body .study-scroll-details,
.study-scroll-body .study-scroll-chart { margin-bottom: 12px; }

/* The money chip sits with the status badge on the first header line, so adding it
   does not add a whole extra line to the collapsed row. */
.study-finance-chip { align-self: center; }
@media (max-width: 700px) {
    .study-finance-chip { font-size: 11px; }
}

@media (max-width: 700px) {
    .patient-reminder-filters { flex-direction: column; gap: 6px; }
    .study-status-select { max-width: none; }
    .study-complete-button { min-height: 44px; }
}
