/* Slide panel & forms: inputs, selects, textareas, buttons, balance calc. */

.slide-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.18);
    z-index: 20000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.slide-panel-overlay.show {
    opacity: 1;
    visibility: visible;
}

.slide-panel {
    position: fixed;
    top: 0;
    right: -90%;
    bottom: 0;
    width: 90%;
    max-width: 900px;
    background: transparent;
    z-index: 20001;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    transition: right 0.3s ease;
    overflow: visible;
}

.slide-panel.wide {
    max-width: 1200px;
}

/* Stacked on top of another open panel (e.g. invoice preview over close-shift) */
.slide-panel-overlay.over { z-index: 20010; background: transparent; }
.slide-panel.over         { z-index: 20011; max-width: 1000px; }

.slide-panel-content {
    flex: 1;
    position: relative;
    z-index: 1;
    background: white;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.12);
    transition: right 0.3s ease;
    overflow: hidden;
}

.slide-panel-left-strip,
.slide-panel-left-close {
    width: 28px;
    flex-shrink: 0;
    background: #f5f5f5;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}

.slide-panel-left-strip:hover,
.slide-panel-left-close:hover {
    background: #e0e0e0;
}

.slide-panel-left-strip i,
.slide-panel-left-close i {
    font-size: 0.75rem;
    color: #adb5bd;
    transition: color 0.2s;
}

.slide-panel-left-strip:hover i,
.slide-panel-left-close:hover i {
    color: var(--calendar-green);
}

.slide-panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

.slide-panel.show {
    right: 0;
}


.slide-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: white;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.slide-panel-title-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.slide-panel-icon {
    font-size: 1.3rem;
    color: var(--calendar-green);
}

.slide-panel-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.slide-panel-close {
    width: 40px;
    height: 40px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #666;
}

.slide-panel-close:hover {
    background: #e0e0e0;
    color: #333;
}

.slide-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem 1.5rem 1.5rem;
    /* Better mobile scrolling */
    -webkit-overflow-scrolling: touch;
}

/* Detail / profile views go edge-to-edge — sections control own padding */
.slide-panel-body:has(.apt-detail-view),
.slide-panel-body:has(.ph-panel) {
    padding: 0;
}

.slide-panel-body::-webkit-scrollbar {
    width: 6px;
}

.slide-panel-body::-webkit-scrollbar-track {
    background: transparent;
}

.slide-panel-body::-webkit-scrollbar-thumb {
    background: var(--calendar-green);
    border-radius: 3px;
}

.slide-panel-body::-webkit-scrollbar-thumb:hover {
    background: var(--calendar-green-dark);
}

.slide-panel-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--calendar-green);
    font-size: 28px;
}

/* Form sections */

.form-section {
    margin-bottom: 2rem;
}

.form-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light-bg);
}

.form-section-title i {
    color: var(--calendar-green);
}

.form-section-collapsed .form-section-title {
    opacity: 0.6;
}

.section-badge {
    margin-left: auto;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row.single {
    grid-template-columns: 1fr;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.85rem;
}

.form-label .required {
    color: #ef4444;
}

.form-helper {
    display: block;
    margin-top: 0.25rem;
    color: #666;
    font-size: 0.85rem;
    font-style: italic;
}

/* Patient Search Dropdown */
.patient-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
}

.patient-search-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.patient-search-item:last-child {
    border-bottom: none;
}

.patient-search-item:hover {
    background: #f8f9fa;
}

.patient-search-item.no-results {
    text-align: center;
    color: #999;
    cursor: default;
}

.patient-search-item.no-results:hover {
    background: white;
}

.patient-search-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.patient-search-name i {
    color: var(--calendar-green);
}

.patient-search-details {
    display: flex;
    gap: 0.75rem;
    font-size: 12px;
    color: #666;
    flex-wrap: wrap;
}

.patient-search-code {
    background: #e3f2fd;
    color: #1976d2;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.patient-search-age {
    color: #666;
}

.patient-search-phone {
    color: #666;
}

/* Form Inputs */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    background: white;
    color: var(--text-dark);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: #c0c5cc;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--calendar-green);
    box-shadow: 0 0 0 3px rgba(0, 179, 0, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Register-patient: the Is International / Is Foreigner toggles sit in a field slot, matching sibling input height. */
.reg-check-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    min-height: 36px;
    padding: 4px 2px;
}
.reg-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
}
.reg-check input { width: 16px; height: 16px; cursor: pointer; }

