@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #AD1AAC;
  --primary-light: #d44fd3;
  --primary-dark: #850d84;
  --primary-bg: #f9eaf9;
  --white: #ffffff;
  --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-900: #111827;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;

  /* Specialty colors */
  --fono: #3b82f6;
  --fono-bg: #eff6ff;
  --psico: #10b981;
  --psico-bg: #ecfdf5;
  --to: #f59e0b;
  --to-bg: #fffbeb;
  --fisio: #ef4444;
  --fisio-bg: #fef2f2;
  --psicoped: #8b5cf6;
  --psicoped-bg: #f5f3ff;
  --outro: #6b7280;
  --outro-bg: #f9fafb;
  --nutri: #16a34a;
  --nutri-bg: #f0fdf4;
  --music: #7c3aed;
  --music-bg: #f5f3ff;

  --nav-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

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

html, body {
  height: 100%;
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  color: var(--gray-700);
  background: var(--gray-50);
  overflow-x: hidden;
}

/* ===================== SCREENS ===================== */
.screen {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}
.screen.active {
  display: flex;
}

/* ===================== LOGIN ===================== */
#screen-login {
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 50%, #5a0a59 100%);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-icon {
  width: 72px;
  height: 72px;
  background: var(--primary-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 36px;
}

.login-logo h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

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

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  color: var(--gray-700);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(173, 26, 172, 0.12);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: var(--white);
  width: 100%;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--primary-bg);
  color: var(--primary);
}
.btn-secondary:hover { background: #f0d4f0; }

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-danger {
  background: #fef2f2;
  color: var(--error);
}
.btn-danger:hover { background: #fee2e2; }

.btn-sm {
  padding: 7px 14px;
  font-size: 0.875rem;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
}

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

/* ===================== APP LAYOUT ===================== */
#screen-app {
  padding-bottom: var(--nav-height);
}

.app-header {
  background: var(--white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.app-header h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gray-900);
  flex: 1;
  text-align: center;
}

.header-logo {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}

.notification-badge {
  position: relative;
}

.notification-badge .badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--error);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* ===================== BOTTOM NAV ===================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.07);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  cursor: pointer;
  color: var(--gray-400);
  transition: color 0.2s;
  border: none;
  background: none;
  font-family: 'Nunito', sans-serif;
}

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

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item span {
  font-size: 0.7rem;
  font-weight: 700;
}

/* ===================== PAGES ===================== */
.page {
  display: none;
  flex-direction: column;
  flex: 1;
}
.page.active {
  display: flex;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ===================== CARDS ===================== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

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

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
}

/* ===================== CHILD CARD ===================== */
.child-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
  border: 1.5px solid transparent;
}

.child-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.child-card.unread {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.child-avatar {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: white;
  font-weight: 800;
  flex-shrink: 0;
}

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

.child-name {
  font-weight: 700;
  color: var(--gray-900);
  font-size: 0.975rem;
}

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

.child-badge {
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ===================== DEVOLUTIVA CARD ===================== */
.devolutiva-card {
  background: var(--white);
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border-left: 4px solid var(--gray-300);
}

.devolutiva-card.specialty-fono { border-left-color: var(--fono); }
.devolutiva-card.specialty-psico { border-left-color: var(--psico); }
.devolutiva-card.specialty-to { border-left-color: var(--to); }
.devolutiva-card.specialty-fisio { border-left-color: var(--fisio); }
.devolutiva-card.specialty-psicoped { border-left-color: var(--psicoped); }
.devolutiva-card.specialty-nutri    { border-left-color: var(--nutri); }
.devolutiva-card.specialty-music    { border-left-color: var(--music); }

.devolutiva-header {
  padding: 12px 14px 8px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.specialty-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-300);
  margin-top: 5px;
  flex-shrink: 0;
}

.specialty-fono .specialty-dot { background: var(--fono); }
.specialty-psico .specialty-dot { background: var(--psico); }
.specialty-to .specialty-dot { background: var(--to); }
.specialty-fisio .specialty-dot { background: var(--fisio); }
.specialty-psicoped .specialty-dot { background: var(--psicoped); }
.specialty-nutri .specialty-dot    { background: var(--nutri); }
.specialty-music .specialty-dot    { background: var(--music); }

.devolutiva-meta { flex: 1; min-width: 0; }

.devolutiva-therapist {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gray-900);
}

