/* styles.css */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Cores Principais - Tema Premium Safira Azul & Dourado */
  --primary-color: hsl(215, 80%, 30%);
  --primary-light: hsl(215, 80%, 38%);
  --primary-glow: hsla(215, 80%, 30%, 0.15);
  
  --secondary-color: hsl(38, 90%, 50%);
  --secondary-light: hsl(38, 90%, 58%);
  
  --accent-color: hsl(330, 80%, 55%);
  
  /* Escala de Neutros */
  --bg-app: hsl(210, 30%, 97%);
  --bg-sidebar: hsl(215, 35%, 15%);
  --bg-sidebar-active: hsl(215, 80%, 24%);
  --bg-card: hsl(0, 0%, 100%);
  --bg-input: hsl(210, 20%, 98%);
  
  --text-main: hsl(215, 30%, 18%);
  --text-muted: hsl(215, 15%, 50%);
  --text-light: hsl(0, 0%, 100%);
  
  /* Estados */
  --color-success: hsl(142, 70%, 40%);
  --color-danger: hsl(350, 70%, 48%);
  --color-warning: hsl(38, 90%, 50%);
  --color-info: hsl(200, 80%, 45%);
  
  /* Efeitos e Bordas */
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 24px;
  
  --box-shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.04);
  --box-shadow-medium: 0 12px 35px rgba(0, 0, 0, 0.08);
  --box-shadow-glow: 0 8px 25px hsla(215, 80%, 30%, 0.2);
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset e Estilos Globais */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

a {
  text-decoration: none;
  color: inherit;
}

/* Otimizações de performance e resposta de toque instantânea para celular */
button, 
a, 
.btn, 
.menu-item a, 
.mobile-nav-item, 
.appt-quick-item, 
.btn-icon,
.mobile-menu-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* --- TELA DE CARREGAMENTO GLOBAL --- */
#app-loader {
  position: fixed;
  inset: 0;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 20px;
  transition: opacity var(--transition-normal);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--bg-input);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* --- TELA DE AUTENTICAÇÃO / LOGIN --- */
.login-container {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  background: radial-gradient(circle at 10% 20%, hsl(215, 80%, 15%) 0%, hsl(215, 35%, 12%) 100%);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  width: 100%;
  max-width: 440px;
  padding: 40px;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  text-align: center;
  color: var(--text-light);
  transform: translateY(0);
  animation: floatIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.login-header img {
  max-width: 138px;
  height: auto;
  border-radius: 50%;
  margin-bottom: 20px;
  object-fit: cover;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.login-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fff 0%, var(--secondary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-header p {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-weight: 300;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
  position: relative;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.8);
}

/* Labels no tema light */
.light-theme-label {
  color: var(--text-main) !important;
  font-weight: 600 !important;
}

.input-icon-wrapper {
  position: relative;
}

.input-icon-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}

.form-control {
  width: 100%;
  padding: 14px 16px 14px 44px;
  border-radius: var(--border-radius-md);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-light);
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--primary-light);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* Inputs no modo claro dentro do Dashboard */
.dashboard-input {
  background: var(--bg-input) !important;
  border: 1.5px solid hsl(210, 15%, 90%) !important;
  color: var(--text-main) !important;
  padding-left: 16px !important;
}
.dashboard-input-icon {
  padding-left: 44px !important;
}
.dashboard-input:focus {
  border-color: var(--primary-color) !important;
  background: white !important;
  box-shadow: 0 0 0 4px var(--primary-glow) !important;
}

.btn {
  width: 100%;
  padding: 14px 28px;
  border-radius: var(--border-radius-md);
  border: none;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
  color: var(--text-light);
  box-shadow: var(--box-shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px hsla(215, 80%, 30%, 0.35);
  background: linear-gradient(135deg, hsl(215, 80%, 38%) 0%, var(--primary-light) 100%);
}

.btn-secondary {
  background: hsl(210, 15%, 90%);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: hsl(210, 15%, 85%);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--color-danger);
  color: var(--text-light);
}
.btn-danger:hover {
  background: hsl(350, 70%, 42%);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.login-footer {
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- ESTRUTURA SPA (SIDEBAR + MAIN) --- */
.app-wrapper {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar Estilizada */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  padding: 30px 20px;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 40px;
  padding: 0 10px;
}

.sidebar-logo img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--secondary-color);
}

