/* =================================================================
   iCare – Orthopaedic Emergency Shift Manager  |  v1.0.1
   Alexia Technology Sdn Bhd
   ================================================================= */

:root {
    --ic-primary:   #1a73e8;
    --ic-primary-d: #1557b0;
    --ic-danger:    #d93025;
    --ic-success:   #1e8e3e;
    --ic-warning:   #f9ab00;
    --ic-purple:    #7c3aed;
    --ic-teal:      #00796b;
    --ic-orange:    #e65100;
    --ic-gray:      #5f6368;
    --ic-border:    #dadce0;
    --ic-bg:        #f8f9fa;
    --ic-card:      #ffffff;
    --ic-text:      #202124;
    --ic-text2:     #5f6368;
    --ic-shadow:    0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
    --ic-shadow-md: 0 4px 12px rgba(0,0,0,.12);
    --ic-r:         8px;
    --ic-r-sm:      5px;
}

/* ---- Reset & wrap ---- */
.icare-wrap * { box-sizing: border-box; }
.icare-wrap {
    max-width: 1100px;
    padding: 0 16px 60px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ic-text);
    font-size: 14px;
}

/* ---- Header ---- */
.icare-header {
    display: flex;
    align-items: center;
    padding: 14px 0 12px;
    border-bottom: 2px solid var(--ic-primary);
    margin-bottom: 18px;
}
.icare-logo { display: flex; align-items: center; gap: 8px; }
.icare-logo-icon { font-size: 26px; }
.icare-logo-text {
    font-size: 22px;
    font-weight: 800;
    color: var(--ic-primary);
    letter-spacing: -0.5px;
}
.icare-logo-sub {
    font-size: 12px;
    color: var(--ic-text2);
    border-left: 1px solid var(--ic-border);
    padding-left: 10px;
    margin-left: 4px;
}

/* ---- No shift ---- */
.icare-no-shift {
    text-align: center;
    padding: 80px 20px;
    background: var(--ic-card);
    border-radius: var(--ic-r);
    box-shadow: var(--ic-shadow);
}
.icare-no-shift-icon { font-size: 64px; margin-bottom: 16px; }
.icare-no-shift h2 { font-size: 22px; color: var(--ic-text); margin-bottom: 8px; }
.icare-no-shift p  { color: var(--ic-text2); margin-bottom: 24px; }

