/* === Sidebar SVG icons === */
.sidebar-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    opacity: 0.7;
    transition: opacity var(--t-fast);
}

.sidebar-link:hover .sidebar-icon {
    opacity: 1;
}

.sidebar-link.active .sidebar-icon {
    opacity: 1;
}

/* Coming-soon icons - larger, muted */
.coming-soon-icon {
    font-size: 48px;
}
/* ============================================
   Bottom shortcut bar (mobile only)
   Shows 6 quick-access icons on phones/tablets.
   Hidden on desktop ( - -1024px) where sidebar is always visible.
   Two mobile navigation options:
     1. Hamburger menu - full sidebar (all 10 items)
     2. Bottom bar - 5 most-used + "More" (opens sidebar)
   ============================================ */

.bottom-bar {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: 56px;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    flex-shrink: 0;
    z-index: 90;
    /* Safe area for iPhone notch / Android gesture bar */
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    background: none;
    border: none;
    color: var(--c-text-muted);
    cursor: pointer;
    padding: var(--sp-xs) 0;
    transition: color var(--t-fast);
    min-width: 0;
    -webkit-tap-highlight-color: transparent;
}

.bottom-bar-item:active {
    background: var(--c-surface-alt);
}

.bottom-bar-item.active {
    color: var(--c-primary);
    font-weight: 600;
}

.bottom-bar-label {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Hide bottom bar on desktop - sidebar is always visible there */
@media (min-width: 1024px) {
    .bottom-bar {
        display: none;
    }
}

/* On very small phones, hide labels to save space */
@media (max-width: 360px) {
    .bottom-bar-label {
        display: none;
    }
    .bottom-bar {
        height: 48px;
    }
}
/* === Searchable combobox === */
.combobox {
    position: relative;
    width: 100%;
}

.combobox-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
}

.combobox-dropdown.open {
    display: block;
}

