/* ==========================================================================
   Family Home Hub - Mobile-First Parent Control Center Stylesheet
   Optimized for iPhone (Safari / WebApp / PWA)
   ========================================================================== */

:root {
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  
  /* Apple Dark Mode Palette */
  --bg-primary: #090E17;
  --bg-secondary: #131B2E;
  --bg-card: rgba(26, 36, 56, 0.78);
  --bg-card-solid: #162035;
  --bg-input: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(255, 255, 255, 0.2);
  
  --text-primary: #FFFFFF;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  
  /* iOS Accent Colors */
  --ios-blue: #0A84FF;
  --ios-green: #30D158;
  --ios-orange: #FF9F0A;
  --ios-red: #FF453A;
  --ios-purple: #BF5AF2;
  --ios-yellow: #FFD60A;
  --ios-teal: #64D2FF;

  /* Safe Area Variables */
  --sat: env(safe-area-inset-top, 20px);
  --sab: env(safe-area-inset-bottom, 20px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  user-select: none;
}

/* Base App Wrapper */
.parent-app {
  max-width: 480px; /* iPhone Pro Max width boundary on larger screens */
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-primary);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   Header Bar (Top Navigation)
   ========================================================================== */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 14, 23, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  padding: calc(var(--sat) + 8px) 16px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon-circle {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #F59E0B, #D97706);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.top-titles h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #FFF;
}

.top-titles .top-sub {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ios-blue);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tv-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(48, 209, 88, 0.15);
  border: 1px solid rgba(48, 209, 88, 0.3);
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #4ADE80;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tv-sync-pill .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 8px #22C55E;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.main-content {
  flex: 1;
  padding: 16px 16px calc(var(--sab) + 84px); /* Clearance for bottom tab bar */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* View Sections */
.app-view {
  display: none;
  animation: fadeIn 0.2s ease-out;
}

.app-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Bottom Tab Bar (iOS Native Style)
   ========================================================================== */
.bottom-tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 100;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-top: 1px solid var(--border-subtle);
  padding: 8px 12px calc(var(--sab) + 6px);
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 12px;
  position: relative;
  transition: color 0.15s ease, transform 0.15s ease;
}

.tab-btn:active {
  transform: scale(0.92);
}

.tab-btn.active {
  color: var(--ios-blue);
}

.tab-icon {
  font-size: 22px;
  line-height: 1;
}

.tab-badge {
  position: absolute;
  top: 0px;
  right: 6px;
  background: var(--ios-red);
  color: #FFF;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
}

/* ==========================================================================
   Reusable iOS Cards & Components
   ========================================================================== */
.ios-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

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

.ios-card-title {
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #FFF;
}

.ios-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.ios-badge-blue { background: rgba(10, 132, 255, 0.18); color: var(--ios-blue); }
.ios-badge-green { background: rgba(48, 209, 88, 0.18); color: var(--ios-green); }
.ios-badge-orange { background: rgba(255, 159, 10, 0.18); color: var(--ios-orange); }
.ios-badge-red { background: rgba(255, 69, 58, 0.18); color: var(--ios-red); }

/* Quick Action Carousel Bar */
.quick-actions-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0 12px;
  margin-bottom: 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.quick-actions-bar::-webkit-scrollbar {
  display: none;
}

.action-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 10px 16px;
  color: #FFF;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.action-chip:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.15);
}

.action-chip.chip-highlight {
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.3), rgba(10, 132, 255, 0.15));
  border-color: rgba(10, 132, 255, 0.4);
  color: #7DD3FC;
}

.chip-counter {
  background: var(--ios-red);
  color: #FFF;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.ios-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ios-btn:active {
  transform: scale(0.97);
}

.ios-btn-full {
  width: 100%;
}

.ios-btn-primary {
  background: var(--ios-blue);
  color: #FFFFFF;
}

.ios-btn-primary:active {
  background: #0071E3;
}

.ios-btn-success {
  background: var(--ios-green);
  color: #064E3B;
  font-weight: 700;
}

.ios-btn-danger {
  background: rgba(255, 69, 58, 0.15);
  border: 1px solid rgba(255, 69, 58, 0.3);
  color: #FF8780;
}

.ios-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #FFF;
}

.ios-btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

/* ==========================================================================
   Chore Verification List Item
   ========================================================================== */
.chore-approval-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  margin-bottom: 10px;
}

.chore-info-col {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.chore-child-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.chore-title-text {
  font-size: 15px;
  font-weight: 600;
  color: #FFF;
}

.chore-meta-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.chore-actions-col {
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   Forms & Controls
   ========================================================================== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  color: #FFF;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--ios-blue);
  background: rgba(255, 255, 255, 0.1);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > * {
  flex: 1;
}

/* iOS Switch Toggle */
.ios-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: .3s;
  border-radius: 28px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

input:checked + .toggle-slider {
  background-color: var(--ios-green);
}

input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

/* ==========================================================================
   Segmented Controls
   ========================================================================== */
.segmented-control {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.segment-btn.active {
  background: var(--bg-card-solid);
  color: #FFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* ==========================================================================
   Bottom Sheet / Slide-up Modal
   ========================================================================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  background: #151D2F;
  border: 1px solid var(--border-highlight);
  border-radius: 28px 28px 0 0;
  padding: 12px 20px calc(var(--sab) + 24px);
  max-height: 88vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.sheet-backdrop.active .bottom-sheet {
  transform: translateY(0);
}

.sheet-handle-bar {
  width: 40px;
  height: 5px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  margin: 4px auto 16px;
}

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

.sheet-title {
  font-size: 19px;
  font-weight: 700;
  color: #FFF;
}

.sheet-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ==========================================================================
   Toasts (iOS Notification Banners)
   ========================================================================== */
.toast-container {
  position: fixed;
  top: calc(var(--sat) + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 420px;
  z-index: 300;
  pointer-events: none;
}

.ios-toast {
  background: rgba(30, 41, 59, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  margin-bottom: 8px;
  animation: toastSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1), toastFadeOut 0.3s ease 3.2s forwards;
}

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

@keyframes toastFadeOut {
  from { opacity: 1; }
  to { opacity: 0; pointer-events: none; }
}

.toast-icon {
  font-size: 24px;
}

.toast-title {
  font-size: 14px;
  font-weight: 700;
  color: #FFF;
}

.toast-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Login Screen
   ========================================================================== */
.login-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-primary);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 32px 24px;
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.login-brand-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, #F59E0B, #D97706);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
}

.login-title {
  font-size: 24px;
  font-weight: 800;
  color: #FFF;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