/* ---- Shift bar ---- */
.icare-shift-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ic-card);
    border: 1px solid var(--ic-border);
    border-radius: var(--ic-r);
    padding: 12px 16px;
    margin-bottom: 14px;
    box-shadow: var(--ic-shadow);
    flex-wrap: wrap;
    gap: 10px;
}
.icare-shift-info { font-size: 13px; }
.icare-shift-actions { display: flex; gap: 8px; }
.icare-shift-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .5px;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    margin-right: 6px;
}
.icare-shift-badge.active { background: #e6f4ea; color: #1e8e3e; }
.icare-shift-badge.closed { background: #f1f3f4; color: #5f6368; }

/* ---- Stats row ---- */
.icare-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}
.icare-stat-card {
    background: var(--ic-card);
    border-radius: var(--ic-r);
    padding: 10px 8px;
    text-align: center;
    box-shadow: var(--ic-shadow);
    border-top: 3px solid transparent;
    cursor: default;
    transition: transform .15s;
}
.icare-stat-card:hover { transform: translateY(-2px); box-shadow: var(--ic-shadow-md); }
.icare-stat-value { font-size: 26px; font-weight: 800; line-height: 1; margin-bottom: 3px; }
.icare-stat-label { font-size: 10px; color: var(--ic-text2); text-transform: uppercase; letter-spacing: .3px; }

.icare-stat-blue   { border-color: var(--ic-primary); } .icare-stat-blue   .icare-stat-value { color: var(--ic-primary); }
.icare-stat-red    { border-color: var(--ic-danger);  } .icare-stat-red    .icare-stat-value { color: var(--ic-danger);  }
.icare-stat-red2   { border-color: #b71c1c;           } .icare-stat-red2   .icare-stat-value { color: #b71c1c;           }
.icare-stat-orange { border-color: var(--ic-orange);  } .icare-stat-orange .icare-stat-value { color: var(--ic-orange);  }
.icare-stat-gray   { border-color: var(--ic-gray);    } .icare-stat-gray   .icare-stat-value { color: var(--ic-gray);    }
.icare-stat-green  { border-color: var(--ic-success); } .icare-stat-green  .icare-stat-value { color: var(--ic-success); }
.icare-stat-teal   { border-color: var(--ic-teal);    } .icare-stat-teal   .icare-stat-value { color: var(--ic-teal);    }
.icare-stat-yellow { border-color: var(--ic-warning); } .icare-stat-yellow .icare-stat-value { color: #b06000; }
.icare-stat-purple { border-color: var(--ic-purple);  } .icare-stat-purple .icare-stat-value { color: var(--ic-purple);  }

/* ---- Toolbar ---- */
.icare-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}
.icare-filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.icare-filter-tab {
    background: none;
    border: 1px solid var(--ic-border);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    color: var(--ic-text2);
    transition: all .15s;
    font-family: inherit;
}
.icare-filter-tab.active,
.icare-filter-tab:hover {
    background: var(--ic-primary);
    border-color: var(--ic-primary);
    color: #fff;
}

/* ---- Patient list ---- */
.icare-patient-list { display: flex; flex-direction: column; gap: 7px; }

.icare-patient-row {
    display: flex;
    align-items: stretch;
    background: var(--ic-card);
    border-radius: var(--ic-r);
    border: 1px solid var(--ic-border);
    box-shadow: var(--ic-shadow);
    overflow: hidden;
    transition: box-shadow .15s;
}
.icare-patient-row:hover { box-shadow: var(--ic-shadow-md); }

.icare-patient-cat {
    width: 34px;
    min-width: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.icare-cat-red    { background: #fce8e6; }
.icare-cat-orange { background: #fef3e2; }
.icare-cat-gray   { background: #f1f3f4; }

.icare-patient-main { flex: 1; padding: 9px 12px; min-width: 0; }
.icare-patient-header {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}
.icare-patient-name { font-size: 14px; font-weight: 700; color: var(--ic-text); }
.icare-patient-time { font-size: 11px; color: var(--ic-text2); margin-left: auto; white-space: nowrap; }
.icare-patient-meta { font-size: 11px; color: var(--ic-text2); margin-bottom: 2px; }
.icare-patient-dx   { font-size: 12px; color: var(--ic-text); margin-bottom: 1px; }
.icare-patient-plan { font-size: 11px; color: var(--ic-text2); }

.icare-patient-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    border-left: 1px solid var(--ic-border);
    min-width: 44px;
}
.icare-img-badge {
    font-size: 10px;
    color: var(--ic-text2);
    background: var(--ic-bg);
    padding: 2px 4px;
    border-radius: 4px;
}

.icare-empty-list {
    text-align: center;
    padding: 50px 20px;
    color: var(--ic-text2);
    background: var(--ic-card);
    border-radius: var(--ic-r);
    border: 2px dashed var(--ic-border);
}
.icare-empty-list span { font-size: 40px; display: block; margin-bottom: 10px; }

/* ---- Badges ---- */
.icare-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: .2px;
    white-space: nowrap;
}
.icare-badge-green  { background: #e6f4ea; color: #1e8e3e; }
.icare-badge-yellow { background: #fef7e0; color: #b06000; }
.icare-badge-red    { background: #fce8e6; color: #c5221f; }
.icare-badge-blue   { background: #e8f0fe; color: #1a73e8; }
.icare-badge-purple { background: #f3e8fd; color: #6d28d9; }
.icare-badge-teal   { background: #e0f5f5; color: #00796b; }
.icare-badge-orange { background: #fff3e0; color: #e65100; }
.icare-badge-gray   { background: #f1f3f4; color: #5f6368; }

/* ---- Buttons ---- */
.icare-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 16px;
    border-radius: var(--ic-r-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all .15s;
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
    line-height: 1.4;
}
.icare-btn:focus { outline: 2px solid var(--ic-primary); outline-offset: 2px; }

.icare-btn-primary   { background: var(--ic-primary);   color: #fff; }
.icare-btn-primary:hover { background: var(--ic-primary-d); color: #fff; }

.icare-btn-secondary { background: #fff; color: var(--ic-text); border: 1px solid var(--ic-border); }
.icare-btn-secondary:hover { background: var(--ic-bg); }

.icare-btn-danger    { background: var(--ic-danger); color: #fff; }
.icare-btn-danger:hover { background: #b71c1c; }

.icare-btn-sm   { padding: 5px 12px; font-size: 12px; }
.icare-btn-xs   { padding: 3px 7px;  font-size: 11px; }
.icare-btn-lg   { padding: 12px 24px; font-size: 15px; }
.icare-btn-full { width: 100%; }

/* ---- Card ---- */
.icare-card {
    background: var(--ic-card);
    border-radius: var(--ic-r);
    padding: 22px;
    box-shadow: var(--ic-shadow);
    margin-bottom: 18px;
}
.icare-card h2 { margin-top: 0; font-size: 18px; }

/* ---- Form ---- */
.icare-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.icare-form-full { grid-column: 1 / -1; }
.icare-form-group { display: flex; flex-direction: column; gap: 4px; }
.icare-form-group label {
    font-size: 11px;
    font-weight: 700;
    color: var(--ic-text2);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.req { color: var(--ic-danger); }
.icare-input {
    padding: 9px 11px;
    border: 1px solid var(--ic-border);
    border-radius: var(--ic-r-sm);
    font-size: 14px;
    color: var(--ic-text);
    background: #fff;
    width: 100%;
    transition: border-color .15s;
    font-family: inherit;
}
.icare-input:focus {
    outline: none;
    border-color: var(--ic-primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}
select.icare-input { appearance: auto; }
.icare-textarea     { min-height: 76px; resize: vertical; }

/* ---- Modal ---- */
.icare-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.icare-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
}
.icare-modal-box {
    position: relative;
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow: hidden;          /* clip border-radius only — body is the sole scroller */
    box-shadow: 0 24px 48px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
}
.icare-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--ic-border);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
    border-radius: 12px 12px 0 0;
}
.icare-modal-header h3 { margin: 0; font-size: 16px; }
.icare-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--ic-text2);
    padding: 4px 6px;
    border-radius: 4px;
    font-family: inherit;
}
.icare-modal-close:hover { background: var(--ic-bg); }
.icare-modal-body { padding: 18px; flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.icare-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--ic-border);
    background: var(--ic-bg);
    border-radius: 0 0 12px 12px;
    flex-shrink: 0;             /* never pushed off-screen by body content */
}

/* ---- OCR section ---- */
.icare-ocr-section {
    background: #e8f0fe;
    border: 1px solid #c5d9f8;
    border-radius: var(--ic-r);
    margin-bottom: 18px;
    overflow: hidden;
}
.icare-ocr-header {
    background: #d2e3fc;
    padding: 7px 13px;
    font-size: 12px;
    font-weight: 700;
    color: var(--ic-primary-d);
}
.icare-ocr-body { padding: 12px; }
.icare-progress-bar {
    background: #c5d9f8;
    border-radius: 10px;
    height: 5px;
    overflow: hidden;
    margin-bottom: 5px;
}
.icare-progress-fill {
    height: 100%;
    background: var(--ic-primary);
    border-radius: 10px;
    width: 0%;
    transition: width .3s;
}
.icare-ocr-result {
    margin-top: 10px;
    padding: 10px;
    background: #fff;
    border-radius: var(--ic-r-sm);
    font-size: 12px;
    color: var(--ic-text2);
    border: 1px solid var(--ic-border);
    line-height: 1.6;
}

/* ---- Image section ---- */
.icare-image-section {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--ic-border);
}
.icare-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--ic-text2);
    text-transform: uppercase;
    letter-spacing: .3px;
    margin-bottom: 8px;
}
.icare-image-gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.icare-image-thumb {
    width: 76px;
    height: 76px;
    object-fit: cover;
    border-radius: var(--ic-r-sm);
    border: 2px solid var(--ic-border);
    cursor: pointer;
    transition: border-color .15s;
}
.icare-image-thumb:hover { border-color: var(--ic-primary); }
.icare-image-note { font-size: 11px; color: var(--ic-text2); margin-top: 6px; }

/* ---- Export modal ---- */
.icare-export-tabs {
    display: flex;
    border-bottom: 1px solid var(--ic-border);
    margin-bottom: 14px;
}
.icare-export-tab {
    padding: 7px 14px;
    border: none;
    background: none;
    font-size: 13px;
    color: var(--ic-text2);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all .15s;
    font-family: inherit;
}
.icare-export-tab.active { color: var(--ic-primary); border-bottom-color: var(--ic-primary); font-weight: 600; }
.icare-export-hint { font-size: 12px; color: var(--ic-text2); margin-bottom: 8px; }
.icare-export-textarea {
    width: 100%;
    height: 260px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    padding: 12px;
    border: 1px solid var(--ic-border);
    border-radius: var(--ic-r-sm);
    resize: vertical;
    background: var(--ic-bg);
    margin-bottom: 10px;
    color: var(--ic-text);
}

/* ---- Table ---- */
.icare-table-wrap { overflow-x: auto; }
.icare-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.icare-table th {
    text-align: left;
    padding: 9px 12px;
    border-bottom: 2px solid var(--ic-border);
    color: var(--ic-text2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
}
.icare-table td { padding: 9px 12px; border-bottom: 1px solid var(--ic-border); }
.icare-table tr:last-child td { border-bottom: none; }
.icare-table tr:hover td { background: var(--ic-bg); }

/* ---- Alerts ---- */
.icare-alert {
    padding: 10px 14px;
    border-radius: var(--ic-r-sm);
    font-size: 13px;
    line-height: 1.5;
}
.icare-alert-success { background: #e6f4ea; color: #1e8e3e; border: 1px solid #b3dfbd; }
.icare-alert-error   { background: #fce8e6; color: #c5221f; border: 1px solid #f5c6c3; }
.icare-alert-info    { background: #e8f0fe; color: #1a73e8; border: 1px solid #c5d9f8; }

/* ---- Settings ---- */
.icare-settings-box {
    background: var(--ic-bg);
    border-radius: var(--ic-r-sm);
    padding: 16px;
    font-size: 14px;
    line-height: 1.8;
}
.icare-settings-box p { margin: 0; }

/* ---- Spinner ---- */
.icare-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--ic-border);
    border-top-color: var(--ic-primary);
    border-radius: 50%;
    animation: ic-spin .6s linear infinite;
    vertical-align: middle;
}
@keyframes ic-spin { to { transform: rotate(360deg); } }

/* ---- Responsive ---- */
@media (max-width: 782px) {
    .icare-logo-sub { display: none; }
    .icare-stats-row { grid-template-columns: repeat(4, 1fr); }
    .icare-shift-bar { flex-direction: column; align-items: flex-start; }
    .icare-modal { align-items: flex-end; padding: 0; }
    .icare-modal-box { max-width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; overflow: hidden; }
    .icare-patient-header { gap: 4px; }
}
@media (max-width: 540px) {
    .icare-form-grid { grid-template-columns: 1fr; }
    .icare-form-full { grid-column: 1; }
    .icare-stats-row { grid-template-columns: repeat(3, 1fr); }
    .icare-wrap { padding: 0 10px 60px; }
    .icare-card { padding: 16px; }
}

/* ================================================================
   iCare CSS additions v1.1.0 — census panel, flags, new zones
   ================================================================ */

/* Census Panel */
.icare-census-panel {
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
}
.icare-census-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: #1a73e8;
    background: #f8f9ff;
    border-bottom: 1px solid #e8eaed;
    user-select: none;
}
.icare-census-header:hover { background: #eef2ff; }
.icare-census-chevron { font-size: 11px; transition: transform .2s; }
.icare-census-chevron.open { transform: rotate(180deg); }

.icare-census-body { padding: 16px; }
.icare-census-section { margin-bottom: 16px; }
.icare-census-section:last-child { margin-bottom: 0; }
.icare-census-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #5f6368;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 10px;
}
.icare-census-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}
.icare-census-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #5f6368;
    margin-bottom: 4px;
}
.icare-census-input { text-align: center; padding: 6px 8px !important; }

/* Flag toggle buttons on patient row */
.icare-flag-group {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}
.icare-flag-btn {
    background: #f1f3f4;
    border: 1px solid #dadce0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    padding: 3px 6px;
    line-height: 1;
    transition: all .15s;
    opacity: .45;
}
.icare-flag-btn:hover { opacity: .75; border-color: #1a73e8; }
.icare-flag-btn.active {
    background: #e8f0fe;
    border-color: #1a73e8;
    opacity: 1;
    box-shadow: 0 0 0 2px rgba(26,115,232,.15);
}

/* Flag checkboxes in modal */
.icare-flag-section {
    margin: 16px 0 0;
    padding: 12px 14px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e8eaed;
}
.icare-flag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}
.icare-flag-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}
.icare-flag-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* Small textarea for contact */
.icare-textarea-sm { min-height: 60px !important; }

/* Export modal actions row */
.icare-export-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}
.icare-export-actions .icare-btn { flex: 1; }

/* 4-tab export tab bar */
.icare-export-tabs { flex-wrap: wrap; }
.icare-export-tab {
    font-size: 12px;
    padding: 7px 10px;
}

/* Badge color for new zones */
.icare-badge-orange { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }

/* Ward group visibility tweak */
#icare-ward-group, #icare-ward-bed-group { transition: opacity .2s; }

/* ================================================================
   Location management (Settings page) — v1.1.0
   ================================================================ */

.icare-add-location-form {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e8eaed;
}

.icare-location-form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    margin-top: 16px;
}

/* Zebra stripe for location table */
#icare-location-table tbody tr:nth-child(even) { background: #f8f9fa; }
#icare-location-table tbody tr:hover { background: #eef2ff; }
#icare-location-table td { vertical-align: middle; }

/* Badge orange — already in existing CSS but ensure it's there */
.icare-badge-teal    { background: #e6f4ea; color: #137333; border: 1px solid #a8d5b5; }

/* ================================================================
   v1.1.5 — prominent Add Patient button
   ================================================================ */

.icare-btn-add-patient {
    font-size: 15px !important;
    padding: 10px 22px !important;
    font-weight: 700 !important;
    letter-spacing: .3px;
    box-shadow: 0 2px 8px rgba(26,115,232,.35);
    border-radius: 10px !important;
    width: 100%;
    display: block;
}
.icare-btn-add-patient:hover {
    box-shadow: 0 4px 14px rgba(26,115,232,.45);
    transform: translateY(-1px);
}

/* ================================================================
   v1.1.7 — clickable patient row
   ================================================================ */

.icare-patient-row {
    cursor: pointer;
    transition: background .12s, box-shadow .12s;
}
.icare-patient-row:hover {
    background: #f0f4ff;
    box-shadow: inset 3px 0 0 #1a73e8;
}
/* Action area — not clickable as a row */
.icare-patient-actions {
    cursor: default;
}

/* ================================================================
   v1.2.1 — drag-to-reorder patient rows
   ================================================================ */

.icare-drag-handle {
    cursor: grab;
    font-size: 18px;
    color: #c0c8d8;
    padding: 0 6px 0 0;
    line-height: 1;
    flex-shrink: 0;
    align-self: center;
    user-select: none;
    transition: color .15s;
}
.icare-drag-handle:hover { color: #1a73e8; }
.icare-drag-handle:active { cursor: grabbing; }

/* Row being dragged */
.icare-patient-row.dragging {
    opacity: .4;
    background: #e8f0fe !important;
    border: 2px dashed #1a73e8 !important;
}

/* Drop target indicator */
.icare-patient-row.drag-over {
    border-top: 3px solid #1a73e8 !important;
    margin-top: -1px;
}

/* ================================================================
   v1.2.3 — numbered sequence + up/down reorder buttons
   ================================================================ */

/* Remove old drag styles */
.icare-drag-handle { display: none; }

.icare-seq-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    min-width: 32px;
}

.icare-seq-num {
    font-size: 13px;
    font-weight: 800;
    color: #1a73e8;
    line-height: 1;
    min-width: 20px;
    text-align: center;
}

.icare-seq-btns {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.icare-seq-btn {
    background: #f1f3f4;
    border: 1px solid #dadce0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 9px;
    line-height: 1;
    padding: 2px 5px;
    color: #5f6368;
    transition: all .12s;
}
.icare-seq-btn:hover:not(:disabled) {
    background: #e8f0fe;
    border-color: #1a73e8;
    color: #1a73e8;
}
.icare-seq-btn:disabled {
    opacity: .3;
    cursor: default;
}

/* ================================================================
   v1.2.5 — image lightbox + thumbnail delete button
   ================================================================ */

/* Thumbnail wrapper — position:relative for delete overlay */
.icare-img-thumb-wrap {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

/* Delete button on thumbnail — always visible on touch, hover on desktop */
.icare-img-del-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 11px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    opacity: 1;               /* always visible */
    transition: background .15s;
}
.icare-img-del-btn:hover { background: #d93025; }

/* Lightbox */
#icare-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200000;
    background: rgba(0,0,0,.92);
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
#icare-lightbox.flex-display { display: flex; }

#icare-lb-overlay {
    position: absolute;
    inset: 0;
}

#icare-lb-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 92vw;
    max-height: 80vh;
    z-index: 1;
}

#icare-lb-img {
    max-width: 92vw;
    max-height: 76vh;
    object-fit: contain;
    border-radius: 8px;
    user-select: none;
    -webkit-user-drag: none;
}

#icare-lb-counter {
    margin-top: 10px;
    color: rgba(255,255,255,.7);
    font-size: 13px;
    letter-spacing: .5px;
}

/* Nav buttons */
#icare-lb-prev, #icare-lb-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    font-size: 36px;
    line-height: 1;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 8px;
    z-index: 2;
    transition: background .15s;
}
#icare-lb-prev { left: 12px; }
#icare-lb-next { right: 12px; }
#icare-lb-prev:hover, #icare-lb-next:hover { background: rgba(255,255,255,.3); }

/* Close button */
#icare-lb-close {
    position: fixed;
    top: 14px;
    right: 14px;
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
    transition: background .15s;
}
#icare-lb-close:hover { background: rgba(255,255,255,.3); }

/* Delete button */
#icare-lb-delete {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #d93025;
    border: none;
    color: #fff;
    font-size: 14px;
    padding: 9px 20px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 2;
    transition: background .15s;
}
#icare-lb-delete:hover { background: #b3261e; }

/* ================================================================
   v1.2.7 — clerked toggle button on patient card
   ================================================================ */

.icare-clerked-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 20px;
    border: 2px solid #dadce0;
    background: #f8f9fa;
    color: #5f6368;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    font-family: inherit;
}
.icare-clerked-btn:hover {
    border-color: #1a73e8;
    color: #1a73e8;
    background: #e8f0fe;
}
.icare-clerked-btn.clerked {
    background: #e6f4ea;
    border-color: #34a853;
    color: #137333;
}
.icare-clerked-btn.clerked:hover {
    background: #d2edd8;
    border-color: #137333;
}

/* ================================================================
   v1.2.2 — Insurance / SOCSO section
   ================================================================ */

.icare-insurance-section {
    margin: 16px 0 0;
    padding: 12px 14px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e8eaed;
}

.icare-ins-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    background: #e8f0fe;
    color: #1557b0;
    border: 1px solid #c5d9f8;
    border-radius: 20px;
    padding: 2px 10px;
}