.sidebar-logo h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, var(--secondary-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.menu-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-item a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--border-radius-md);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.menu-item a i {
  font-size: 1.2rem;
}

.menu-item a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-light);
}

.menu-item.active a {
  background: var(--bg-sidebar-active);
  color: var(--text-light);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background-color: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  color: white;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-info-text .user-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info-text .user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Área de Conteúdo Principal */
.main-content {
  margin-left: 280px;
  flex-grow: 1;
  padding: 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-normal);
}

/* Header Principal */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 36px;
}

.header-title-area h1 {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.header-title-area p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Botão do Hamburguer para Mobile */
.mobile-menu-btn {
  display: none;
  background: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-md);
  box-shadow: var(--box-shadow-soft);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-main);
  z-index: 101;
}

/* Seções de visualização da SPA */
.view-section {
  display: none;
  flex-direction: column;
  animation: fadeIn var(--transition-normal);
}

.view-section.active {
  display: flex;
}

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

/* --- DASHBOARD: CARDS FINANCEIROS --- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 36px;
}

.metric-card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--border-radius-md);
  box-shadow: var(--box-shadow-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  border: 1px solid hsl(210, 15%, 95%);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--box-shadow-medium);
}

.metric-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
}

.metric-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.metric-icon.faturamento {
  background-color: hsla(142, 70%, 40%, 0.1);
  color: var(--color-success);
}

.metric-icon.despesas {
  background-color: hsla(350, 70%, 48%, 0.1);
  color: var(--color-danger);
}

.metric-icon.lucro {
  background-color: hsla(165, 80%, 28%, 0.1);
  color: var(--primary-color);
}

.metric-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
}
.metric-card.faturamento-card::after { background-color: var(--color-success); }
.metric-card.despesas-card::after { background-color: var(--color-danger); }
.metric-card.lucro-card::after { background-color: var(--primary-color); }

/* Layout de Duas Colunas (Gráfico + Agenda Hoje) */
.dashboard-cols {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 28px;
  align-items: start;
}

.panel-card {
  background: var(--bg-card);
  padding: 30px;
  border-radius: var(--border-radius-md);
  box-shadow: var(--box-shadow-soft);
  border: 1px solid hsl(210, 15%, 95%);
  margin-bottom: 28px;
}

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

.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Gráfico de Barras Financeiro Simples (SVG/CSS) */
.chart-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 10px 0;
}

.chart-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-row-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 500;
}

.chart-bar-bg {
  width: 100%;
  height: 12px;
  background-color: var(--bg-input);
  border-radius: 6px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 1s ease-out;
}

.chart-bar-fill.revenue { background: linear-gradient(90deg, var(--color-success), hsl(142, 70%, 50%)); }
.chart-bar-fill.expense { background: linear-gradient(90deg, var(--color-danger), hsl(350, 70%, 58%)); }

/* Lista de Compromissos Rápidos */
.appt-quick-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 380px;
  overflow-y: auto;
}

.appt-quick-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  background-color: var(--bg-input);
  border-left: 4px solid var(--primary-color);
  transition: transform var(--transition-fast);
}

.appt-quick-item:hover {
  transform: translateX(4px);
}

.appt-quick-time {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-color);
  min-width: 50px;
}

.appt-quick-details {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.appt-quick-dog {
  font-weight: 600;
  font-size: 0.95rem;
}

.appt-quick-owner {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.appt-quick-badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}

/* Status Badges */
.badge-agendado { background-color: hsla(200, 80%, 45%, 0.15); color: var(--color-info); }
.badge-concluido { background-color: hsla(142, 70%, 40%, 0.15); color: var(--color-success); }
.badge-cancelado { background-color: hsla(0, 0%, 50%, 0.15); color: var(--text-muted); }
.badge-faltou { background-color: hsla(350, 70%, 48%, 0.15); color: var(--color-danger); }

/* --- CONTROLE DE TABELAS (CLIENTES / PETS / FINANÇAS) --- */
.table-actions {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  flex-grow: 1;
  position: relative;
}

.search-input-wrapper i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 46px;
}

