/* ============================================================
   MedAlerta — Layout
   Shell do app, navegação, grid
   ============================================================ */

/* ── App Shell ───────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: var(--content-max-width);
  margin: 0 auto;
  position: relative;
  background: var(--bg-app);
}

/* ── Tela de autenticação ────────────────────────────────── */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--bg-app);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-subtle);
  animation: scaleIn var(--transition-slow) cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── Top Bar (Header) ────────────────────────────────────── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--nav-height);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.top-bar-left  { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 0; }
.top-bar-right { display: flex; align-items: center; gap: var(--space-2); }
.top-bar-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-bar-subtitle {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

/* ── Bottom Navigation ───────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--content-max-width);
  height: var(--bottom-nav-height);
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border);
  display: flex;
  align-items: center;
  z-index: var(--z-fixed);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-2) var(--space-1);
  cursor: pointer;
  border: none;
  background: none;
  transition: all var(--transition-fast);
  text-decoration: none;
  position: relative;
  min-height: 52px;
}

.bottom-nav-item .nav-icon {
  font-size: 22px;
  transition: transform var(--transition-spring);
  color: var(--nav-inactive);
  line-height: 1;
}

.bottom-nav-item .nav-label {
  font-size: 10px;
  font-weight: var(--font-weight-medium);
  color: var(--nav-inactive);
  transition: color var(--transition-fast);
  letter-spacing: 0.02em;
}

.bottom-nav-item.active .nav-icon {
  color: var(--nav-active);
  transform: scale(1.1) translateY(-1px);
}

.bottom-nav-item.active .nav-label {
  color: var(--nav-active);
  font-weight: var(--font-weight-semibold);
}

/* Active indicator dot */
.bottom-nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px; height: 4px;
  border-radius: var(--radius-full);
  background: var(--nav-active);
}

/* Badge no ícone de navegação */
.nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  background: var(--color-danger-500);
  color: white;
  font-size: 9px;
  font-weight: var(--font-weight-bold);
  min-width: 16px; height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--nav-bg);
}

/* ── Page Content ────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: var(--space-4);
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-16));
  overflow-y: auto;
  animation: slideUp var(--transition-base) both;
}

/* Page sem bottom nav */
.page-content.full { padding-bottom: var(--space-6); }

/* ── Profile Switcher (top bar) ──────────────────────────── */
.profile-switcher {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface-2);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-subtle);
  max-width: 200px;
}

.profile-switcher:hover { border-color: var(--brand); }

.profile-switcher-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* ── Dashboard Grid ──────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.doses-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ── Medications Grid ────────────────────────────────────── */
.med-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ── History Layout ──────────────────────────────────────── */
.history-calendar-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
  box-shadow: var(--card-shadow);
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.calendar-month-year {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-md);
}

/* ── Reports Layout ──────────────────────────────────────── */
.reports-period-selector {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  scrollbar-width: none;
}

.reports-period-selector::-webkit-scrollbar { display: none; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

/* ── Form Layout ─────────────────────────────────────────── */
.form-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.form-card-title {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-md);
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* ── Schedule Item ───────────────────────────────────────── */
.schedule-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-2);
}

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

/* ── Days Picker ─────────────────────────────────────────── */
.days-picker {
  display: flex;
  gap: var(--space-2);
}

.day-toggle {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--transition-fast);
  user-select: none;
}

.day-toggle:hover { border-color: var(--brand); color: var(--brand); }
.day-toggle.active { background: var(--brand); color: white; border-color: var(--brand); }

/* ── NFC Manager Layout ──────────────────────────────────── */
.nfc-tag-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-3);
  box-shadow: var(--card-shadow);
}

.nfc-tag-card-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-lg);
  background: var(--brand-subtle);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

/* ── Settings List ───────────────────────────────────────── */
.settings-section {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.settings-section-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-4) var(--space-5) var(--space-2);
}

/* ── Onboarding / Welcome ────────────────────────────────── */
.welcome-hero {
  text-align: center;
  padding: var(--space-12) var(--space-6) var(--space-8);
}

.welcome-logo {
  width: 96px; height: 96px;
  border-radius: var(--radius-2xl);
  background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-700));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-6);
  font-size: 48px;
  box-shadow: 0 8px 32px hsla(199, 89%, 48%, 0.4);
  animation: bounceIn 600ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.welcome-title {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  background: linear-gradient(135deg, var(--color-primary-400), var(--color-primary-600));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: var(--space-3);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (min-width: 480px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}

/* Para tablets — layout expandido */
@media (min-width: 768px) {
  :root {
    --content-max-width: 720px;
  }

  .form-row { grid-template-columns: 1fr 1fr 1fr; }

  .bottom-nav {
    background: var(--nav-bg);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  }
}
