/* ... keep all existing CSS from the top ... */
h1 { display: none; }
body { font-family: sans-serif; padding: 10px; background-color: var(--tg-theme-bg-color, #fff); color: var(--tg-theme-text-color, #000); }
.ward { margin-bottom: 7px; }
.ward-header { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: #2c3e50; border-bottom: 2px solid #34495e; border-radius: 6px; }
.ward-title { font-weight: bold; font-size: 16px; color: #ecf0f1; flex: 1; }
.patient { display: flex; align-items: center; padding: 4px 5px; gap: 4px; }
.patient span { flex: 1; }
.patient input[type="checkbox"] { margin-right: 10px; display: none; }
.ward-delete-checkbox { display: none; margin-right: 10px; }
body.remove-mode .patient input, body.transfer-mode .patient input, body.delete-ward-mode .ward-delete-checkbox { display: block !important; }
.total-ip-header {
    padding: 10px 15px;
    font-size: 18px;
    font-weight: bold;
    color: var(--tg-theme-text-color, #000);
    background-color: var(--tg-theme-secondary-bg-color, #f0f0f0);
    border-radius: 8px;
    margin: 0 0 15px 0;
    text-align: center;
    line-height: 1.4; /* ✅ ADD THIS LINE for better spacing */
}
#patient-list-container { padding-bottom: 80px; }
.scrollable-controls { padding-top: 20px; }
.ward-controls { display: flex; gap: 10px; margin-bottom: 10px; }
#add-new-ward-btn, #delete-ward-btn { flex: 1; padding: 12px; font-size: 16px; font-weight: bold; color: #ecf0f1; background-color: #34495e; border: none; border-radius: 8px; cursor: pointer; }
#recently-deleted-btn, #retry-failed-uploads-btn { display: block; width: 75%; margin: 0 auto 10px; padding: 12px; font-size: 16px; font-weight: bold; color: #ecf0f1; background-color: #34495e; border: none; border-radius: 8px; cursor: pointer; }
#retry-failed-uploads-btn { background-color: #8e44ad; }
.fixed-controls { position: fixed; bottom: 0; left: 0; right: 0; padding: 10px; background: var(--tg-theme-secondary-bg-color, #f0f0f0); z-index: 10; display: flex; gap: 10px; border-top: 1px solid #ccc; }
#remove-btn, #transfer-btn, #submit-btn, #cancel-btn { flex: 1; padding: 12px; font-size: 16px; color: white; border: none; border-radius: 8px; }
#remove-btn, #transfer-btn { background-color: #2980b9; }
#submit-btn { background-color: #27ae60; }
#cancel-btn { background-color: #c0392b; }
.flash-message { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); padding: 12px 20px; border-radius: 8px; color: #fff; background-color: #27ae60; z-index: 2000; opacity: 0; transition: all 0.3s ease; }
.flash-message.show { opacity: 1; bottom: 90px; }
.flash-message.error { background-color: #c0392b; }
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.7); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: var(--tg-theme-bg-color, #fff); padding: 20px; border-radius: 10px; width: 90%; max-width: 400px; }
.modal-content h2 { margin-top: 0; color: var(--tg-theme-text-color, #000); }
.modal-content button { width: 100%; padding: 10px; margin-top: 10px; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; color: white; }
#ward-list-buttons button { background-color: #2980b9; margin-bottom: 5px; }
#cancel-transfer-btn { background-color: #c0392b; }

.admission-type-modal-content p { margin: 0 0 8px; }
#add-regular-patient-btn { background-color: #2980b9; }
#add-new-admission-btn { background-color: #27ae60; }
#cancel-admission-type-btn { background-color: #c0392b; }

/* ✅ CRITICAL FIX: Add this rule to style the "Close" button */
#cancel-deleted-btn {
    background-color: #c0392b; /* Same red as the other cancel button */
}

#deleted-patient-list { max-height: 40vh; overflow-y: auto; }
.deleted-patient-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 5px; border-bottom: 1px solid var(--tg-theme-secondary-bg-color, #eee); }
.redo-btn { background-color: #27ae60; color: white; width: auto; padding: 5px 12px; font-size: 14px; border-radius: 5px; cursor: pointer; }

/* Full-screen camera overlay (getUserMedia) */
#camera-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: #000; z-index: 3000; display: flex; flex-direction: column; align-items: center; justify-content: space-between; }
#camera-preview { width: 100%; flex: 1; object-fit: cover; display: block; }
.capture-count-badge { position: absolute; top: 16px; right: 16px; background: rgba(0,0,0,0.6); color: white; padding: 4px 12px; border-radius: 20px; font-size: 14px; font-weight: bold; z-index: 3001; }
.camera-controls { position: absolute; bottom: 0; left: 0; right: 0; z-index: 3005; display: flex; align-items: center; justify-content: space-around; padding: 20px 16px 100px; padding-bottom: calc(100px + env(safe-area-inset-bottom)); background: rgba(0,0,0,0.7); }
#shutter-btn { width: 72px; height: 72px; border-radius: 50%; background: white; border: 5px solid rgba(255,255,255,0.5); cursor: pointer; flex-shrink: 0; }
#shutter-btn:active { background: #ccc; transform: scale(0.93); }
#close-camera-btn, #done-camera-btn { padding: 10px 20px; border: none; border-radius: 8px; font-size: 15px; font-weight: bold; cursor: pointer; color: white; width: auto; margin: 0; }
#close-camera-btn { background: rgba(192,57,43,0.85); }
#done-camera-btn  { background: rgba(39,174,96,0.9); }

/* Tap-to-focus ring */
#focus-ring {
    position: fixed;
    width: 64px;
    height: 64px;
    border: 2px solid #ffe066;
    border-radius: 6px;
    pointer-events: none;
    z-index: 3002;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}
#focus-ring.focusing {
    animation: focus-in 0.45s ease-out forwards;
}
@keyframes focus-in {
    0%   { transform: scale(1.6); opacity: 0.5; border-color: #fff; }
    60%  { transform: scale(0.95); opacity: 1; border-color: #ffe066; }
    100% { transform: scale(1); opacity: 1; border-color: #ffe066; }
}

/* Camera button on each patient row */
.camera-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    line-height: 1;
    color: var(--tg-theme-text-color, #555);
    opacity: 0.7;
}
.camera-btn:active { opacity: 1; background: rgba(0,0,0,0.08); }
body.remove-mode .camera-btn,
body.transfer-mode .camera-btn,
body.delete-ward-mode .camera-btn { display: none; }

/* Investigation modal */
.investigation-modal-content { max-height: 88vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.investigation-patient-label { margin: 0; font-weight: bold; font-size: 15px; color: var(--tg-theme-text-color, #333); }
.investigation-capture-buttons { display: flex; gap: 8px; }
.investigation-capture-buttons button { flex: 1; padding: 10px; font-size: 15px; font-weight: bold; background-color: #2980b9; color: white; border: none; border-radius: 8px; cursor: pointer; }
.image-previews { display: flex; flex-wrap: wrap; gap: 8px; min-height: 0; }
.preview-item { position: relative; width: 80px; height: 80px; }
.preview-item img { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; border: 2px solid #34495e; }
.remove-preview-btn { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: #c0392b; color: white; border: none; font-size: 14px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
#investigation-comment { width: 100%; box-sizing: border-box; padding: 10px; border-radius: 8px; border: 1px solid #ccc; font-size: 14px; resize: none; background: var(--tg-theme-secondary-bg-color, #f0f0f0); color: var(--tg-theme-text-color, #000); }
.investigation-actions { display: flex; gap: 10px; }
#send-investigation-btn { flex: 2; padding: 12px; background-color: #27ae60; color: white; border: none; border-radius: 8px; font-size: 16px; font-weight: bold; cursor: pointer; }
#cancel-investigation-btn { flex: 1; padding: 12px; background-color: #c0392b; color: white; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; }

.hidden { display: none !important; }
