/* ==========================================================================
   CareClock (智慧同心圓照護鐘) - Premium Mobile Healthcare CSS
   ========================================================================== */

:root {
  /* Color Palette - Modern Medical & Warm Care */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  
  --primary-50: #f0f9ff;
  --primary-100: #e0f2fe;
  --primary-500: #0ea5e9;
  --primary-600: #0284c7;
  --primary-700: #0369a1;

  --turn-left: #38bdf8;
  --turn-center: #10b981;
  --turn-right: #f59e0b;

  --danger-50: #fef2f2;
  --danger-100: #fee2e2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;

  --feed-color: #8b5cf6;
  --feed-bg: #f5f3ff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-focus: #38bdf8;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.12);
  --shadow-glow-danger: 0 0 16px rgba(239, 68, 68, 0.35);
  
  --font-main: 'Plus Jakarta Sans', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background-color: #0f172a; /* Outer backdrop for desktop preview */
  color: var(--text-main);
  line-height: 1.5;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Mobile Application Frame */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.3);
  padding-bottom: 74px; /* Space for bottom navigation */
}

/* Top App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding: 10px 14px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.patient-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.patient-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.patient-name-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.patient-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  color: #059669;
  margin-top: 1px;
  white-space: nowrap;
}

.status-badge.danger {
  color: var(--danger-600);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: #10b981;
  border-radius: var(--radius-full);
  animation: pulseGreen 1.8s infinite;
}

.status-badge.danger .pulse-dot {
  background-color: var(--danger-500);
  animation: pulseRed 1.2s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulseRed {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8); }
  70% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.header-action-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 5px 9px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.2s ease;
  white-space: nowrap;
  touch-action: manipulation;
}

.header-action-btn:active {
  transform: scale(0.92);
  background: #e2e8f0;
}

.header-action-btn .action-icon {
  font-size: 13px;
}

.header-action-btn.mode-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  font-size: 14px;
}

/* Danger Alert Banner (Anti-choking safety buffer) */
.danger-banner {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border-left: 4px solid var(--danger-500);
  padding: 10px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 16px 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-glow-danger);
  animation: slideDown 0.3s ease;
}

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

.danger-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.danger-content strong {
  display: block;
  font-size: 13px;
  color: #991b1b;
  font-weight: 700;
}

.danger-content p {
  font-size: 12px;
  color: #b91c1c;
  margin-top: 2px;
  line-height: 1.35;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 12px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Clock Card & SVG Concentric Rings */
.clock-section {
  width: 100%;
}

.clock-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 14px 12px 16px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.concentric-clock-wrapper {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
  position: relative;
}

.clock-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.outer-dial-bg {
  fill: #ffffff;
  stroke: #e2e8f0;
  stroke-width: 2;
}

.hour-tick {
  stroke: #cbd5e1;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.hour-tick-major {
  stroke: #64748b;
  stroke-width: 2.5;
}

.hour-num {
  font-size: 12px;
  font-weight: 700;
  fill: #475569;
  text-anchor: middle;
  dominant-baseline: central;
}

.center-core {
  fill: url(#clockCenterGlow);
  stroke: #cbd5e1;
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.06));
}

.center-posture-icon {
  font-size: 26px;
}

.center-posture-text {
  font-size: 12px;
  font-weight: 800;
  fill: var(--text-main);
}

.center-time-digital {
  font-size: 14px;
  font-weight: 900;
  fill: var(--primary-700);
}

.center-sub-hint {
  font-size: 9.5px;
  font-weight: 600;
  fill: var(--text-muted);
}

.hour-hand {
  stroke: #0369a1;
  stroke-width: 4.5;
  stroke-linecap: round;
}

.minute-hand {
  stroke: #0284c7;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.hand-cap {
  fill: #0284c7;
  stroke: #ffffff;
  stroke-width: 2;
}

/* Legend below clock */
.ring-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
  width: 100%;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
}