.devolutiva-info {
  font-size: 0.78rem;
  color: var(--gray-500);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.specialty-tag {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
}

.specialty-tag.fono { background: var(--fono-bg); color: var(--fono); }
.specialty-tag.psico { background: var(--psico-bg); color: var(--psico); }
.specialty-tag.to { background: var(--to-bg); color: var(--to); }
.specialty-tag.fisio { background: var(--fisio-bg); color: var(--fisio); }
.specialty-tag.psicoped { background: var(--psicoped-bg); color: var(--psicoped); }
.specialty-tag.outro    { background: var(--outro-bg);   color: var(--outro); }
.specialty-tag.nutri    { background: var(--nutri-bg);   color: var(--nutri); }
.specialty-tag.music    { background: var(--music-bg);   color: var(--music); }

.devolutiva-content {
  padding: 0 14px 12px;
  color: var(--gray-700);
  font-size: 0.9rem;
  line-height: 1.6;
}

.devolutiva-read-status {
  padding: 0 14px 8px;
  font-size: 0.75rem;
  color: var(--gray-400);
}

.devolutiva-actions {
  padding: 8px 14px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--gray-100);
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 20px;
  border: none;
  background: var(--gray-100);
  color: var(--gray-500);
  font-family: 'Nunito', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.action-btn:hover { background: var(--gray-200); }

.action-btn.liked {
  background: #fce7fb;
  color: var(--primary);
}

.action-btn svg {
  width: 15px;
  height: 15px;
}

/* ===================== REPLIES ===================== */
.replies-section {
  padding: 0 14px 12px;
  border-top: 1px solid var(--gray-100);
}

.reply-item {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}

.reply-item:last-child { border-bottom: none; }

.reply-avatar {
  width: 30px;
  height: 30px;
  background: var(--primary-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

.reply-content { flex: 1; min-width: 0; }

.reply-author {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray-900);
}

.reply-text {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-top: 2px;
}

.reply-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.reply-input-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 20px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.875rem;
  outline: none;
}

.reply-input-row input:focus {
  border-color: var(--primary);
}

.reply-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===================== MOMENTO CARD ===================== */
.momento-card {
  background: var(--white);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.momento-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.momento-img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  background: var(--gray-100);
  display: block;
}

.momento-img-placeholder {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, var(--primary-bg), var(--gray-100));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: 3rem;
}

.momento-footer {
  padding: 12px 14px;
}

.momento-caption {
  font-size: 0.9rem;
  color: var(--gray-700);
  margin-bottom: 10px;
  line-height: 1.5;
}

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

/* ===================== SECTION HEADER ===================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gray-900);
}

/* ===================== EMPTY STATE ===================== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

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

.empty-state p {
  font-size: 0.9rem;
  font-weight: 600;
}

/* ===================== MODAL ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: none;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 20px 32px;
  animation: slideUp 0.3s ease;
}

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

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 20px;
}

/* ===================== TOAST ===================== */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  background: var(--gray-900);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.info { background: var(--primary); }

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

/* ===================== TABS ===================== */
.tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
  gap: 2px;
}

.tab-btn {
  flex: 1;
  padding: 8px 6px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* ===================== FILTER CHIPS ===================== */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-500);
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===================== STAT CARDS ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--gray-500);
  font-weight: 600;
  margin-top: 4px;
}

/* ===================== LIST ITEM ===================== */
.list-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.list-item-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.list-item-content { flex: 1; min-width: 0; }

.list-item-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gray-900);
}

.list-item-sub {
  font-size: 0.78rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ===================== FAB ===================== */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  right: 16px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(173,26,172,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 150;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(173,26,172,0.5);
}

.fab svg {
  width: 24px;
  height: 24px;
  stroke: white;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===================== BACK BUTTON ===================== */
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  background: none;
  border: none;
  color: var(--primary);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 12px;
}

.back-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===================== READ INDICATOR ===================== */
.read-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--gray-400);
}