.combobox-item {
    display: flex;
    flex-direction: column;
    padding: var(--sp-sm) var(--sp-md);
    cursor: pointer;
    transition: background var(--t-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.combobox-item:hover, .combobox-item.highlighted {
    background: var(--c-surface-alt);
}

.combobox-item.selected {
    background: var(--c-primary-light);
    font-weight: 600;
}

.combobox-item-name {
    font-size: var(--fs-sm);
    color: var(--c-text);
}

.combobox-item-clinic {
    font-size: var(--fs-xs);
    color: var(--c-text-muted);
}

.combobox-empty {
    padding: var(--sp-md);
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--c-text-muted);
}

/* === Smooth transitions === */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rowFadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes cardSlideIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@keyframes overlayFadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes modalSlideUp { from { opacity:0; transform:translateY(20px) scale(0.98); } to { opacity:1; transform:translateY(0) scale(1); } }

.data-table tbody tr { animation: rowFadeIn 0.25s ease-out both; }
.data-table tbody tr:nth-child(1){animation-delay:0ms}.data-table tbody tr:nth-child(2){animation-delay:30ms}.data-table tbody tr:nth-child(3){animation-delay:60ms}.data-table tbody tr:nth-child(4){animation-delay:90ms}.data-table tbody tr:nth-child(5){animation-delay:120ms}.data-table tbody tr:nth-child(6){animation-delay:150ms}.data-table tbody tr:nth-child(7){animation-delay:180ms}.data-table tbody tr:nth-child(8){animation-delay:210ms}.data-table tbody tr:nth-child(9){animation-delay:240ms}.data-table tbody tr:nth-child(10){animation-delay:270ms}.data-table tbody tr:nth-child(n+11){animation-delay:300ms}

.state-loading,.state-empty,.state-error { animation: fadeIn 0.3s ease-out; }
.card { animation: cardSlideIn 0.3s ease-out both; }
.card:nth-child(1){animation-delay:0ms}.card:nth-child(2){animation-delay:50ms}.card:nth-child(3){animation-delay:100ms}.card:nth-child(4){animation-delay:150ms}.card:nth-child(5){animation-delay:200ms}.card:nth-child(n+6){animation-delay:250ms}

#patient-search,#doctor-search { transition: border-color 0.2s, box-shadow 0.2s; }
#patient-search:focus,#doctor-search:focus { box-shadow: 0 0 0 3px rgba(52,152,219,0.15); }

.modal-overlay { animation: overlayFadeIn 0.2s ease-out; }
.modal-content { animation: modalSlideUp 0.25s ease-out; }
/* === Test Selection Popup (light theme, 4-column) === */
.test-popup-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.test-col { background: var(--c-surface-alt); border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: 6px; }
.test-cat-header { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--c-primary); padding: 4px 0 3px; border-bottom: 1px solid var(--c-border); margin-bottom: 3px; }
.test-row { display: flex; align-items: center; padding: 2px 0; font-size: 11px; line-height: 1.4; }
.test-row input[type="checkbox"] { width: 13px; height: 13px; margin: 0 5px 0 0; flex-shrink: 0; accent-color: var(--c-primary); cursor: pointer; }
.test-row label { cursor: pointer; flex: 1; color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.test-row .price { color: var(--c-primary); font-size: 10px; flex-shrink: 0; margin-left: 4px; font-weight: 600; }
.test-row.panel-row { font-weight: 600; }
.test-row.panel-row label { color: var(--c-primary); }
.test-row.child-row { padding-left: 16px; }
.test-row.child-row label { color: var(--c-text-muted); font-weight: 400; }
.test-row.child-row .price { color: var(--c-text-muted); font-weight: 400; }
.test-popup-search { width: 100%; background: var(--c-surface); border: 2px solid var(--c-border); border-radius: var(--radius-sm); color: var(--c-text); padding: 6px 10px; font-size: 12px; box-sizing: border-box; }
.test-popup-search:focus { outline: none; border-color: var(--c-focus); }
@media (max-width: 700px) { .test-popup-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 400px) { .test-popup-grid { grid-template-columns: 1fr; } }
/* === Quote modal responsive === */
@media (min-width: 769px) {
    #quote-modal { padding: 24px !important; }
    #quote-modal-inner {
        max-width: 1100px; max-height: calc(100vh - 48px);
        border-radius: var(--radius) !important; margin: auto;
    }
}

@media (max-width: 768px) {
    /* Mobile: stack vertically */
    #quote-form { flex-direction: column !important; }
    #qf-left {
        width: 100% !important; border-right: none !important;
        border-bottom: 1px solid var(--c-border);
        flex-shrink: 0 !important; max-height: 180px;
        flex-direction: row !important; flex-wrap: wrap; gap: 8px !important;
        padding: 12px !important;
    }
    #qf-left .form-group { flex: 1; min-width: 140px; margin: 0; }
    #qf-selected-summary { display: none !important; }
    #quote-form-error { display: none !important; }
    #qf-left > div:last-child { display: none !important; }
    #qf-mobile-footer { display: block !important; }
    /* Test grid: 1 column on mobile */
    .test-popup-grid { grid-template-columns: 1fr !important; }
    /* Bigger touch targets */
    .test-row { padding: 6px 0 !important; font-size: 13px !important; }
    .test-row input[type="checkbox"] { width: 18px !important; height: 18px !important; }
    .test-row .price { font-size: 12px !important; }
    .test-cat-header { font-size: 11px !important; padding: 6px 0 4px !important; }
    /* Panel rows: bold, separated, clearly parent */
    .test-row.panel-row {
        font-weight: 700 !important;
        padding-top: 10px !important;
        border-top: 1px solid var(--c-border);
        margin-top: 6px;
    }
    .test-row.panel-row label {
        color: var(--c-primary) !important;
        font-size: 14px !important;
    }
    .test-row.panel-row .price {
        font-size: 13px !important;
    }
    /* Child rows: indented, muted - clearly subtest */
    .test-row.child-row {
        padding-left: 32px !important;
        padding-top: 4px !important;
        padding-bottom: 4px !important;
    }
    .test-row.child-row label {
        color: var(--c-text-muted) !important;
        font-size: 13px !important;
        font-weight: 400 !important;
    }
    .test-row.child-row .price {
        color: var(--c-text-muted) !important;
        font-weight: 400 !important;
    }
}

