/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Girls — Aneesa */
  --pink-50: #fdf2f8;
  --pink-100: #fce7f3;
  --pink-200: #fbcfe8;
  --pink-400: #f472b6;
  --pink-500: #ec4899;
  --pink-600: #db2777;
  --pink-700: #be185d;
  --pink-800: #9d174d;
  
  /* Boys — Anees */
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  
  /* Neutral */
  --purple-400: #a78bfa;
  --purple-600: #7c3aed;
  --purple-700: #6d28d9;
  
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
}

html, body {
  height: 100%;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--gray-50);
  color: var(--gray-800);
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT ===== */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.page {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.page.active {
  display: flex;
}

/* ===== LOGIN PAGE ===== */
#page-login {
  justify-content: center;
  align-items: center;
  padding: 24px 20px;
  min-height: 100vh;
  background: linear-gradient(160deg, #fdf2f8 0%, #e0f2fe 50%, #f0fdfa 100%);
}

.login-bismillah {
  font-family: 'Amiri', serif;
  font-size: 1.3rem;
  color: var(--gray-500);
  margin-bottom: 6px;
  direction: rtl;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-icon {
  font-size: 3.5rem;
  margin-bottom: 8px;
  line-height: 1;
}

.login-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.login-title.girls { color: var(--pink-600); }
.login-title.boys { color: var(--teal-600); }
.login-title.neutral { color: var(--purple-600); }

.login-subtitle {
  font-size: 0.95rem;
  color: var(--gray-500);
  margin-bottom: 24px;
  font-style: italic;
}

.login-label {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 6px;
  margin-top: 14px;
}

.login-label:first-of-type {
  margin-top: 0;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: 'Nunito', sans-serif;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
  background: var(--gray-50);
}

.login-input:focus {
  border-color: var(--purple-400);
}

.login-btn {
  width: 100%;
  padding: 16px;
  margin-top: 22px;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.login-btn.girls {
  background: linear-gradient(135deg, var(--pink-500), var(--pink-700));
}

.login-btn.boys {
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
}

.login-btn.neutral {
  background: linear-gradient(135deg, var(--purple-400), var(--purple-700));
}

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

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-error {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 12px;
  min-height: 1.2em;
}

.login-footer {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--gray-400);
}

.login-footer a {
  color: var(--purple-400);
  text-decoration: none;
  font-weight: 600;
}

.login-parent-link {
  margin-top: 16px;
  font-size: 0.85rem;
}

.login-parent-link a {
  color: var(--gray-500);
  text-decoration: none;
}

/* ===== CHAT PAGE ===== */
#page-chat {
  background: var(--white);
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}

.chat-header.girls {
  background: linear-gradient(135deg, var(--pink-50), var(--pink-100));
  border-bottom-color: var(--pink-200);
}

.chat-header.boys {
  background: linear-gradient(135deg, var(--teal-50), var(--teal-100));
  border-bottom-color: var(--teal-200);
}

.chat-header.neutral {
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  border-bottom-color: #ddd6fe;
}

.chat-back-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
  color: var(--gray-600);
}

.chat-back-btn:active {
  background: rgba(0,0,0,0.06);
}

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.chat-avatar.girls {
  background: var(--pink-100);
  color: var(--pink-600);
}

.chat-avatar.boys {
  background: var(--teal-100);
  color: var(--teal-600);
}

.chat-avatar.neutral {
  background: #ede9fe;
  color: var(--purple-600);
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-companion-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.chat-companion-name.girls { color: var(--pink-700); }
.chat-companion-name.boys { color: var(--teal-700); }
.chat-companion-name.neutral { color: var(--purple-700); }

.chat-child-name {
  font-size: 0.8rem;
  color: var(--gray-500);
}

.chat-settings-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--gray-400);
  transition: background 0.2s;
}

.chat-settings-btn:active {
  background: rgba(0,0,0,0.06);
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: var(--gray-50);
}

.message {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: messageSlide 0.25s ease-out;
}

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

.message.incoming {
  align-self: flex-start;
}

.message.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.message-avatar.girls {
  background: var(--pink-100);
  color: var(--pink-600);
}

.message-avatar.boys {
  background: var(--teal-100);
  color: var(--teal-600);
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message.incoming .message-bubble {
  background: var(--white);
  color: var(--gray-800);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.message.outgoing .message-bubble {
  background: linear-gradient(135deg, var(--purple-400), var(--purple-600));
  color: var(--white);
  border-bottom-right-radius: 6px;
}

.message-time {
  font-size: 0.65rem;
  color: var(--gray-400);
  margin-top: 3px;
  padding: 0 4px;
}

.message.outgoing .message-time {
  text-align: right;
  color: rgba(255,255,255,0.6);
}

/* Typing indicator */
.typing-indicator {
  align-self: flex-start;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  animation: messageSlide 0.2s ease-out;
}

.typing-dots {
  background: var(--white);
  padding: 12px 18px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 5px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--gray-300);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); }
  40% { transform: scale(1); }
}