.table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--border-radius-md);
  border: 1px solid hsl(210, 15%, 92%);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  background-color: var(--bg-card);
}

.data-table th {
  background-color: hsl(210, 15%, 96%);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 18px 20px;
  border-top: 1px solid hsl(210, 15%, 92%);
  font-size: 0.95rem;
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
  background-color: hsla(210, 15%, 98%, 0.6);
}

/* Ações nas linhas */
.row-actions {
  display: flex;
  gap: 10px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-sm);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background-color: var(--bg-input);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background-color: var(--primary-glow);
  color: var(--primary-color);
}

.btn-icon-danger:hover {
  background-color: hsla(350, 70%, 48%, 0.1);
  color: var(--color-danger);
}

/* Pets Listados na Linha do Cliente */
.pet-pill-container {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pet-pill {
  background-color: var(--primary-glow);
  color: var(--primary-color);
  padding: 4px 10px;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pet-pill:hover {
  background-color: hsla(215, 80%, 30%, 0.25);
  cursor: pointer;
}

/* --- TELA DA AGENDA & CALENDÁRIOS --- */
.calendar-view-toggle {
  display: flex;
  background-color: var(--bg-input);
  padding: 4px;
  border-radius: var(--border-radius-sm);
  border: 1px solid hsl(210, 15%, 92%);
}

.toggle-btn {
  padding: 8px 18px;
  border-radius: 6px;
  border: none;
  font-weight: 600;
  font-size: 0.88rem;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toggle-btn.active {
  background-color: white;
  color: var(--primary-color);
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

/* Layout Calendário / Agenda */
.agenda-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Visão Semanal */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  background-color: var(--bg-input);
  padding: 12px;
  border-radius: var(--border-radius-md);
  min-height: 480px;
}

.week-day-col {
  background-color: white;
  border-radius: var(--border-radius-sm);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--box-shadow-soft);
}

.week-day-header {
  text-align: center;
  border-bottom: 2px solid var(--bg-input);
  padding-bottom: 10px;
}

.week-day-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.week-day-number {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

.week-day-col.today {
  outline: 2px solid var(--primary-color);
  background-color: hsla(165, 80%, 28%, 0.01);
}
.week-day-col.today .week-day-number {
  color: var(--primary-color);
}

.week-cards-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
  overflow-y: auto;
}

.appt-calendar-card {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  border-left: 3px solid var(--primary-color);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.appt-calendar-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.appt-calendar-card .time {
  font-weight: 700;
  display: block;
}

.appt-calendar-card .pet-name {
  font-weight: 600;
  display: block;
}

.appt-calendar-card .service {
  font-size: 0.72rem;
  opacity: 0.8;
}

/* Visão Mensal */
.month-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  background-color: var(--bg-input);
  padding: 12px;
  border-radius: var(--border-radius-md);
}

.month-day-cell {
  background-color: white;
  min-height: 90px;
  padding: 8px;
  border-radius: var(--border-radius-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--box-shadow-soft);
  position: relative;
}

.month-day-number {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-main);
  align-self: flex-end;
}

.month-day-cell.today {
  outline: 2px solid var(--primary-color);
}
.month-day-cell.today .month-day-number {
  color: var(--primary-color);
}

.month-day-cell.other-month {
  opacity: 0.4;
}

.month-day-dot-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
}

.month-day-appt-pill {
  width: 100%;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* --- MODAIS DE CADASTRO --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeInModal var(--transition-fast);
}

@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.modal-content {
  background-color: white;
  width: 100%;
  max-width: 600px;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--box-shadow-medium);
  border: 1px solid hsl(210, 15%, 90%);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  transform: scale(0.95);
  transition: transform var(--transition-fast);
  overflow: hidden;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 24px 30px;
  border-bottom: 1px solid hsl(210, 15%, 92%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: hsl(210, 15%, 98%);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--color-danger);
}