@media (max-width: 480px) {
    #qf-left .form-group { min-width: 100% !important; }
}

/* === Print === */
@media print {
    .topbar, .sidebar, .statusbar, .sidebar-toggle, .sidebar-overlay {
        display: none !important;
    }
    .main-area {
        padding: 0;
        overflow: visible;
    }
    .app-shell {
        height: auto;
        overflow: visible;
    }
}
/* === Sidebar SVG icons === */
.sidebar-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    opacity: 0.7;
    transition: opacity var(--t-fast);
}

.sidebar-link:hover .sidebar-icon {
    opacity: 1;
}

.sidebar-link.active .sidebar-icon {
    opacity: 1;
}

/* Coming-soon icons - larger, muted */
.coming-soon-icon {
    font-size: 48px;
}
/* ============================================
   Bottom shortcut bar (mobile only)
   Shows 6 quick-access icons on phones/tablets.
   Hidden on desktop ( - -1024px) where sidebar is always visible.
   Two mobile navigation options:
     1. Hamburger menu - full sidebar (all 10 items)
     2. Bottom bar - 5 most-used + "More" (opens sidebar)
   ============================================ */

.bottom-bar {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: 56px;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    flex-shrink: 0;
    z-index: 90;
    /* Safe area for iPhone notch / Android gesture bar */
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    background: none;
    border: none;
    color: var(--c-text-muted);
    cursor: pointer;
    padding: var(--sp-xs) 0;
    transition: color var(--t-fast);
    min-width: 0;
    -webkit-tap-highlight-color: transparent;
}

.bottom-bar-item:active {
    background: var(--c-surface-alt);
}

.bottom-bar-item.active {
    color: var(--c-primary);
    font-weight: 600;
}

.bottom-bar-label {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Hide bottom bar on desktop - sidebar is always visible there */
@media (min-width: 1024px) {
    .bottom-bar {
        display: none;
    }
}

/* On very small phones, hide labels to save space */
@media (max-width: 360px) {
    .bottom-bar-label {
        display: none;
    }
    .bottom-bar {
        height: 48px;
    }
}
/* === Searchable combobox === */
.combobox {
    position: relative;
    width: 100%;
}

.combobox-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
}

.combobox-dropdown.open {
    display: block;
}

