/* ============================================================
   Aneesa Frontend — Mobile-First, Child-Friendly Design
   ============================================================ */

:root {
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --font: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --transition: 0.3s ease;
}

/* ----- Girl Theme (pink) ----- */
.theme-girl {
  --primary: #E91E8C;
  --primary-light: #FCE4EC;
  --primary-dark: #C2185B;
  --accent: #F48FB1;
  --bg: #FFF0F5;
  --card: #FFFFFF;
  --text: #4A0E2E;
  --text-muted: #9E6A7D;
  --bubble-ai: #FCE4EC;
  --bubble-child: #E91E8C;
  --bubble-child-text: #fff;
  --header-bg: #E91E8C;
  --header-text: #fff;
  --btn-primary-bg: #E91E8C;
  --btn-primary-text: #fff;
  --input-border: #F48FB1;
  --input-focus: #E91E8C;
}

/* ----- Boy Theme (green) ----- */
.theme-boy {
  --primary: #2E7D32;
  --primary-light: #E8F5E9;
  --primary-dark: #1B5E20;
  --accent: #66BB6A;
  --bg: #F1F8E9;
  --card: #FFFFFF;
  --text: #1B3A1B;
  --text-muted: #5A8A5A;
  --bubble-ai: #E8F5E9;
  --bubble-child: #2E7D32;
  --bubble-child-text: #fff;
  --header-bg: #2E7D32;
  --header-text: #fff;
  --btn-primary-bg: #2E7D32;
  --btn-primary-text: #fff;
  --input-border: #66BB6A;
  --input-focus: #2E7D32;
}

/* ----- Base ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 18px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ----- Screens ----- */
#app { height: 100dvh; display: flex; flex-direction: column; }
.screen { display: none; flex-direction: column; height: 100dvh; }
.screen.active, .screen.hidden { display: flex; }
.screen.hidden { display: none; }

/* ================================================================
   LOGIN SCREEN
   ================================================================ */
#login-screen {
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--bg) 0%, var(--primary-light) 100%);
}
.login-card {
  background: var(--card);
  border-radius: 24px;
  padding: 32px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-avatar { font-size: 64px; margin-bottom: 12px; }
#login-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
}
.login-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.field {
  margin-bottom: 16px;
  text-align: left;
}
.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.field input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--input-border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border var(--transition);
}
.field input:focus {
  border-color: var(--input-focus);
}
.error {
  color: #D32F2F;
  font-size: 0.8rem;
  margin: 8px 0;
}
.hidden { display: none; }

.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  margin-top: 8px;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ================================================================
   CHAT HEADER
   ================================================================ */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--header-bg);
  color: var(--header-text);
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.companion-avatar { font-size: 36px; }
header h2 { font-size: 1.1rem; font-weight: 700; }
.status {
  font-size: 0.65rem;
  opacity: 0.8;
}
.status.online::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: #69F0AE;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.header-right { display: flex; gap: 6px; }
.icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.icon-btn:active { background: rgba(255,255,255,0.3); }



/* ================================================================
   CHAT MESSAGES
   ================================================================ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--bg);
}
.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.5;
  animation: msgIn 0.25s ease-out;
  word-wrap: break-word;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.message.ai {
  align-self: flex-start;
  background: var(--bubble-ai);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.message.child {
  align-self: flex-end;
  background: var(--bubble-child);
  color: var(--bubble-child-text);
  border-bottom-right-radius: 4px;
}
.message-time {
  font-size: 0.6rem;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}
.message.child .message-time { color: rgba(255,255,255,0.7); }

/* ================================================================
   CHAT INPUT
   ================================================================ */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  border-top: 1px solid var(--input-border);
  flex-shrink: 0;
}
.chat-input-bar input {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid var(--input-border);
  border-radius: 24px;
  font-size: 0.95rem;
  outline: none;
  background: var(--bg);
  color: var(--text);
}
.chat-input-bar input:focus { border-color: var(--input-focus); }
.btn-send {
  width: 50px; height: 50px;
  border: none;
  border-radius: 50%;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
  flex-shrink: 0;
}
.btn-send:active { transform: scale(0.9); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ================================================================
   PROFILE SCREEN
   ================================================================ */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--header-bg);
  color: var(--header-text);
  flex-shrink: 0;
}
.profile-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
}
.profile-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.profile-card h3 {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 12px;
}
.profile-field {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 0.85rem;
}
.profile-field:last-child { border: none; }
.profile-field .label { color: var(--text-muted); }
.profile-field .value { font-weight: 600; }

/* ================================================================
   MODAL (Add Child Form)
   ================================================================ */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
}
.modal-content {
  position: relative;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
  animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 0;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
}
.modal-header h2 { font-size: 1.2rem; color: var(--primary); }
.modal-body { padding: 16px 20px 24px; }
.form-row {
  display: flex;
  gap: 12px;
}
.form-row .field { margin-bottom: 12px; }
.modal-body .field { margin-bottom: 12px; }
.modal-body select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--input-border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  appearance: auto;
}
.modal-body select:focus {
  border-color: var(--input-focus);
}

/* Checkbox group for interests/hobbies */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  padding: 8px 12px;
  border: 2px solid var(--input-border);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
  color: var(--text);
}
.checkbox-item:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.checkbox-item input { display: none; }