.dot-turn-l { background-color: var(--turn-left); }
.dot-turn-c { background-color: var(--turn-center); }
.dot-turn-r { background-color: var(--turn-right); }
.dot-feeding { background-color: var(--feed-color); }
.dot-danger { 
  background: repeating-linear-gradient(45deg, #ef4444, #ef4444 3px, #fecaca 3px, #fecaca 6px);
}

/* Countdown Cards Grid */
.countdowns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.countdown-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.countdown-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.card-turnover::before {
  background: linear-gradient(90deg, var(--turn-left), var(--turn-right));
}

.card-feeding::before {
  background: linear-gradient(90deg, #8b5cf6, #ec4899);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
}

.turn-badge { color: #0284c7; }
.feed-badge { color: #7c3aed; }

.badge-icon {
  font-size: 16px;
}

.interval-tag {
  font-size: 11px;
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
}

/* Full Width Countdowns Stack (Spacious Single Column for Mobile) */
.countdowns-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.full-width-card {
  width: 100%;
  padding: 16px 18px;
}

.countdown-main-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 4px 0 6px;
}

.countdown-time {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.countdown-target-box {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  background: var(--bg-card-subtle);
  padding: 4px 10px;
  border-radius: 6px;
}

.target-label {
  color: var(--text-muted);
  font-weight: 600;
}

.target-val {
  color: var(--text-main);
  font-size: 16px;
  font-weight: 800;
}

.card-tasks-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.task-chip {
  background: #ecfdf5;
  color: #059669;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.card-formula-preview {
  margin-top: 2px;
}

.formula-chip {
  background: #f5f3ff;
  color: #6d28d9;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-block;
  font-weight: 700;
  font-size: 13px;
}

/* Quick Action Check-in Section */
.quick-actions-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.actions-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title {
  font-size: 15px;
  font-weight: 800;
  color: #334155;
}

.voice-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Full Width Action Buttons Stack */
.action-buttons-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.full-width-btn {
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  text-align: left;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.full-width-btn:active {
  transform: translateY(2px) scale(0.98);
}

.btn-turnover {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
}

.btn-feeding {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #ffffff;
}

.btn-icon-wrapper {
  font-size: 28px;
  background: rgba(255, 255, 255, 0.22);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-text-content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.btn-main-text {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.btn-sub-text {
  font-size: 12px;
  opacity: 0.9;
  margin-top: 3px;
}

.btn-arrow-right {
  font-size: 18px;
  font-weight: 900;
  opacity: 0.8;
}

/* Patient Title Row with Cloud Sync Button */
.patient-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-status-pill {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sync-cloud-icon {
  font-size: 12px;
}

/* Cloud Sync Modal Dialog */
.sync-dialog-box {
  width: 92%;
  max-width: 400px;
}

.room-input-group {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.room-action-btn {
  background: var(--primary-600);
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.sync-share-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.share-box-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
}

.share-url-row {
  display: flex;
  gap: 6px;
}

.share-input {
  font-size: 12px;
  font-weight: 600;
  background: #ffffff;
}

.copy-btn {
  background: #059669;
}

.share-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.35;
}

.sync-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #059669;
  font-weight: 700;
  margin: 4px 0;
}

  line-height: 1.2;
}

.btn-sub-text {
  font-size: 10px;
  opacity: 0.85;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Timeline & Schedule Section */
.timeline-section, .history-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--primary-600);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.log-count {
  font-size: 11px;
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.timeline-container {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 14px;
}

.timeline-container::before {
  content: '';
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 6px;
  width: 2px;
  background: #e2e8f0;
}

.timeline-item {
  position: relative;
  padding-bottom: 14px;
  padding-left: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-node {
  position: absolute;
  left: -13px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background: #ffffff;
  border: 3px solid #94a3b8;
  z-index: 2;
}

.timeline-item.node-turn-l .timeline-node { border-color: var(--turn-left); }
.timeline-item.node-turn-c .timeline-node { border-color: var(--turn-center); }
.timeline-item.node-turn-r .timeline-node { border-color: var(--turn-right); }
.timeline-item.node-feed .timeline-node { border-color: var(--feed-color); }
.timeline-item.node-danger .timeline-node { 
  border-color: var(--danger-500); 
  background-color: var(--danger-100);
}

.timeline-content-card {
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.timeline-item.node-danger .timeline-content-card {
  background: #fef2f2;
  border: 1px dashed #fca5a5;
}

.t-time-tag {
  font-weight: 800;
  color: var(--text-main);
  min-width: 48px;
}

.t-desc {
  flex: 1;
  margin-left: 8px;
  font-weight: 600;
}

.t-badge-flag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.t-badge-danger {
  background: #fee2e2;
  color: #dc2626;
}

.t-badge-smart {
  background: #dbeafe;
  color: #1d4ed8;
}

/* History Completed List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 16px 0;
}

.history-entry {
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.history-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-type-icon {
  font-size: 16px;
}

.history-title {
  font-weight: 700;
}

.history-tags {
  font-size: 10.5px;
  color: var(--text-muted);
}

.history-time {
  font-weight: 700;
  color: var(--primary-700);
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 64px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  cursor: pointer;
  flex: 1;
  padding: 6px 0;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.nav-item:active {
  transform: scale(0.92);
  color: var(--primary-700);
}

.nav-item.active {
  color: var(--primary-600);
}

.nav-icon {
  font-size: 20px;
  pointer-events: none;
}

.nav-label {
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

/* Modals & Bottom Sheets */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  animation: fadeIn 0.2s ease;
  touch-action: auto;
}

/* Universal Hidden Utility */
.hidden {
  display: none !important;
}

.modal-backdrop.hidden,
.danger-banner.hidden,
.bedside-overlay.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bottom-sheet {
  background: #ffffff;
  border-radius: 24px 24px 0 0;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2);
  animation: sheetUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-header {
  padding: 14px 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.sheet-drag-handle {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 4px;
}

.sheet-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 4px;
}

.sheet-close-btn {
  background: var(--bg-card-subtle);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-body {
  padding: 16px 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Form Elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.small-link-btn {
  background: none;
  border: none;
  color: var(--primary-600);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.time-input, .text-input, .select-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  transition: border-color 0.2s;
}

.time-input:focus, .text-input:focus, .select-input:focus {
  border-color: var(--primary-600);
}

/* Posture Selector Radio Cards */
.posture-selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.posture-radio-card {
  position: relative;
  cursor: pointer;
}

.posture-radio-card input {
  position: absolute;
  opacity: 0;
}

.radio-content {
  background: var(--bg-card-subtle);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.2s ease;
}

.posture-emoji {
  font-size: 24px;
  margin-bottom: 2px;
}

.posture-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-main);
}

.posture-sub {
  font-size: 9.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.posture-radio-card input:checked + .radio-content {
  border-color: var(--primary-600);
  background: #f0f9ff;
  box-shadow: 0 0 0 1px var(--primary-600);
}

/* Checkbox Tasks List */
.checkbox-task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.2s;
}

.checkbox-task-item input {
  position: absolute;
  opacity: 0;
}

.custom-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid #94a3b8;
  border-radius: 5px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.2s ease;
}

.checkbox-task-item input:checked ~ .custom-checkbox {
  background: var(--primary-600);
  border-color: var(--primary-600);
}

.checkbox-task-item input:checked ~ .custom-checkbox::after {
  content: '✓';
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.task-info {
  display: flex;
  flex-direction: column;
}

.task-info strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.task-info span {
  font-size: 11px;
  color: var(--text-muted);
}

/* Tube Feeding Formula Options */
.formula-options-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.formula-radio-card {
  position: relative;
  cursor: pointer;
}

.formula-radio-card input {
  position: absolute;
  opacity: 0;
}

.formula-radio-card .card-inner {
  padding: 10px 12px;
  background: var(--bg-card-subtle);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.formula-radio-card .f-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.formula-radio-card .f-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.formula-radio-card input:checked + .card-inner {
  border-color: #7c3aed;
  background: #f5f3ff;
}

/* Volume Fields */
.volume-inputs-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.volume-field {
  display: flex;
  align-items: center;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}

.v-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.num-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 16px;
  font-weight: 800;
  text-align: right;
  padding: 6px;
  outline: none;
  font-family: inherit;
}

.v-unit {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 4px;
}

/* Safety Confirm Box inside modal */
.safety-confirm-box {
  background: #fff1f2;
  border-left: 4px solid #f43f5e;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.safety-box-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.safety-box-text strong {
  display: block;
  font-size: 12px;
  color: #9f1239;
}

.safety-box-text p {
  font-size: 11px;
  color: #be123c;
  margin-top: 2px;
}

/* Submit Action Button */
.submit-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s ease;
}

.submit-btn:active {
  transform: scale(0.98);
}

/* Language Dialog Modal */
.dialog-box {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  width: 90%;
  max-width: 380px;
  margin: auto;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.dialog-title {
  font-size: 17px;
  font-weight: 800;
}

.dialog-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 16px;
}

.lang-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.lang-select-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.lang-select-btn:hover, .lang-select-btn:active {
  border-color: var(--primary-600);
  background: #f0f9ff;
}

.l-flag {
  font-size: 24px;
}

.l-info {
  display: flex;
  flex-direction: column;
}

.l-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.l-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.cancel-btn {
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  background: #f1f5f9;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

/* Guide Cards */
.guide-sheet .sheet-body {
  gap: 14px;
}

.guide-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.guide-badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.badge-red {
  background: #fee2e2;
  color: #b91c1c;
}

.pillow-tip ul {
  padding-left: 18px;
  font-size: 12px;
  color: #334155;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

/* Fullscreen Bedside Overlay (OLED Deep Night Mode) */
.bedside-overlay {
  position: fixed;
  inset: 0;
  background-color: #000000;
  color: #ffffff;
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  text-align: center;
}

.bedside-container {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.exit-bedside-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.bedside-time-huge {
  font-size: 64px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  color: #38bdf8;
  text-shadow: 0 0 24px rgba(56, 189, 248, 0.4);
}

.bedside-posture-box {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.bedside-posture-icon {
  font-size: 48px;
}

.bedside-posture-title {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
}

.bedside-sub-countdown {
  font-size: 15px;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.bedside-feed-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.4);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 14px;
  color: #c4b5fd;
  font-weight: 700;
}

.bedside-feed-dot {
  width: 8px;
  height: 8px;
  background: #a855f7;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   Large Font Accessibility Mode (老人/照服員大字模式)
   ========================================================================== */
body.large-font {
  font-size: 17px;
}

body.large-font .patient-name { font-size: 19px; }
body.large-font .status-badge { font-size: 13.5px; }
body.large-font .icon-btn { font-size: 14px; padding: 7px 12px; }
body.large-font .countdown-time { font-size: 26px; }
body.large-font .countdown-target { font-size: 13.5px; }
body.large-font .btn-main-text { font-size: 16px; }
body.large-font .btn-sub-text { font-size: 12px; }
body.large-font .timeline-content-card { font-size: 14px; }
body.large-font .form-label { font-size: 15px; }
body.large-font .task-info strong { font-size: 15px; }
body.large-font .task-info span { font-size: 12.5px; }
body.large-font .submit-btn { font-size: 17px; padding: 16px; }
body.large-font .hour-num { font-size: 14px; font-weight: 800; }
body.large-font .center-posture-text { font-size: 14px; }
body.large-font .center-time-digital { font-size: 17px; }
body.large-font .center-sub-hint { font-size: 11px; }

/* Extra Large Font */
body.xlarge-font {
  font-size: 19px;
}
body.xlarge-font .countdown-time { font-size: 30px; }
body.xlarge-font .btn-main-text { font-size: 18px; }
body.xlarge-font .center-posture-text { font-size: 16px; }
body.xlarge-font .center-time-digital { font-size: 19px; }

/* ==========================================================================
   Interactive User Manual Modal Styles
   ========================================================================== */
.manual-sheet {
  max-height: 92vh;
}

.manual-tabs-bar {
  display: flex;
  background: var(--bg-card-subtle);
  padding: 6px;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none;
}

.manual-tabs-bar::-webkit-scrollbar {
  display: none;
}

.manual-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.manual-tab-btn.active {
  background: #ffffff;
  color: var(--primary-700);
  box-shadow: var(--shadow-sm);
}

.manual-content {
  padding: 16px 18px 28px;
}

.manual-tab-page {
  display: none;
  flex-direction: column;
  gap: 14px;
  animation: fadeIn 0.2s ease;
}

.manual-tab-page.active {
  display: flex;
}

.manual-card {
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.manual-card.highlight-card {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.manual-card.danger-card {
  background: #fef2f2;
  border-color: #fca5a5;
}

.manual-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--text-main);
  margin-bottom: 2px;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--primary-600);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.manual-h4 {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.manual-bullet-list, .manual-numbered-list {
  padding-left: 20px;
  font-size: 13.5px;
  color: #334155;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sop-sequence-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
}

.sop-tag {
  padding: 4px 8px;
  border-radius: 6px;
}
.tag-green { background: #dcfce7; color: #15803d; }
.tag-orange { background: #fef3c7; color: #b45309; }
.tag-blue { background: #e0f2fe; color: #0369a1; }

.danger-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #991b1b;
  font-size: 15px;
}

.danger-box-content {
  background: #fee2e2;
  border-left: 4px solid #ef4444;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13.5px;
  color: #7f1d1d;
  margin-top: 4px;
}

/* Caregiver Terms Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.manual-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.manual-table th, .manual-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-color);
}

.manual-table th {
  background: var(--bg-card-subtle);
  font-weight: 800;
  color: var(--text-main);
}