.combobox-item {
    display: flex;
    flex-direction: column;
    padding: var(--sp-sm) var(--sp-md);
    cursor: pointer;
    transition: background var(--t-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.combobox-item:hover, .combobox-item.highlighted {
    background: var(--c-surface-alt);
}

.combobox-item.selected {
    background: var(--c-primary-light);
    font-weight: 600;
}

.combobox-item-name {
    font-size: var(--fs-sm);
    color: var(--c-text);
}

.combobox-item-clinic {
    font-size: var(--fs-xs);
    color: var(--c-text-muted);
}

.combobox-empty {
    padding: var(--sp-md);
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--c-text-muted);
}

/* === Smooth transitions === */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rowFadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes cardSlideIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@keyframes overlayFadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes modalSlideUp { from { opacity:0; transform:translateY(20px) scale(0.98); } to { opacity:1; transform:translateY(0) scale(1); } }

.data-table tbody tr { animation: rowFadeIn 0.25s ease-out both; }
.data-table tbody tr:nth-child(1){animation-delay:0ms}.data-table tbody tr:nth-child(2){animation-delay:30ms}.data-table tbody tr:nth-child(3){animation-delay:60ms}.data-table tbody tr:nth-child(4){animation-delay:90ms}.data-table tbody tr:nth-child(5){animation-delay:120ms}.data-table tbody tr:nth-child(6){animation-delay:150ms}.data-table tbody tr:nth-child(7){animation-delay:180ms}.data-table tbody tr:nth-child(8){animation-delay:210ms}.data-table tbody tr:nth-child(9){animation-delay:240ms}.data-table tbody tr:nth-child(10){animation-delay:270ms}.data-table tbody tr:nth-child(n+11){animation-delay:300ms}

.state-loading,.state-empty,.state-error { animation: fadeIn 0.3s ease-out; }
.card { animation: cardSlideIn 0.3s ease-out both; }
.card:nth-child(1){animation-delay:0ms}.card:nth-child(2){animation-delay:50ms}.card:nth-child(3){animation-delay:100ms}.card:nth-child(4){animation-delay:150ms}.card:nth-child(5){animation-delay:200ms}.card:nth-child(n+6){animation-delay:250ms}

#patient-search,#doctor-search { transition: border-color 0.2s, box-shadow 0.2s; }
#patient-search:focus,#doctor-search:focus { box-shadow: 0 0 0 3px rgba(52,152,219,0.15); }

.modal-overlay { animation: overlayFadeIn 0.2s ease-out; }
.modal-content { animation: modalSlideUp 0.25s ease-out; }
/* === Test Selection Popup (light theme, 4-column) === */
.test-popup-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.test-col { background: var(--c-surface-alt); border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: 6px; }
.test-cat-header { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--c-primary); padding: 4px 0 3px; border-bottom: 1px solid var(--c-border); margin-bottom: 3px; }
.test-row { display: flex; align-items: center; padding: 2px 0; font-size: 11px; line-height: 1.4; }
.test-row input[type="checkbox"] { width: 13px; height: 13px; margin: 0 5px 0 0; flex-shrink: 0; accent-color: var(--c-primary); cursor: pointer; }
.test-row label { cursor: pointer; flex: 1; color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.test-row .price { color: var(--c-primary); font-size: 10px; flex-shrink: 0; margin-left: 4px; font-weight: 600; }
.test-row.panel-row { font-weight: 600; }
.test-row.panel-row label { color: var(--c-primary); }
.test-row.child-row { padding-left: 16px; }
.test-row.child-row label { color: var(--c-text-muted); font-weight: 400; }
.test-row.child-row .price { color: var(--c-text-muted); font-weight: 400; }
.test-popup-search { width: 100%; background: var(--c-surface); border: 2px solid var(--c-border); border-radius: var(--radius-sm); color: var(--c-text); padding: 6px 10px; font-size: 12px; box-sizing: border-box; }
.test-popup-search:focus { outline: none; border-color: var(--c-focus); }
@media (max-width: 700px) { .test-popup-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 400px) { .test-popup-grid { grid-template-columns: 1fr; } }
/* === Quote modal responsive === */
@media (min-width: 769px) {
    #quote-modal { padding: 24px !important; }
    #quote-modal-inner {
        max-width: 1100px; max-height: calc(100vh - 48px);
        border-radius: var(--radius) !important; margin: auto;
    }
}

