/* ── Reset & Base ────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght=400;500;600;700;800&display=swap');

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Tons de Azul */
  --blue-50: #f0f9ff;
  --blue-100: #e0f2fe;
  --blue-200: #bae6fd;
  --blue-300: #7dd3fc;
  --blue-400: #38bdf8;
  --blue-500: #0ea5e9;
  --blue-600: #0284c7;

  /* Tons de Verde Claro / Menta */
  --mint-50: #f0fdf4;
  --mint-100: #dcfce7;
  --mint-200: #bbf7d0;
  --mint-300: #86efac;
  --mint-500: #22c55e;
  --mint-700: #15803d;

  /* Neutros e Base */
  --cream: #f4f9f6;
  /* Um creme levemente esverdeado/frio para harmonizar */
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;

  /* Sombras ajustadas para uma base azulada fria */
  --shadow-sm: 0 1px 2px rgba(2, 132, 199, .06);
  --shadow-md: 0 4px 16px rgba(2, 132, 199, .10);
  --shadow-lg: 0 8px 32px rgba(2, 132, 199, .14);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--cream);
  color: var(--gray-700);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--mint-500) 0%, var(--blue-500) 100%);
  padding: 20px 24px 28px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.app-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.app-title span {
  opacity: .85;
  font-weight: 500;
  font-size: 1rem;
  display: block;
  margin-top: 2px;
}

/* ── Date Navigator ──────────────────────────────────────────────────────── */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.date-nav button {
  background: rgba(255, 255, 255, .25);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .15s;
}

.date-nav button:hover {
  background: rgba(255, 255, 255, .4);
  transform: scale(1.1);
}

#current-date-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  min-width: 180px;
  text-align: center;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .2);
  transition: background .2s;
}

#current-date-label:hover {
  background: rgba(255, 255, 255, .35);
}

#date-picker-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

/* ── Main Layout ─────────────────────────────────────────────────────────── */
.main-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 120px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow .2s;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--blue-100);
  background: var(--blue-50);
}

.card-icon {
  font-size: 1.5rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--blue-600);
  flex: 1;
}

.card-badge {
  background: var(--blue-200);
  color: var(--blue-600);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: .8rem;
  font-weight: 700;
}

.card-body {
  padding: 16px 20px 20px;
}

/* ── Action Buttons ──────────────────────────────────────────────────────── */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-family: 'Nunito', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform .15s, box-shadow .15s, filter .15s;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(.95);
}

.btn-primary {
  background: linear-gradient(135deg, var(--mint-500), var(--blue-500));
  color: #fff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, .25);
}

.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(2, 132, 199, .35);
}

.btn-outline {
  background: var(--blue-50);
  color: var(--blue-600);
  border: 2px solid var(--blue-200);
}

.btn-outline:hover {
  background: var(--blue-100);
  border-color: var(--mint-300);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, .3);
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {

  0%,
  100% {
    box-shadow: 0 4px 12px rgba(239, 68, 68, .3);
  }

  50% {
    box-shadow: 0 4px 20px rgba(239, 68, 68, .6);
  }
}

.btn-sm {
  padding: 6px 12px;
  font-size: .8rem;
  border-radius: var(--radius-sm);
}

/* ── ML Picker ───────────────────────────────────────────────────────────── */
.ml-form {
  background: var(--mint-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  display: none;
  animation: slideDown .25s ease;
}

.ml-form.visible {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ml-form-title {
  font-weight: 700;
  color: var(--blue-600);
  font-size: .9rem;
  margin-bottom: 12px;
}

.ml-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.ml-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 100px;
}

.ml-field label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.ml-input {
  border: 2px solid var(--blue-200);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: 'Nunito', sans-serif;
  font-size: .95rem;
  font-weight: 700;
  color: var(--gray-700);
  background: var(--white);
  outline: none;
  transition: border-color .2s;
  width: 100%;
}

.ml-input:focus {
  border-color: var(--mint-500);
}

/* ML quick picker */
.ml-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.ml-chip {
  background: var(--blue-100);
  border: 2px solid transparent;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  color: var(--blue-600);
}

.ml-chip:hover,
.ml-chip.selected {
  background: var(--mint-500);
  color: #fff;
  border-color: var(--mint-500);
}

/* ── Records List ────────────────────────────────────────────────────────── */
.records-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.record-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-100);
  animation: fadeIn .3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.record-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.record-info {
  flex: 1;
}