.modal-body {
  padding: 30px;
  overflow-y: auto;
  flex-grow: 1;
  flex-shrink: 1;
  min-height: 0;
}

.modal-footer {
  padding: 20px 30px;
  border-top: 1px solid hsl(210, 15%, 92%);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: hsl(210, 15%, 98%);
}

/* Grade de Formulários em Modais */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.form-grid-full {
  grid-column: span 2;
}

/* --- TELA DE CONFIGURAÇÕES --- */
.settings-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 28px;
}

.logo-upload-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed hsl(210, 15%, 85%);
  border-radius: var(--border-radius-md);
  padding: 30px;
  text-align: center;
  gap: 16px;
  background-color: var(--bg-input);
  transition: border-color var(--transition-fast);
}

.logo-upload-wrapper:hover {
  border-color: var(--primary-color);
}

.logo-preview {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid white;
  box-shadow: var(--box-shadow-soft);
  background-color: white;
}

.logo-upload-btn {
  background-color: white;
  border: 1px solid hsl(210, 15%, 80%);
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.logo-upload-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Responsividade Mobile */
@media (max-width: 1024px) {
  .dashboard-cols {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }
  
  .sidebar {
    transform: translateX(-280px);
    width: 280px;
    overflow-y: auto; /* Garante que o menu e o botão de logout sejam roláveis */
    -webkit-overflow-scrolling: touch;
  }
  
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.25);
  }
  
  .main-content {
    margin-left: 0;
    padding: 20px;
    padding-top: 80px; /* Espaço para cabeçalho flutuante */
    min-height: auto !important; /* Evita que o conteúdo role além da página em branco */
  }

  .mobile-menu-btn {
    display: flex;
  }
  
  .main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid hsl(210, 15%, 92%);
    padding: 14px 20px;
    margin-bottom: 0;
    z-index: 99;
  }

  .header-title-area h1 {
    font-size: 1.4rem;
  }
  .header-title-area p {
    font-size: 0.8rem;
  }

  .week-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    min-height: auto;
  }
  
  .month-calendar-grid {
    grid-template-columns: repeat(7, 1fr);
    font-size: 0.75rem;
  }
  
  .month-day-cell {
    min-height: 60px;
    padding: 4px;
  }
  
  .month-day-number {
    font-size: 0.8rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .form-grid-full {
    grid-column: span 1;
  }
  
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

/* Feedback de Toasts/Avisos flutuantes */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
  width: calc(100vw - 48px);
}

.toast {
  background: white;
  border-left: 4px solid var(--primary-color);
  padding: 16px 20px;
  border-radius: var(--border-radius-sm);
  box-shadow: var(--box-shadow-medium);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 0.9rem;
  animation: slideInToast var(--transition-fast) forwards;
}

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

.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-danger); }
.toast.info { border-left-color: var(--color-info); }