.icare-patient-insurance {
    margin-top: 5px;
}

/* ================================================================
   v1.2.8 — Status filter tabs row
   ================================================================ */

.icare-status-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0 12px;
    border-bottom: 1px solid #e8eaed;
    margin-bottom: 12px;
}

.icare-status-tab {
    background: #f1f3f4;
    border: 1px solid #dadce0;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: #3c4043;
    white-space: nowrap;
    transition: all .15s;
    font-family: inherit;
}

.icare-status-tab:hover {
    background: #e8eaed;
    border-color: #bdc1c6;
}

.icare-status-tab.active {
    background: #1a73e8;
    color: #fff;
    border-color: #1a73e8;
    font-weight: 600;
}

/* ================================================================
   v1.3.3 — compact referral time field
   ================================================================ */

.icare-ref-time-group {
    max-width: 160px !important;
    min-width: 120px;
}
.icare-ref-time-input {
    max-width: 140px !important;
    padding-left: 8px !important;
    padding-right: 4px !important;
}

/* ================================================================
   v1.2.3 — image section actions (Add + Download buttons)
   ================================================================ */

.icare-image-section-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

/* ================================================================
   v1.2.5 — inline image row inside patient card body
   ================================================================ */

.icare-patient-images-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.icare-patient-images-row .icare-img-badge {
    font-size: 12px;
    color: #5f6368;
    background: #f1f3f4;
    border-radius: 6px;
    padding: 2px 8px;
    border: 1px solid #e0e0e0;
}