.record-time {
  font-size: .78rem;
  font-weight: 700;
  color: var(--mint-700);
  letter-spacing: .3px;
  display: flex;
  align-items: center;
}

.record-detail {
  font-size: .88rem;
  font-weight: 600;
  color: var(--gray-700);
}

.record-delete {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  border-radius: 6px;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}

.record-delete:hover {
  color: #ef4444;
  background: #fef2f2;
}

/* Botão de lápis para edição de horários ✏️ */
.record-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  margin-left: 6px;
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.1s;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
}

.record-edit-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

/* ── Sleep Card special ──────────────────────────────────────────────────── */
.sleep-active-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: .88rem;
  font-weight: 600;
  color: #92400e;
}

.sleep-active-indicator.visible {
  display: flex;
}

.sleep-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  animation: blink 1.4s infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .2;
  }
}

/* ── Summary strip ───────────────────────────────────────────────────────── */
.day-summary {
  background: linear-gradient(135deg, var(--mint-500) 0%, var(--blue-500) 100%);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  box-shadow: var(--shadow-md);
}

.summary-item {
  text-align: center;
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.summary-label {
  font-size: .72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, .75);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 4px;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  align-items: center;
}

.toast {
  background: var(--gray-900);
  color: #fff;
  border-radius: 20px;
  padding: 10px 20px;
  font-size: .88rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s ease, toastOut .3s ease 2.2s forwards;
  white-space: nowrap;
}

.toast.success {
  background: #059669;
}

.toast.error {
  background: #dc2626;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--gray-400);
  font-size: .85rem;
  font-weight: 600;
  padding: 16px 0 4px;
}

/* ── Loading spinner ─────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .app-title {
    font-size: 1.3rem;
  }

  .main-content {
    padding: 16px 12px 100px;
  }

  .btn {
    padding: 10px 14px;
    font-size: .85rem;
  }

  .day-summary {
    grid-template-columns: repeat(2, 1fr);
  }
}
/*      Tabs                                                                                                                                      */
.main-tabs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 20px auto 0;
  max-width: 680px;
  padding: 0 16px;
}

.tab-btn {
  background: var(--blue-100);
  color: var(--blue-600);
  border: 2px solid transparent;
  padding: 10px 24px;
  border-radius: 24px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: var(--blue-200);
}

.tab-btn.active {
  background: var(--mint-500);
  color: #fff;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-section.active {
  display: block;
}

/*      Reports                                                                                                                                */
.filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-100);
}

.filter-group label {
  font-weight: 700;
  color: var(--gray-500);
  font-size: 0.9rem;
}

.filter-select {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--blue-200);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  color: var(--blue-600);
  outline: none;
  cursor: pointer;
  background: #fff;
}

.filter-select:focus {
  border-color: var(--mint-500);
}

.table-responsive {
  overflow-x: auto;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.report-table th, .report-table td {
  padding: 12px;
  border-bottom: 1px solid var(--gray-100);
}

.report-table th {
  font-weight: 800;
  color: var(--gray-700);
  background: var(--gray-50);
}

.report-table td {
  font-weight: 600;
  color: var(--gray-500);
}

.report-table tbody tr:hover td {
  background: var(--blue-50);
}

.toggle-records-btn {
  background: none;
  border: none;
  color: var(--blue-600);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toggle-records-btn:hover {
  background: var(--blue-100);
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: white;
  padding: 20px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

#view-reports .card {
    max-width: 95vw;
    height: 85vh;
    overflow-y: auto;
}