/* Layout de duas colunas para Receitas e Despesas */
.finance-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}
@media (max-width: 1024px) {
  .finance-cols {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* --- STYLING MOBILE PREMIUM E RESPONSIVIDADE --- */
@media (max-width: 768px) {
  /* Ajustes da Tela de Login no Celular */
  .login-card {
    padding: 24px 20px !important;
    max-width: 92vw !important;
  }

  /* 1. Barra de Navegação Inferior */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid hsl(210, 15%, 90%);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    gap: 4px;
    width: 20%;
    height: 100%;
    cursor: pointer;
    transition: color var(--transition-fast) ease;
  }

  .mobile-nav-item i {
    font-size: 1.2rem;
    transition: transform var(--transition-fast) ease;
  }

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

  .mobile-nav-item.active i {
    transform: translateY(-2px);
  }

  /* Compensa o espaço da barra inferior para o conteúdo principal */
  .main-content {
    padding-bottom: 90px !important;
  }

  /* 2. Modais Responsivos (Centralizados e 100% Roláveis) */
  .modal-overlay {
    align-items: flex-start !important; /* Alinha no topo para permitir rolagem fluida */
    justify-content: center !important;
    padding: 24px 16px 120px !important; /* Margem inferior de 120px para rolar acima do teclado */
    overflow-y: auto !important; /* Transfere a rolagem para a tela overlay */
    -webkit-overflow-scrolling: touch;
  }

  .modal-content {
    margin: 0 auto !important;
    border-radius: var(--border-radius-lg) !important;
    max-height: none !important; /* Remove limites para fluir naturalmente */
    overflow: visible !important;
    width: 100% !important;
    transform: scale(0.9) !important;
    transition: transform var(--transition-fast) cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    display: block !important;
  }

  .modal-overlay.active .modal-content {
    transform: scale(1) !important;
  }

  .modal-header {
    border-bottom: 1px solid hsl(210, 15%, 93%);
    padding: 16px 20px;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  }

  .modal-body {
    padding: 20px !important;
    overflow: visible !important; /* Remove barra interna para não dar conflito */
    max-height: none !important;
  }

  .modal-footer {
    padding: 16px 20px;
    background: hsl(210, 15%, 98%);
    border-top: 1px solid hsl(210, 15%, 93%);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap !important;
  }

  .modal-footer .btn {
    width: 100% !important;
    flex-grow: 1 !important;
    padding: 12px 20px !important;
  }

  /* Garante que nenhum campo de texto, select ou input estoure o limite de largura útil */
  .form-control, 
  .dashboard-input,
  select,
  textarea,
  input:not([type="checkbox"]):not([type="radio"]) {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* Impede que checkboxes e radios estiquem a 100% de largura */
  input[type="checkbox"],
  input[type="radio"] {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    max-width: 18px !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    cursor: pointer;
  }

  /* Garante empilhamento vertical para botões inline em formulários no mobile */
  .modal-body div[style*="display: flex"],
  .modal-body div[style*="display:flex"] {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .modal-body div[style*="display: flex"] > *,
  .modal-body div[style*="display:flex"] > * {
    width: 100% !important;
    flex-grow: 1 !important;
  }

  /* Grade de Formulários em Coluna Única no Celular */
  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .form-grid-full {
    grid-column: span 1 !important;
  }

  /* Evita zoom automático do iOS ao focar inputs */
  .form-control, 
  .dashboard-input, 
  select, 
  textarea {
    font-size: 16px !important;
  }

  /* 3. Tabelas Responsivas Adaptadas para Cards */
  .data-table, 
  .data-table thead, 
  .data-table tbody, 
  .data-table th, 
  .data-table td, 
  .data-table tr {
    display: block;
    width: 100%;
  }

  .data-table thead {
    display: none; /* Oculta cabeçalhos da tabela */
  }

  .data-table tr {
    margin-bottom: 16px;
    background: white;
    border: 1px solid hsl(210, 15%, 90%);
    border-radius: var(--border-radius-md);
    padding: 14px 18px;
    box-shadow: var(--box-shadow-soft);
  }

  .data-table tr:hover {
    background-color: white;
  }

  .data-table td {
    border: none;
    padding: 8px 0;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed hsl(210, 15%, 95%);
    text-align: right;
  }

  .data-table td:last-child {
    border-bottom: none;
    padding-top: 12px;
    justify-content: flex-end;
  }

  /* Injeta a legenda lateral do campo usando o data-label */
  .data-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    float: left;
    text-align: left;
  }

  /* Ajuste para botões de ação e contêineres nas linhas */
  .pet-pill-container {
    justify-content: flex-end;
    flex-wrap: wrap;
    max-width: 70%;
  }
}

/* Garante ocultação em telas maiores */
@media (min-width: 769px) {
  .mobile-bottom-nav {
    display: none !important;
  }
}

/* Indicador Táxi Dog (Borda Azul) */
.appt-calendar-card.taxi-dog-active {
  box-shadow: 0 0 0 2px var(--color-info) !important;
}
.month-day-appt-pill.taxi-dog-active {
  box-shadow: 0 0 0 1.5px var(--color-info) !important;
}

/* Grade da Agenda Diária */
.day-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}