/* ================================================================
   v1.2.6 — S/B SP label + filter tabs
   ================================================================ */

/* S/B SP label below flag buttons */
.icare-sbsp-label {
    font-size: 10px;
    font-weight: 700;
    color: #1a73e8;
    letter-spacing: .3px;
    min-height: 14px;
    text-align: center;
    margin-top: 2px;
}

/* SP filter tab row */
.icare-sp-filter-tabs {
    margin-top: 0;
}
.icare-sp-filter-tab {
    background: #fff;
    border: 1px solid #dadce0;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: #5f6368;
    transition: all .15s;
    white-space: nowrap;
    font-family: inherit;
}
.icare-sp-filter-tab:hover {
    background: #f1f3f4;
    border-color: #bdc1c6;
}
.icare-sp-filter-tab.active {
    background: #e8f0fe;
    border-color: #1a73e8;
    color: #1a73e8;
    font-weight: 600;
}
/* Pending tab — orange accent when active */
.icare-sp-filter-tab[data-sp-filter="pending"].active {
    background: #fff3e0;
    border-color: #e65100;
    color: #e65100;
}

/* ================================================================
   v1.2.7 — prominent Export WhatsApp button
   ================================================================ */

.icare-btn-export-main {
    background: #25D366 !important;         /* WhatsApp green */
    color: #fff !important;
    border: none !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    padding: 9px 18px !important;
    border-radius: 10px !important;
    box-shadow: 0 2px 8px rgba(37,211,102,.4);
    letter-spacing: .2px;
}
.icare-btn-export-main:hover {
    background: #1ebe5d !important;
    box-shadow: 0 4px 14px rgba(37,211,102,.5);
    transform: translateY(-1px);
    color: #fff !important;
}

/* ================================================================
   v1.2.13 — prominent Export button (green, distinct from Add Patient)
   ================================================================ */

.icare-btn-export {
    background: #1e8c45 !important;
    border-color: #1e8c45 !important;
    color: #fff !important;
    font-weight: 700 !important;
    letter-spacing: .2px;
    box-shadow: 0 2px 8px rgba(30,140,69,.35);
}
.icare-btn-export:hover {
    background: #166d36 !important;
    border-color: #166d36 !important;
    box-shadow: 0 4px 12px rgba(30,140,69,.45);
    transform: translateY(-1px);
}
