/* ============================================================
   RowComponents.css
   Shared styles for: AllergyRow, ImmunisationRow, ComplaintRow,
   DiagnosisRow, InvestigationRow.

   Add this to your wwwroot/css/ folder and reference it in
   _Layout.cshtml alongside your existing stylesheets.

   Design tokens mirror your existing Syncfusion theme variables
   so all rows blend seamlessly with the rest of the consultation UI.
   ============================================================ */

/* ── Shared base row ─────────────────────────────────────────── */
.ar-row, .imr-row, .ccr-row, .dxr-row, .invr-row {
    border-bottom: 0.5px solid var(--e-content-border-color, #e0e0e0);
    transition: background 0.12s;
}

.ar-row:hover, .imr-row:hover, .ccr-row:hover,
.dxr-row:hover, .invr-row:hover {
    background: var(--e-hover-bg, #f5f5f5);
}

/* Slide-in animation for new rows */
.ar-row--new, .imr-row--new, .ccr-row--new,
.dxr-row--new, .invr-row--new {
    animation: rowSlideIn 0.2s ease-out;
}

@keyframes rowSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Row number gutter ───────────────────────────────────────── */
.ar-num, .imr-num, .ccr-num, .dxr-num {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--e-content-placeholder-color, #bbb);
    width: 26px;
    flex-shrink: 0;
}

/* ── Row body ────────────────────────────────────────────────── */
.ar-row  { display: grid; grid-template-columns: 26px 1fr; }
.imr-row { display: grid; grid-template-columns: 26px 1fr; }
.ccr-row { display: grid; grid-template-columns: 26px 1fr; }
.dxr-row { display: grid; grid-template-columns: 26px 1fr; }

.ar-body, .imr-body, .ccr-body, .dxr-body {
    padding: 8px 12px 8px 2px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Line-level flex rows */
.ar-body,
.imr-body {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.ccr-line1, .dxr-line1 {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ccr-line2, .dxr-tpl-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Shared ComboBox size reset ──────────────────────────────── */
.ar-combo.e-control-wrapper,
.imr-combo.e-control-wrapper,
.ccr-combo.e-control-wrapper,
.dxr-combo.e-control-wrapper,
.invr-combo.e-control-wrapper {
    border-radius: 4px !important;
    min-height: 30px !important;
}

.ar-combo .e-input,
.imr-combo .e-input,
.ccr-combo .e-input,
.dxr-combo .e-input,
.invr-combo .e-input {
    font-size: 13px !important;
    padding: 0 6px !important;
    height: 30px !important;
    line-height: 30px !important;
}

.dxr-name .e-input { font-weight: 500 !important; }

/* ── Text inputs (plain html inputs used where SfTextBox not needed) ── */
.ar-text-input,
.imr-text-input,
.ccr-comment-input,
.invr-text-input,
.invr-result-input {
    border: 1px solid var(--e-content-border-color, #e0e0e0);
    border-radius: 4px;
    background: transparent;
    outline: none;
    font-size: 12px;
    color: var(--e-content-font-color, #333);
    padding: 4px 8px;
    height: 30px;
    width: 100%;
    transition: border-color 0.12s;
}

.ar-text-input:focus,
.ccr-comment-input:focus,
.invr-text-input:focus,
.invr-result-input:focus {
    border-color: var(--e-primary, #6200ea);
}

.ccr-comment-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 12px;
    font-style: italic;
    color: var(--e-content-secondary-color, #888);
    padding: 0;
    height: auto;
}

.ccr-comment-input::placeholder { opacity: 0.6; }

/* ── Delete buttons ──────────────────────────────────────────── */
.ar-del-btn, .imr-del-btn, .ccr-del-btn, .dxr-del-btn, .invr-del-btn {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--e-content-placeholder-color, #bbb);
    flex-shrink: 0;
    transition: color 0.12s, background 0.12s;
    margin-left: auto;
}

.ar-del-btn:hover, .imr-del-btn:hover, .ccr-del-btn:hover,
.dxr-del-btn:hover, .invr-del-btn:hover {
    color: #c62828;
    background: #ffebee;
}

/* ── Allergy warning chip strip ──────────────────────────────── */
.allergy-known-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 7px 14px;
    border-bottom: 0.5px solid #F7C1C1;
    background: #fff8f8;
}

.allergy-lbl {
    font-size: 11px;
    font-weight: 600;
    color: #A32D2D;
}

.allergy-chip--warning {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 9px;
    border-radius: 20px;
    background: #FCEBEB;
    color: #A32D2D;
    border: 1px solid #F7C1C1;
}

/* ── Complaint — duration chips ──────────────────────────────── */
.ccr-dur-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.ccr-dur-chip {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid var(--e-content-border-color, #e0e0e0);
    background: var(--e-bg-base, #fff);
    color: var(--e-content-secondary-color, #666);
    cursor: pointer;
    transition: all 0.1s;
}

.ccr-dur-chip:hover {
    border-color: var(--e-primary, #6200ea);
    color: var(--e-primary, #6200ea);
}

.ccr-dur-chip--on {
    background: var(--e-primary, #6200ea) !important;
    border-color: var(--e-primary, #6200ea) !important;
    color: #fff !important;
}

.ccr-dur-chip--display {
    background: var(--e-primary-light, #ede7f6);
    color: var(--e-primary, #6200ea);
    border-color: var(--e-primary-light, #ede7f6);
    cursor: default;
    pointer-events: none;
}

.ccr-name-field { flex: 1; min-width: 180px; }

.ccr-custom-dur {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ccr-dur-num {
    width: 44px;
    height: 28px;
    border: 1px solid var(--e-content-border-color, #e0e0e0);
    border-radius: 4px;
    text-align: center;
    font-size: 12px;
    background: transparent;
    outline: none;
    -moz-appearance: textfield;
}

.ccr-dur-num::-webkit-outer-spin-button,
.ccr-dur-num::-webkit-inner-spin-button { -webkit-appearance: none; }

.ccr-unit-combo.e-control-wrapper { min-height: 28px !important; }
.ccr-unit-combo .e-input { font-size: 11px !important; height: 28px !important; }

/* ── Diagnosis — ICD chip ────────────────────────────────────── */
.dxr-icd-chip {
    font-size: 10px;
    font-weight: 600;
    font-family: var(--e-font-mono, monospace);
    padding: 3px 9px;
    border-radius: 4px;
    border: 1px solid var(--e-content-border-color, #e0e0e0);
    background: var(--e-input-bg, #f5f5f5);
    color: var(--e-content-secondary-color, #666);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.1s;
}

.dxr-icd-chip:hover {
    border-color: var(--e-primary, #6200ea);
    color: var(--e-primary, #6200ea);
    background: var(--e-primary-light, #ede7f6);
}

.dxr-icd-chip--empty {
    border-style: dashed;
    color: var(--e-content-placeholder-color, #bbb);
}

.dxr-icd-input {
    width: 90px;
    height: 28px;
    border: 1px solid var(--e-primary, #6200ea);
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--e-font-mono, monospace);
    padding: 0 6px;
    background: var(--e-primary-light, #ede7f6);
    outline: none;
}

/* ── Diagnosis — notes template row ─────────────────────────── */
.dxr-tpl-combo.e-control-wrapper { min-height: 26px !important; min-width: 160px; }
.dxr-tpl-combo .e-input { font-size: 11px !important; }

.dxr-bookmark-btn {
    font-size: 13px;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: 1px dashed var(--e-content-border-color, #ccc);
    background: transparent;
    cursor: pointer;
    color: var(--e-content-secondary-color, #999);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.12s;
}

.dxr-bookmark-btn:hover {
    border-style: solid;
    border-color: var(--e-primary, #6200ea);
    color: var(--e-primary, #6200ea);
    background: var(--e-primary-light, #ede7f6);
}

.dxr-notes.e-control-wrapper, .dxr-comments.e-control-wrapper {
    font-size: 12px !important;
}

/* ── Investigation — CSS Grid hybrid layout ──────────────────── */
/* Applied to the parent container in Examination.razor */
.inv-table {
    display: grid;
    grid-template-columns: 160px 200px 110px 110px 120px 1fr 80px;
    min-width: 0;
    overflow-x: auto;
}

.inv-table-header {
    display: contents; /* participates in parent grid */
}

.inv-header-cell {
    position: sticky;
    top: 0;
    background: var(--e-hover-bg, #fafafa);
    border-bottom: 1px solid var(--e-content-border-color, #e0e0e0);
    font-size: 10px;
    font-weight: 600;
    color: var(--e-content-secondary-color, #888);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 8px;
    z-index: 1;
}

.invr-row {
    display: contents; /* each child div fills one grid column */
}

/* Abnormal row highlight */
.invr-row--abnormal .invr-cell { background: #FFF8F8; }

.invr-cell {
    padding: 6px 8px;
    border-bottom: 0.5px solid var(--e-content-border-color, #f0f0f0);
    display: flex;
    align-items: center;
    min-width: 0;
}

.invr-combo.e-control-wrapper { width: 100% !important; min-height: 28px !important; }
.invr-combo .e-input { font-size: 12px !important; height: 28px !important; }

.invr-text-input { font-size: 12px; height: 28px; }

/* Normal value chip */
.invr-normal-chip {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid var(--e-content-border-color, #e0e0e0);
    background: var(--e-input-bg, #f5f5f5);
    color: var(--e-content-secondary-color, #777);
    cursor: pointer;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.1s;
}

.invr-normal-chip:hover { border-color: var(--e-primary, #6200ea); }

.invr-normal-chip--empty {
    border-style: dashed;
    color: var(--e-content-placeholder-color, #bbb);
    font-size: 10px;
}

/* Result cell */
.invr-result-cell {
    position: relative;
}

.invr-result-cell--abnormal { background: #FFF4F4 !important; }

.invr-result-input {
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--e-content-border-color, #e0e0e0);
    background: transparent;
}

.invr-result-input--abnormal {
    border-color: #F09595 !important;
    color: #A32D2D;
    background: #FFF4F4;
}

.invr-abnormal-flag {
    font-size: 13px;
    color: #E24B4A;
    margin-left: 4px;
    flex-shrink: 0;
}

/* Actions cell */
.invr-actions-cell { gap: 4px; justify-content: flex-end; }

.invr-action-btn {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: 1px solid var(--e-content-border-color, #e0e0e0);
    background: var(--e-bg-base, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--e-content-secondary-color, #666);
    transition: all 0.12s;
}

.invr-action-btn:hover {
    border-color: var(--e-primary, #6200ea);
    color: var(--e-primary, #6200ea);
    background: var(--e-primary-light, #ede7f6);
}

/* ── Immunisation — date chip ────────────────────────────────── */
.imr-date-chip {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 20px;
    background: var(--e-primary-light, #ede7f6);
    color: var(--e-primary, #6200ea);
    white-space: nowrap;
    font-weight: 500;
}

.imr-date.e-control-wrapper { min-height: 30px !important; min-width: 130px; }
.imr-date .e-input { font-size: 12px !important; }