/* Locked provider field (a doctor booking their own slot): keep it solid black so it reads as a
   value, not a dimmed control. -webkit-text-fill-color is needed to override the WebKit gray. */
#appointmentForm .form-input:disabled,
#createPatientForm .form-input:disabled {
    color: #111827;
    -webkit-text-fill-color: #111827;
    opacity: 1;
}

/* Select dropdown */
.form-select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.form-select:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2300b300' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
}

/* Input with icon (date, time) */
.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper > i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 1;
    transition: color 0.2s;
}

.input-icon-wrapper:focus-within > i {
    color: var(--calendar-green);
}

.input-icon-wrapper > .form-input {
    padding-left: 2.2rem;
}

/* Premium styling for native date/time picker fields */
/* 3-column layout for date + start time + end time */
.form-row-3col {
    grid-template-columns: 1.5fr 1fr 1fr;
}

.picker-field {
    position: relative;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.picker-field:hover {
    border-color: #a7d7af;
    box-shadow: 0 3px 10px rgba(0, 179, 0, 0.10);
}

.picker-field:focus-within {
    border-color: var(--calendar-green);
    box-shadow: 0 0 0 3px rgba(0, 179, 0, 0.13);
}

.picker-field > .form-input.native-date-input,
.picker-field > .form-input.native-time-input {
    cursor: pointer;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding-right: 0.5rem;
}

.picker-field > .form-input.native-date-input:hover,
.picker-field > .form-input.native-time-input:hover,
.picker-field > .form-input.native-date-input:focus,
.picker-field > .form-input.native-time-input:focus {
    border: 0;
    box-shadow: none;
    outline: none;
}

/* Remove custom chevron — let native browser indicator show cleanly */
.picker-field::after {
    display: none;
}

/* Style native calendar/clock picker indicator to match theme */
.picker-field input[type="date"]::-webkit-calendar-picker-indicator,
.picker-field input[type="time"]::-webkit-calendar-picker-indicator {
    opacity: 0.35;
    cursor: pointer;
    border-radius: 4px;
    padding: 3px;
    transition: opacity 0.2s, filter 0.2s;
}

.picker-field:hover input[type="date"]::-webkit-calendar-picker-indicator,
.picker-field:hover input[type="time"]::-webkit-calendar-picker-indicator,
.picker-field:focus-within input[type="date"]::-webkit-calendar-picker-indicator,
.picker-field:focus-within input[type="time"]::-webkit-calendar-picker-indicator {
    opacity: 1;
    filter: invert(40%) sepia(80%) saturate(4) hue-rotate(100deg) brightness(0.85);
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

/* Pinned footer: action buttons move out of the scrolling body so they stay put and the body gets full height. */
.slide-panel-footer {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid var(--border-color);
    padding: 0.85rem 1.5rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.06);
}
/* Inside the footer the divider/spacing comes from the footer itself. */
.slide-panel-footer .form-actions {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* Enhanced form components */

.prefilled-info-box {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.prefilled-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    margin-bottom: 14px;
    font-size: 15px;
    opacity: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.prefilled-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prefilled-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.prefilled-item:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateX(2px);
}

.prefilled-item i {
    width: 20px;
    text-align: center;
    font-size: 14px;
}

.prefilled-item strong {
    min-width: 70px;
    font-weight: 500;
}

.prefilled-value {
    flex: 1;
    font-weight: 600;
}

.btn-unlock {
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.3s ease;
    margin-left: auto;
    font-weight: 500;
}

.btn-unlock:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-unlock i {
    font-size: 10px;
}

/* Conflict Warning */
#conflictWarning {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
}

.conflict-warning-box {
    background: #fef3cd;
    border: 1px solid #f0ad4e;
    color: #856404;
}

.conflict-error-box {
    background: #f8d7da;
    border: 1px solid #dc3545;
    color: #721c24;
}

.conflict-success-box {
    background: #d1ecf1;
    border: 1px solid #17a2b8;
    color: #0c5460;
}

.conflict-title {
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.conflicting-apt {
    background: rgba(0, 0, 0, 0.05);
    padding: 6px 10px;
    border-radius: 4px;
    margin: 6px 0;
    font-size: 12px;
}

.alt-time-suggestions {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.alt-time-btn {
    padding: 4px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.alt-time-btn:hover {
    background: #f0f0f0;
    border-color: #007bff;
}

.conflict-warning {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    color: #92400e;
}

.conflict-warning i {
    color: #f59e0b;
    margin-right: 0.5rem;
}

.conflict-warning ul {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

.conflict-warning li {
    margin: 0.25rem 0;
}

/* Searchable select: same pattern as the header's provider filter. */

.searchable-select {
    position: relative;
}

/* Trigger button — matches .form-select */
.searchable-select-trigger {
    width: 100%;
    padding: 0.55rem 0.75rem;
    padding-right: 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    text-align: left;
    transition: all 0.2s;
    position: relative;
}

.searchable-select-trigger:hover {
    border-color: var(--calendar-green);
    background: #f0fdf4;
}

.searchable-select-trigger:focus {
    outline: none;
    border-color: var(--calendar-green);
    box-shadow: 0 0 0 3px rgba(0, 179, 0, 0.1);
}

.searchable-select-trigger .searchable-select-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.searchable-select-trigger.is-placeholder .searchable-select-text {
    color: #9ca3af;
}

.searchable-select-trigger > i {
    position: absolute;
    right: 12px;
    font-size: 0.6rem;
    color: #666;
    transition: transform 0.2s;
}

.searchable-select.is-open .searchable-select-trigger > i {
    transform: rotate(180deg);
}

/* Dropdown — fixed positioned below the trigger via JS */
.searchable-select-dropdown {
    display: none;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    overflow: hidden;
}

.searchable-select.is-open .searchable-select-dropdown {
    display: block;
}

/* Search row at top of dropdown */
.searchable-select-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid #f3f4f6;
}

/* Non-searchable variant: same trigger width/style, just no search box. */
.searchable-select.ss-no-search .searchable-select-search { display: none; }

.searchable-select-search i {
    color: #9ca3af;
    font-size: 0.9rem;
}

.searchable-select-search input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.85rem;
    font-family: inherit;
    color: #374151;
    background: transparent;
}

.searchable-select-search input::placeholder {
    color: #9ca3af;
}

/* Options list */
.searchable-select-list {
    max-height: 240px;
    overflow-y: auto;
    padding: 0.5rem;
}

.searchable-select-hint {
    padding: 6px 12px;
    color: #94a3b8;
    font-size: 12px;
    text-align: center;
}

.searchable-select-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: #374151;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}

.searchable-select-item:hover {
    background: #f0fdf4;
    color: #16a34a;
}

.searchable-select-item.is-selected {
    background: #f0fdf4;
    color: var(--text-dark);
    font-weight: 500;
}

.searchable-select-item.search-hidden {
    display: none;
}

/* Already has a card → not selectable (must remove the existing card first). */
.searchable-select-item.is-disabled {
    color: #9ca3af;
    cursor: not-allowed;
}
.searchable-select-item.is-disabled:hover {
    background: transparent;
    color: #9ca3af;
}

/* Inline new patient */
.searchable-select-new-patient {
    padding: 6px 8px;
    border-bottom: 1px solid #f1f5f9;
    background: #fafbff;
}
.ss-new-patient-btn {
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #2563eb;
    background: #eff6ff;
    border: 1px dashed #93c5fd;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    transition: background .15s, border-color .15s;
}
.ss-new-patient-btn:hover {
    background: #dbeafe;
    border-color: #60a5fa;
}
.ss-new-patient-btn i { font-size: 11px; }

.ss-new-patient-form {
    margin-top: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.ss-new-patient-form::before {
    content: "New Patient";
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #6b7280;
}

.ss-np-name,
.ss-np-phone,
.ss-np-gender,
.np-f-name,
.np-f-phone,
.np-f-gender {
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    font-family: inherit;
    color: #111827;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.ss-np-name::placeholder,
.ss-np-phone::placeholder,
.np-f-name::placeholder,
.np-f-phone::placeholder { color: #9ca3af; }
.ss-np-gender:invalid { color: #9ca3af; }

/* Gender <select>: strip the native chrome for the same gray chevron the searchable-selects use (fa-chevron-down, #666). */
.ss-np-gender,
.np-f-gender {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    padding-right: 26px;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 11px;
}
/* Match the app's green focus accent; the chevron stays gray, like the searchable-select triggers. */
.ss-np-name:focus,
.ss-np-phone:focus,
.ss-np-gender:focus,
.np-f-name:focus,
.np-f-phone:focus,
.np-f-gender:focus {
    border-color: var(--calendar-green);
    box-shadow: 0 0 0 3px rgba(0, 179, 0, 0.15);
}

.ss-np-name.is-invalid,
.ss-np-phone.is-invalid,
.ss-np-gender.is-invalid,
.np-f-name.is-invalid,
.np-f-phone.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239,68,68,.12);
}

.ss-np-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.ss-np-row .ss-np-phone { flex: 1; }

.ss-np-save,
.np-f-done {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: #16a34a;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    transition: background .15s, transform .05s;
}
.ss-np-save:hover,
.np-f-done:hover { background: #15803d; }
.ss-np-save:active,
.np-f-done:active { transform: translateY(1px); }
.np-f-done { align-self: flex-end; }

/* "NEW" badge for a stashed patient not saved yet (created on appointment submit). */
.ss-new-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    background: #16a34a;
    border-radius: 999px;
    vertical-align: middle;
}

/* Patient field for a check-in with no chart — it STANDS IN for the picker (initNewPatientCard), so it
   reads as a field first and a notice second. The summary line makes the guessed gender correctable. */
.np-card {
    border: 1px solid #86efac;
    border-radius: 8px;
    background: #f0fdf4;
    overflow: hidden;
}
.np-card-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background .15s;
}
.np-card-trigger:hover { background: #dcfce7; }

.np-card-summary { flex: 1; min-width: 0; }
.np-card-name,
.np-card-meta {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.np-card-name { font-size: 14px; color: var(--text-dark); }
.np-card-meta { margin-top: 2px; font-size: 11px; color: #166534; }

.np-card-action {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    background: #16a34a;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
}
.np-card.is-editing .np-card-action { background: #6b7280; }

.np-card-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid #bbf7d0;
    background: #fff;
}
.np-card-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.np-card-row .np-f-gender { flex: 0 0 110px; }
.np-card-row .np-f-phone  { flex: 1; }

/* Matches .searchable-select.is-invalid — the submit marks whichever patient control was rendered. */
.np-card.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Validation error state */
.searchable-select.is-invalid .searchable-select-trigger {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Native date/time input enhancements. Keep browser picker UI with app styling. */

.form-input.native-date-input,
.form-input.native-time-input {
    min-height: 42px;
}

.form-input.native-date-input::-webkit-calendar-picker-indicator,
.form-input.native-time-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.75;
    filter: hue-rotate(65deg) saturate(1.6);
}

.form-input.native-date-input::-webkit-calendar-picker-indicator:hover,
.form-input.native-time-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Payment modal patterns */
.pay-modal-body    { padding: 16px 20px; overflow-y: auto; flex: 1; }
.pay-items-box     { border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; margin-bottom: 16px; max-height: 160px; overflow-y: auto; }
.pay-item-empty    { color: #6b7280; font-style: italic; }
.pay-discount-input { width: 110px; text-align: right; padding: 6px 10px; font-size: 13px; }
.pay-amount-input  { text-align: right; font-size: 15px; font-weight: 600; }
.pay-method-list   { display: flex; gap: 8px; }
.pay-info-subtext  { opacity: 0.7; font-weight: 400; font-size: 13px; margin-left: 4px; }
.pay-form-icon     { margin-right: 6px; color: var(--calendar-green); }

/* Add-item modal (services/products) */
.aim-overlay   { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 30000; display: flex; align-items: center; justify-content: center; }
.aim-card      { background: #fff; border-radius: 12px; padding: 24px; min-width: 360px; max-width: 480px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.aim-header    { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.aim-title     { margin: 0; font-size: 16px; font-weight: 700; }
.aim-title .fa-stethoscope  { color: #f59e0b; margin-right: 8px; }
.aim-title .fa-shopping-cart { color: #8b5cf6; margin-right: 8px; }
.aim-close     { background: none; border: none; cursor: pointer; font-size: 20px; color: #9ca3af; line-height: 1; }
.aim-fields    { display: flex; flex-direction: column; gap: 14px; }
.aim-label     { font-size: 12px; font-weight: 600; color: #374151; display: block; margin-bottom: 4px; }
.aim-required  { color: #dc2626; }
.aim-select,
.aim-input     { width: 100%; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; box-sizing: border-box; }
.aim-grid-2    { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.aim-footer    { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.aim-cancel    { padding: 8px 16px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px; cursor: pointer; font-size: 14px; }
.aim-submit    { padding: 8px 16px; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; }
.aim-submit i  { margin-right: 4px; }
.aim-submit-svc { background: #f59e0b; }
.aim-submit-prd { background: #8b5cf6; }

/* In-panel payment form */
.pay-panel-body   { flex: 1; overflow-y: auto; padding: 16px 20px; }
.pay-panel-info   { margin: 14px 20px 0; border-radius: 10px; }
.pay-panel-items  { border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; margin-bottom: 16px; max-height: 180px; overflow-y: auto; }
.pay-panel-title  { font-size: 14px; font-weight: 700; color: #374151; }
.pay-panel-cancel { flex: 1; padding: 9px; border: 1.5px solid #e2e8f0; border-radius: 8px; background: #fff; color: #374151; font-size: 13px; font-weight: 600; cursor: pointer; }
.pay-panel-confirm { flex: 2; padding: 9px; border: none; border-radius: 8px; background: #16a34a; color: #fff; font-size: 13px; font-weight: 700; cursor: pointer; }

/* Responsive / phone (≤ 640px) */

@media (max-width: 640px) {

    /* Panel shell */
    .slide-panel { width: 100%; right: -100%; }
    .slide-panel-left-close,
    .slide-panel-left-strip { display: none; }
    .slide-panel-header { padding: 0.6rem 0.9rem; }
    .slide-panel-body { padding: 0.6rem 0.6rem 1rem; }

    /* Form sections: comfortable cards */
    .form-section {
        padding: 14px 14px;
        border-radius: 10px;
        margin-bottom: 12px;
    }
    .form-section-title {
        font-size: 14px;
        font-weight: 700;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        margin-bottom: 10px;
        padding-bottom: 7px;
    }

    /* Form rows */
    /* Balanced field spacing: every gap, stacked or between rows, is the same 12px. Spacing comes only
       from the row gap/margin, never per-field margins, so they can't double up. */
    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 12px;
    }
    /* date+times: date full-width, times side-by-side */
    .form-row-3col {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 12px;
    }
    .form-row-3col .form-group:first-child { grid-column: 1 / -1; }
    .form-row:last-child { margin-bottom: 0; }

    /* Field spacing — handled by the rows, not the individual groups */
    .form-group { margin-bottom: 0; }

    /* Labels */
    .form-label { font-size: 13px; margin-bottom: 5px; }

    /* Inputs/selects (16px font prevents iOS auto-zoom) */
    .form-input,
    .form-select,
    .form-textarea,
    .searchable-select-trigger,
    .ss-np-name, .ss-np-phone, .ss-np-gender {
        font-size: 16px;
        padding: 0.5rem 0.7rem;
        min-height: 44px;
        border-radius: 8px;
    }
    .form-select { padding-right: 2rem; }
    .searchable-select-trigger { padding-right: 2rem; }
    /* The mobile padding shorthand wipes the gender select's right padding, so give it back and move the arrow in. */
    .ss-np-gender {
        padding-right: 2rem;
        background-position: right 0.75rem center;
    }

    .form-textarea { min-height: 60px; resize: none; }

    /* picker-field: match form-select styling */
    .picker-field { border-width: 1px; border-radius: 8px; }
    .form-input.native-date-input,
    .form-input.native-time-input { min-height: 44px; padding: 0.5rem 0.6rem; }

    /* Picker triggers carry a 13px base; force the same 16px as the other inputs so the row matches on phones. */
    .dp-trigger.form-input,
    .tp-trigger.form-input,
    .dp-trigger.form-input .dp-trigger-label { font-size: 16px; }

    /* Appointment form fills the panel height: Notes absorbs the leftover space, so it fits without scrolling. */
    .slide-panel-body:has(#appointmentForm) { display: flex; flex-direction: column; }
    #appointmentForm {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }
    /* Last section and its Notes row grow to fill; the extra bottom padding leaves room under the Notes box. */
    #appointmentForm .form-section:last-of-type {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        padding-bottom: 24px;
    }
    #appointmentForm .form-section:last-of-type .form-row.single:last-child,
    #appointmentForm .form-section:last-of-type .form-row.single:last-child .form-group {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    #appointmentForm .form-textarea { flex: 1 1 auto; }

    /* Searchable select dropdown */
    .searchable-select-dropdown { max-width: 100vw; }
    .searchable-select-search { padding: 6px 8px; }
    .searchable-select-search input { font-size: 14px; padding: 0.3rem 0.5rem; min-height: 30px; }
    .searchable-select-item { font-size: 13px; padding: 0.45rem 0.75rem; }
    .searchable-select-list { max-height: 160px; }

    /* Form actions: full-width buttons */
    .form-actions { padding-top: 8px; margin-top: 2px; gap: 8px; }
    .form-actions .btn { flex: 1; justify-content: center; padding: 0.7rem 1rem; font-size: 15px; }
}
