/* ==========================================================================
   Sem Perder a Data - Estilos Mobile-First Ultra Modernos
   Design 100% adaptado para celular, com Menu Inferior (Bottom Bar) e Zero Rolagem Lateral
   ========================================================================== */

:root {
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-light: #ccfbf1;
  --primary-dark: #115e59;
  
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;
  
  --border-color: #e2e8f0;
  
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-nav: 0 -4px 16px rgba(0, 0, 0, 0.08);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  max-width: 100%;
  overflow-x: hidden;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================================
   CABEÇALHO SUPERIOR (COMPACTO E MODERNO)
   ========================================================================= */
.header-app {
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
  color: #ffffff;
  padding: 0.85rem 1rem;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-md);
}

.header-container {
  max-width: 768px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo-icon {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.logo-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.logo-text p {
  font-size: 0.75rem;
  color: #ccfbf1;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-header {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-header:active {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(0.97);
}

/* =========================================================================
   BARRA DE NAVEGAÇÃO INFERIOR (BOTTOM NAVIGATION BAR)
   Sem rolagem lateral! Todos os 5 botões cabem perfeitamente na tela do celular
   ========================================================================= */
.bottom-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  box-shadow: var(--shadow-nav);
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-container {
  max-width: 768px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 62px;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px 0;
  position: relative;
  transition: var(--transition);
}

.bottom-nav-item .nav-icon {
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 2px;
  position: relative;
}

.bottom-nav-item .nav-text {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

.bottom-nav-item.active .nav-icon {
  transform: scale(1.1);
}

.nav-badge-pill {
  position: absolute;
  top: -4px;
  right: -8px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  border-radius: var(--radius-full);
  text-align: center;
  padding: 0 4px;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
}

/* =========================================================================
   ÁREA PRINCIPAL DE CONTEÚDO (COM ESPAÇO INFERIOR PARA NÃO COBRIR)
   ========================================================================= */
.main-wrapper {
  max-width: 768px;
  margin: 0 auto;
  padding: 1rem 1rem 85px 1rem; /* 85px garante que nada fique coberto pelo menu inferior */
}

/* =========================================================================
   FILTRO DE PESSOAS MODERNO (SEM ROLAGEM LATERAL)
   ========================================================================= */
.person-filter-wrapper {
  background: #ffffff;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.person-filter-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
}

.person-filter-select {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 700;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  background-color: #f8fafc;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.person-filter-select:focus {
  border-color: var(--primary);
  background-color: #ffffff;
}

/* =========================================================================
   BANNER DA LOGÍSTICA / CARONA
   ========================================================================= */
.logistics-hero-banner {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.banner-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(13, 148, 136, 0.3);
  color: #5eead4;
  border: 1px solid rgba(94, 234, 212, 0.3);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.banner-title {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
  line-height: 1.25;
}

.banner-desc {
  color: #cbd5e1;
  font-size: 0.86rem;
  line-height: 1.4;
}

/* =========================================================================
   GRID DE RESUMO E ESTATÍSTICAS DO PAINEL
   ========================================================================= */
.summary-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}

.stat-card:active {
  transform: scale(0.98);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.info { background: #e0f2fe; color: #0284c7; }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.purple { background: #ede9fe; color: #8b5cf6; }

.stat-info .stat-number {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat-info .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 2px;
  line-height: 1.2;
}

/* =========================================================================
   BARRA DE AÇÕES (CABEÇALHO DA SEÇÃO)
   ========================================================================= */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  background: #ffffff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.action-bar-title {
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* =========================================================================
   CARTÕES DE VIAGEM COMPARTILHADA (LOGÍSTICA)
   ========================================================================= */
.trip-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  overflow: hidden;
}

.trip-card.shared-trip {
  border: 2px solid #0d9488;
}

.trip-card-header {
  padding: 1rem 1.1rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.trip-card.shared-trip .trip-card-header {
  background: #f0fdfa;
}

.trip-date-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.trip-calendar-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  text-align: center;
}

.trip-calendar-box .month {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--primary);
}

.trip-calendar-box .day {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.1;
}

.trip-meta-title h3 {
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.2;
}

.trip-meta-title p {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.trip-body {
  padding: 1rem 1.1rem;
}

.trip-passengers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--border-color);
}

.passenger-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffffff;
}

.timeline-stops {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stop-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  border-left: 4px solid var(--primary);
}

.stop-time {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary-dark);
  min-width: 50px;
}

.stop-details {
  flex: 1;
}

.stop-person-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  color: #ffffff;
  margin-bottom: 0.2rem;
}

.stop-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.stop-location {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pharmacy-hint-box {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-left: 4px solid #f59e0b;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  margin-top: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.84rem;
  color: #92400e;
}

/* =========================================================================
   CARTÕES DE ITENS (CONSULTAS, EXAMES, REMÉDIOS)
   ========================================================================= */
.item-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.person-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
}

.item-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.item-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0.5rem 0;
}

.item-meta-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.bring-to-appointment-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  margin: 0.6rem 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.84rem;
  color: #1e40af;
  font-weight: 600;
}

/* Status Pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 700;
}

.status-a-agendar { background: #fef3c7; color: #b45309; }
.status-agendado { background: #e0f2fe; color: #0369a1; }
.status-aguardando { background: #ede9fe; color: #6d28d9; }
.status-pronto { background: #dcfce7; color: #15803d; border: 1px solid #86efac; font-weight: 800; }
.status-concluido { background: #f1f5f9; color: #64748b; }

/* Linhas de Remédio */
.med-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: #ffffff;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 0.65rem;
}

.med-row.needs-purchase {
  border-left: 5px solid #f59e0b;
  background: #fffdfa;
}

.med-info h4 {
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.med-details {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

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

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Modais */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end; /* No celular abre de baixo para cima como Bottom Sheet */
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #ffffff;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-nav);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-dialog {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 1rem;
  }
  .modal-dialog {
    border-radius: var(--radius-lg);
    transform: translateY(20px);
  }
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  background: #f8fafc;
}

.form-group {
  margin-bottom: 1rem;
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-row .form-group {
  flex: 1;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.form-label span.req {
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.8rem;
  font-size: 0.92rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  background-color: #ffffff;
  color: var(--text-main);
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
}

textarea.form-control {
  min-height: 70px;
  resize: vertical;
}

/* Toast */
.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  font-size: 0.88rem;
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border-color);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.3rem;
}

/* Modal de Escolha "+ Novo" */
.sheet-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sheet-option-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.sheet-option-btn:active {
  background: var(--primary-light);
  border-color: var(--primary);
}

.sheet-option-icon {
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  background: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.sheet-option-text h4 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
}

.sheet-option-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
}