/* ================================================================
   PARENT DASHBOARD
   ================================================================ */
.parent-container {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
  height: 100%;
  overflow-y: auto;
}

#parent-dashboard {
  height: 100%;
}

#parent-child-detail {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.parent-header {
  text-align: center;
  margin-bottom: 20px;
}
.parent-header h1 { font-size: 1.4rem; color: var(--primary); }
.parent-header p { font-size: 0.85rem; color: var(--text-muted); }

.parent-login {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.parent-login h2 { font-size: 1.1rem; margin-bottom: 16px; color: var(--primary); }

.children-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.children-table th {
  background: var(--primary);
  color: var(--header-text);
  padding: 12px 10px;
  font-size: 0.8rem;
  text-align: left;
}
.children-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--bg);
  font-size: 0.8rem;
}
.children-table tr:last-child td { border: none; }

.child-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}
.child-link:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge.girl { background: #FCE4EC; color: #C2185B; }
.badge.boy { background: #E8F5E9; color: #1B5E20; }

.parent-section {
  margin-top: 20px;
}
.parent-section h3 {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 10px;
}

.conv-item {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.conv-item .date { font-size: 0.7rem; color: var(--text-muted); }
.conv-item .summary { font-size: 0.8rem; margin-top: 4px; }
.sentiment-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  margin-top: 4px;
  font-weight: 600;
}
.sentiment-tag.positive { background: #E8F5E9; color: #2E7D32; }
.sentiment-tag.neutral  { background: #FFF3E0; color: #E65100; }
.sentiment-tag.negative { background: #FFEBEE; color: #C62828; }

/* ================================================================
   LOADING
   ================================================================ */
.loading {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
}
.spinner {
  display: inline-block;
  width: 28px; height: 28px;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (min-width: 600px) {
  #chat-screen { max-width: 480px; margin: 0 auto; border-left: 1px solid var(--input-border); border-right: 1px solid var(--input-border); }
  .message { max-width: 70%; }
}
@media (max-width: 400px) {
  html { font-size: 16px; }
  .login-card { padding: 24px 16px; }
}

/* ================================================================
   PARENT THEME (Professional / Neutral)
   ================================================================ */
.theme-parent {
  --primary: #1B2A4A;
  --primary-light: #E8ECF1;
  --primary-dark: #0F1A30;
  --accent: #2C5F7C;
  --bg: #F4F6F9;
  --card: #FFFFFF;
  --text: #1A1A2E;
  --text-muted: #6B7280;
  --header-bg: #1B2A4A;
  --header-text: #FFFFFF;
  --btn-primary-bg: #1B2A4A;
  --btn-primary-text: #FFFFFF;
  --input-border: #D1D5DB;
  --input-focus: #2C5F7C;
  --shadow: 0 1px 6px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

.theme-parent-dark {
  --primary: #3B82F6;
  --primary-light: #1E293B;
  --primary-dark: #60A5FA;
  --accent: #38BDF8;
  --bg: #0F172A;
  --card: #1E293B;
  --text: #E2E8F0;
  --text-muted: #94A3B8;
  --header-bg: #0F172A;
  --header-text: #E2E8F0;
  --btn-primary-bg: #3B82F6;
  --btn-primary-text: #FFFFFF;
  --input-border: #334155;
  --input-focus: #3B82F6;
  --shadow: 0 1px 6px rgba(0,0,0,0.3);
  --radius: 12px;
  --radius-sm: 8px;
}

.parent-landing {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.parent-hero {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 48px 24px 32px;
  text-align: center;
}
.parent-hero h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 8px; }
.parent-hero p { font-size: 0.9rem; opacity: 0.8; }

.parent-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--input-border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}
.parent-tab {
  flex: 1;
  padding: 14px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
}
.parent-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.parent-tab:hover { color: var(--text); }

.parent-form-section {
  padding: 24px 20px;
  flex: 1;
}
.parent-form-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  max-width: 420px;
  margin: 0 auto;
}
.parent-form-card h2 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 8px;
}
.parent-form-card p.sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.parent-form-card .field { margin-bottom: 16px; }
.parent-form-card .field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.parent-form-card input[type="text"],
.parent-form-card input[type="email"],
.parent-form-card input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--input-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border 0.2s;
}
.parent-form-card input:focus {
  border-color: var(--input-focus);
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
}

/* Parent dashboard inner */
.parent-dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.parent-dash-header h2 { font-size: 1.1rem; color: var(--text); margin: 0; }
.parent-dash-header .p-email { font-size: 0.75rem; color: var(--text-muted); }

.parent-btn-outline {
  padding: 8px 16px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.parent-btn-outline:hover {
  background: var(--primary);
  color: var(--btn-primary-text);
}

.parent-empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
}
.parent-empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.parent-empty-state p { font-size: 0.9rem; }

.theme-toggle-form {
  text-align: center;
  padding: 24px;
}
.theme-toggle-form h3 { font-size: 1.1rem; margin-bottom: 16px; }
.theme-options {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 16px;
}
.theme-opt {
  padding: 16px 24px;
  border: 2px solid var(--input-border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
  background: var(--card);
  color: var(--text);
  min-width: 120px;
}
.theme-opt:hover { border-color: var(--accent); }
.theme-opt.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
