/* Family Learning Lab - Core Design System & Layout */
:root {
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-glass: rgba(30, 41, 59, 0.85);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #38bdf8;
  --accent-green: #34d399;
  --accent-amber: #fbbf24;
  --accent-rose: #fb7185;
  --accent-purple: #c084fc;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.25);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* App Shell */
#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
}

/* Top Navigation Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #f8fafc, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.active-profile-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  font-weight: 600;
}

.active-profile-pill:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: scale(1.05);
}

/* Views & Screens */
.view-container {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease-out;
}

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

/* Common Card */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-2px);
}

.btn-danger {
  background: #e11d48;
  color: #fff;
}

.btn-danger:hover {
  background: #be123c;
}

/* Responsive Grid */
.grid {
  display: grid;
  gap: 20px;
}

.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .grid-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .grid-cols-3 {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 10px 14px;
  }
  .brand-title {
    font-size: 1rem;
  }
  .view-container {
    padding: 14px;
  }
}

/* Modals & Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 28px;
  box-shadow: var(--shadow-md);
  position: relative;
}

/* Rest Screen / Digital Wellbeing */
.rest-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #1e1b4b 0%, #09090b 100%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.rest-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  animation: pulse 2.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

/* Notification Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1100;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-weight: 500;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

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

/* Mobile & Touch Responsive Enhancements */
@media (max-width: 640px) {
  .topbar {
    padding: 10px 14px;
    gap: 8px;
  }
  .brand-title {
    font-size: 1rem;
  }
  .topbar .brand-section > div > div:last-child {
    display: none; /* Hide subtitle on small phones */
  }
  .topbar-actions {
    gap: 8px;
  }
  .active-profile-pill {
    padding: 4px 10px;
    font-size: 0.8rem;
  }
  .btn-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .view-container {
    padding: 12px;
  }
  .card {
    padding: 16px;
  }
  .question-text {
    font-size: 1.3rem;
  }
  .choice-btn {
    font-size: 1.15rem;
    padding: 14px;
  }
}