@media (max-width: 768px) {
    /* Mobile: stack vertically - patient info on top, tests below */
    #quote-form { flex-direction: column !important; }
    #qf-left {
        width: 100% !important; border-right: none !important;
        border-bottom: 1px solid var(--c-border);
        flex-shrink: 0 !important; max-height: 180px;
        flex-direction: row !important; flex-wrap: wrap; gap: 8px !important;
        padding: 12px !important;
        /* Mobile: clear panel vs child indentation */
    .test-row.panel-row { font-weight: 700 !important; padding-top: 8px !important; border-top: 1px solid var(--c-border); margin-top: 4px; }
    .test-row.panel-row label { color: var(--c-primary) !important; font-size: 14px !important; }
    .test-row.child-row { padding-left: 28px !important; }
    .test-row.child-row label { color: var(--c-text-muted) !important; font-size: 13px !important; }
    .test-row.child-row .price { color: var(--c-text-muted) !important; }
}
    #qf-left .form-group { flex: 1; min-width: 140px; margin: 0; }
    #qf-selected-summary { display: none !important; }
    #quote-form-error { display: none !important; }
    #qf-left > div:last-child { display: none !important; } /* hide desktop buttons */
    /* Show mobile footer */
    #qf-mobile-footer { display: block !important; }
    /* Test grid: 1 column on mobile */
    .test-popup-grid { grid-template-columns: 1fr !important; }
    /* Make rows slightly bigger for touch */
    .test-row { padding: 6px 0 !important; font-size: 13px !important; }
    .test-row input[type="checkbox"] { width: 18px !important; height: 18px !important; }
    .test-row .price { font-size: 12px !important; }
    .test-cat-header { font-size: 11px !important; padding: 6px 0 4px !important; }
}

@media (max-width: 480px) {
    #qf-left .form-group { min-width: 100% !important; }
}
/* === Results entry modal === */
.result-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 300; padding: 16px;
}
.result-modal-content {
    background: var(--c-surface); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); max-width: 1100px; width: 100%;
    margin: auto; max-height: calc(100vh - 32px);
    display: flex; flex-direction: column; overflow: hidden;
}
.result-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}
.result-modal-title {
    margin: 0; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.result-modal-close {
    background: none; border: none; font-size: 24px; line-height: 1;
    cursor: pointer; color: var(--c-text-muted); flex-shrink: 0;
    padding: 0 4px;
}
.result-modal-close:hover { color: var(--c-text); }
.result-modal-body {
    flex: 1; display: flex; overflow: hidden; min-height: 0;
}
.result-modal-left {
    width: 320px; flex-shrink: 0; overflow-y: auto;
    border-right: 1px solid var(--c-border); padding: 12px;
    -webkit-overflow-scrolling: touch;
}
.result-modal-right {
    flex: 1; overflow-y: auto; padding: 20px; min-width: 0;
    -webkit-overflow-scrolling: touch;
}
.result-modal-footer {
    padding: 12px 20px; border-top: 1px solid var(--c-border);
    display: flex; justify-content: space-between; align-items: center;
    gap: 8px; flex-shrink: 0; flex-wrap: wrap;
}
.result-modal-footer .btn { flex: 1 1 auto; min-width: 120px; }

/* Results entry modal - tablet: narrow the side column */
@media (max-width: 900px) {
    .result-modal-left { width: 260px; }
    .result-modal-right { padding: 16px; }
}

/* Results entry modal - mobile: stack vertically (test list on top, input below) */
@media (max-width: 768px) {
    .result-modal-overlay { padding: 0; }
    .result-modal-content {
        max-width: 100%; max-height: 100vh; height: 100vh;
        border-radius: 0;
    }
    .result-modal-header { padding: 10px 12px; }
    .result-modal-title { font-size: 15px; }
    .result-modal-body { flex-direction: column; }
    .result-modal-left {
        width: 100%; flex-shrink: 0; max-height: 38vh;
        border-right: none; border-bottom: 1px solid var(--c-border);
        padding: 10px;
    }
    .result-modal-right { padding: 14px; }
    .result-modal-footer { padding: 10px 12px; }
    .result-modal-footer .btn { min-width: 0; }
}

/* Results entry modal - very small phones */
@media (max-width: 380px) {
    .result-modal-left { max-height: 42vh; }
    .result-modal-right { padding: 10px; }
    .result-modal-header { padding: 8px 10px; }
    .result-modal-footer { padding: 8px 10px; }
}

/* Panel child drag-and-drop reorder (AGENTS.md -7) */
.panel-child-row.dragging { opacity: 0.5; border: 2px dashed var(--c-primary) !important; }
.panel-child-row:active { cursor: grabbing; }
.panel-child-list { user-select: none; }