/* Chat input */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-100);
  background: var(--white);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: 'Nunito', sans-serif;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-full);
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 44px;
  transition: border-color 0.2s;
  background: var(--gray-50);
}

.chat-input:focus {
  border-color: var(--purple-400);
}

.chat-send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn.girls {
  background: linear-gradient(135deg, var(--pink-500), var(--pink-700));
  color: var(--white);
}

.chat-send-btn.boys {
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  color: var(--white);
}

.chat-send-btn:active {
  transform: scale(0.9);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ===== PARENT DASHBOARD ===== */
#page-parent {
  background: var(--gray-50);
  min-height: 100vh;
}

.parent-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--white);
}

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

.parent-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--gray-800);
}

.parent-title-icon {
  font-size: 1.5rem;
}

.parent-logout-btn {
  background: none;
  border: 1px solid var(--gray-200);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--gray-500);
  transition: all 0.2s;
  font-family: 'Nunito', sans-serif;
}

.parent-logout-btn:active {
  background: var(--gray-100);
}

.parent-subtitle {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.parent-content {
  flex: 1;
  padding: 16px 20px 24px;
  overflow-y: auto;
}

.parent-welcome {
  font-size: 0.95rem;
  color: var(--gray-600);
  margin-bottom: 16px;
  text-align: center;
}

/* Child cards */
.child-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--gray-300);
  cursor: pointer;
  transition: all 0.2s;
}

.child-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-md);
}

.child-card.girls {
  border-left-color: var(--pink-400);
}

.child-card.boys {
  border-left-color: var(--teal-400);
}

.child-card.neutral {
  border-left-color: var(--purple-400);
}

.child-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.child-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.child-card-avatar.girls {
  background: var(--pink-100);
  color: var(--pink-600);
}

.child-card-avatar.boys {
  background: var(--teal-100);
  color: var(--teal-600);
}

.child-card-info {
  flex: 1;
}

.child-card-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-800);
}

.child-card-gender {
  font-size: 0.8rem;
  color: var(--gray-400);
}

.child-card-companion {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.child-card-arrow {
  font-size: 1.2rem;
  color: var(--gray-300);
}

.child-card-stats {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--gray-100);
}

.child-stat {
  flex: 1;
  text-align: center;
  font-size: 0.78rem;
  color: var(--gray-500);
}

.child-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-700);
  display: block;
}

.child-stat-label {
  font-size: 0.72rem;
}

.loading-spinner {
  text-align: center;
  padding: 40px 20px;
}

.loading-spinner .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--purple-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--gray-400);
  font-size: 0.9rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: 0.95rem;
}

/* ===== PROFILE PAGE (from parent dashboard) ===== */
#page-profile {
  background: var(--white);
}

.profile-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}

.profile-header.girls {
  background: linear-gradient(135deg, var(--pink-50), var(--pink-100));
  border-bottom-color: var(--pink-200);
}

.profile-header.boys {
  background: linear-gradient(135deg, var(--teal-50), var(--teal-100));
  border-bottom-color: var(--teal-200);
}

.profile-back-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--gray-600);
}

.profile-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.profile-content {
  padding: 20px;
  overflow-y: auto;
}

.profile-card {
  text-align: center;
  padding: 24px;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 12px;
}

.profile-avatar.girls {
  background: var(--pink-100);
  color: var(--pink-600);
}

.profile-avatar.boys {
  background: var(--teal-100);
  color: var(--teal-600);
}

.profile-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gray-800);
}

.profile-detail {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.profile-section {
  margin-bottom: 16px;
}

.profile-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.profile-info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.9rem;
}

.profile-info-row:last-child {
  border-bottom: none;
}

.profile-info-label {
  color: var(--gray-500);
}

.profile-info-value {
  font-weight: 600;
  color: var(--gray-700);
}

/* ===== ERROR PAGE ===== */
#page-error {
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
  text-align: center;
  min-height: 100vh;
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.error-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.error-message {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin-bottom: 24px;
}

.error-btn {
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  color: var(--white);
  background: linear-gradient(135deg, var(--purple-400), var(--purple-600));
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ===== RESPONSIVE ===== */
@media (min-width: 481px) {
  #app {
    padding: 20px;
    background: linear-gradient(160deg, #fdf2f8, #e0f2fe, #f0fdfa);
  }

  .page {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
  }

  #page-login {
    border-radius: var(--radius-lg);
    min-height: auto;
    padding: 32px;
  }

  #page-parent {
    border-radius: var(--radius-lg);
    min-height: auto;
    max-height: 90vh;
  }
}

@media (max-width: 360px) {
  .login-card {
    padding: 24px 16px;
  }

  .chat-messages {
    padding: 12px;
  }

  .message-bubble {
    font-size: 0.88rem;
    padding: 10px 14px;
  }
}