.read-indicator.read { color: var(--success); }

/* ===================== IMAGE UPLOAD ===================== */
.image-upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.image-upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.image-upload-area input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.image-upload-area .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.image-upload-area p {
  color: var(--gray-500);
  font-size: 0.875rem;
  font-weight: 600;
}

.image-preview {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  max-height: 200px;
  object-fit: cover;
}

/* ===================== PROFILE HEADER ===================== */
.profile-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 28px 20px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: white;
}

.profile-avatar-big {
  width: 64px;
  height: 64px;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  flex-shrink: 0;
  border: 3px solid rgba(255,255,255,0.4);
}

.profile-info h3 {
  font-size: 1.15rem;
  font-weight: 800;
}

.profile-info p {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 3px;
}

.role-badge {
  display: inline-block;
  padding: 2px 10px;
  background: rgba(255,255,255,0.2);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 5px;
}

/* ===================== LOADING ===================== */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ===================== NOTIFICATION BANNER ===================== */
.notification-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  color: white;
  padding: 14px 16px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.3s ease;
  cursor: pointer;
}

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

.notification-banner .notif-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.notification-banner .notif-content { flex: 1; }
.notification-banner .notif-title { font-weight: 700; font-size: 0.9rem; }
.notification-banner .notif-body { font-size: 0.8rem; opacity: 0.9; margin-top: 2px; }

.notification-banner .notif-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

/* ===================== UNREAD DOT ===================== */
.unread-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  display: inline-block;
  margin-left: 6px;
  vertical-align: middle;
}

/* ===================== LINK CARD ===================== */
.link-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--gray-200);
}

.link-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gray-900);
  margin-bottom: 12px;
}

.linked-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.875rem;
}

.linked-item:last-child { border-bottom: none; }

/* ===================== HELPERS ===================== */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); font-size: 0.875rem; }
.font-bold { font-weight: 700; }
.divider { height: 1px; background: var(--gray-200); margin: 16px 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

/* Safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  }
  #screen-app { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); }
}

/* ===================== FAMILY REPLIES (terapeuta view) ===================== */
.family-replies-wrap {
  background: #f0fdf4;
  border-radius: var(--radius-sm);
  padding: 12px;
  border-left: 3px solid var(--success);
}

.family-replies-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 10px;
}

.family-reply-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 0;
  border-bottom: 1px solid rgba(16,185,129,0.12);
}

.family-reply-item:last-child { border-bottom: none; }

/* ===================== BADGE RESPONDEU ===================== */
.badge-replied {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: #ecfdf5;
  color: var(--success);
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid rgba(16,185,129,0.25);
}

/* ===================== DASHBOARD TABLES ===================== */
.dashboard-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  background: var(--white);
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.dashboard-table thead th {
  background: var(--gray-50);
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.dashboard-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  white-space: nowrap;
}

.dashboard-table tbody tr:last-child td { border-bottom: none; }
.dashboard-table tbody tr:hover td { background: var(--gray-50); }

.read-pct      { font-weight: 700; color: var(--success); }
.read-pct.low  { color: var(--error); }
.read-pct.mid  { color: var(--warning); }

/* ===================== DASHBOARD CHART ===================== */
.chart-wrap {
  padding: 16px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.chart-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.chart-dot.sent { background: var(--primary); }
.chart-dot.read { background: var(--primary-light); }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.chart-bar-group {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 100%;
  width: 100%;
  justify-content: center;
}

.chart-bar {
  width: 8px;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.4s ease;
}
.chart-bar.sent { background: var(--primary); }
.chart-bar.read { background: var(--primary-light); opacity: 0.65; }

.chart-x-labels {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.chart-x-label {
  flex: 1;
  text-align: center;
  font-size: 0.65rem;
  color: var(--gray-400);
  font-weight: 600;
  line-height: 1.4;
}
