/* ========================================================== */
/* VARIÁVEIS & SETUP (Consistente com Geral/Resumo) */
/* ========================================================== */
:host {
  --brand: #E33DCF;
  --brand-soft: rgba(227, 61, 207, 0.08);
  --brand-hover: #c92bb6;
  
  --blue: #030FAA;
  --blue-soft: rgba(3, 15, 170, 0.08);
  
  --text-main: #111827;
  --text-muted: rgba(17, 18, 20, 0.65);
  
  --bg-page: #f8fafc;
  --card-bg: rgba(255, 255, 255, 0.9);
  --glass-border: 1px solid rgba(255, 255, 255, 0.6);
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 20px 40px -5px rgba(0, 0, 0, 0.1);
  
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;

  /* Cores de Gráfico (Palette do Sistema) */
  --chart-pink: #E33DCF;
  --chart-blue: #030FAA;
  --chart-purple: #6A55FF;
  --chart-pink-soft: #F3B0E8;
  --chart-dark: #B832A8;

  display: block;
  font-family: 'Inter', sans-serif;
  color: var(--text-main);
}

/* Remove footer se necessário (herdado do antigo css) */
:host ::ng-deep footer,
:host ::ng-deep .footer,
:host ::ng-deep .portal-footer,
:host ::ng-deep .app-footer {
  display: none !important;
}

/* ========================================================== */
/* LAYOUT BASE */
/* ========================================================== */
.dashboard-page {
  min-height: 100vh;
  padding-bottom: 60px;
  background: 
    radial-gradient(circle at 15% 10%, rgba(227, 61, 207, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(3, 15, 170, 0.06) 0%, transparent 40%),
    var(--bg-page);
  position: relative;
  overflow-x: hidden;
}

.page-blob {
  position: fixed; pointer-events: none; border-radius: 999px;
  filter: blur(40px); opacity: 0.6; z-index: 0;
  
  &.blob-1 { width: 300px; height: 300px; top: -100px; left: -50px; background: rgba(227,61,207,0.3); }
  &.blob-2 { width: 400px; height: 400px; top: 20%; right: -100px; background: rgba(3,15,170,0.2); }
  &.blob-3 { width: 350px; height: 350px; bottom: 0; left: 20%; background: rgba(106,85,255,0.2); }
}

.container-dashboard {
  width: 100%;
  max-width: 1380px; /* Largura executiva */
  margin: 0 auto;
  padding: 24px 20px;
  position: relative;
  z-index: 1;
}

/* Animações */
.fade-in-up {
  opacity: 0;
  animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================================================== */
/* HEADER */
/* ========================================================== */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  
  @media(max-width: 768px) { flex-direction: column; align-items: flex-start; gap: 16px; }
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 99px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  i { font-size: 14px; }
}

.page-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 4px;
  color: var(--text-main);
  line-height: 1.1;
}

.page-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0;
}

.head-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  
  &.error { color: #dc2626; }
}

.last-update {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  i { color: #10b981; }
}

/* ========================================================== */
/* HERO KPIS */
/* ========================================================== */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;

  @media (min-width: 1500px) {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.hero-card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  
  &:hover {
    transform: translateY(-3px);
    background: #fff;
    box-shadow: var(--shadow-card);
    border-color: rgba(227, 61, 207, 0.2);
  }
}

.hero-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), #9d2ec5);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(227, 61, 207, 0.3);
}

.hero-data {
  display: flex; flex-direction: column;
}

.hero-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.hero-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 2px;
}

.hero-hint {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.8;
  margin-top: 4px;
}

/* ========================================================== */
/* CARDS MODERNOS (Container Genérico) */
/* ========================================================== */
.card-modern {
  background: #fff;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(0,0,0,0.04);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  height: 100%;
  
  &:hover {
    box-shadow: var(--shadow-hover);
  }
}

.card-header-clean {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(250, 250, 252, 0.5);
  
  .header-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: grid; place-items: center;
    font-size: 16px;
    
    &.brand { background: var(--brand-soft); color: var(--brand); }
    &.blue { background: var(--blue-soft); color: var(--blue); }
    &.purple { background: rgba(106, 85, 255, 0.1); color: var(--chart-purple); }
    &.warning { background: rgba(245, 158, 11, 0.1); color: #d97706; }
  }
  
  h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-main);
  }
  
  p {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
  }
}

/* ========================================================== */
/* SEÇÃO 1: STATUS SPLIT */
/* ========================================================== */
.dashboard-section {
  margin-bottom: 24px;
}

.context-title {
  margin: 4px 0 14px;

  h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
  }

  p {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
  }
}

.section-top-row {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;

  @media(max-width: 1120px) { grid-template-columns: 1fr; }
}

.section-bottom-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;

  @media(max-width: 900px) { grid-template-columns: 1fr; }
}

.card-body-split {
  padding: 14px 16px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 12px;

  @media(max-width: 700px) { grid-template-columns: 1fr; }
}

.chart-wrapper-pie {
  position: relative;
  height: 184px;
  width: 100%;
}

.status-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: #f8fafc;
  border-radius: 10px;
  font-size: 12px;
  
  .dot { width: 8px; height: 8px; border-radius: 50%; margin-right: 10px; }
  .d-active { background: var(--chart-blue); box-shadow: 0 0 0 2px rgba(3, 15, 170, 0.2); }
  .d-reserve { background: var(--chart-pink-soft); }
  .d-blocked { background: var(--chart-dark); }
  .d-blocked-soft { background: var(--chart-purple); }
  
  .lbl { font-weight: 600; color: var(--text-muted); margin-right: auto; }
  .val { font-weight: 800; color: var(--text-main); font-size: 13px; }
  
  &.total-row {
    background: var(--brand-soft);
    border: 1px solid rgba(227, 61, 207, 0.1);
    margin-top: 4px;
    .lbl { color: var(--brand); text-transform: uppercase; font-size: 11px; font-weight: 800; }
    .val { color: var(--brand); font-size: 16px; }
  }
}

.chart-wrapper-bar {
  padding: 16px 20px 20px;
  height: 220px;
  position: relative;
  
  &.compact { height: 180px; }
  &.compact-half { height: 200px; }
}

.card-adicionais .card-body-adicionais {
  padding: 14px 16px 12px;
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 12px;
  align-items: center;

  @media(max-width: 700px) { grid-template-columns: 1fr; }
}

.chart-wrapper-pie-sm {
  position: relative;
  height: 186px;
  width: 100%;
}

.compare-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compare-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.05);
  font-size: 12px;

  .dot { width: 8px; height: 8px; border-radius: 50%; }
  .d-com-add { background: var(--chart-purple); box-shadow: 0 0 0 2px rgba(106, 85, 255, 0.2); }
  .d-sem-add { background: var(--brand); box-shadow: 0 0 0 2px rgba(227, 61, 207, 0.18); }
  .lbl { color: var(--text-muted); font-weight: 700; }
  .val { color: var(--text-main); font-weight: 800; }
  .pct {
    color: var(--blue);
    font-weight: 800;
    background: rgba(3, 15, 170, 0.1);
    border-radius: 999px;
    padding: 2px 8px;
  }

  &.total-row {
    grid-template-columns: 1fr auto;
    .lbl { color: var(--brand); text-transform: uppercase; font-size: 11px; letter-spacing: 0.03em; }
    .val { color: var(--brand); font-size: 14px; }
  }
}

/* ========================================================== */
/* SEÇÃO 2: ANALYTICS INTEGRADO (TOOLBAR) */
/* ========================================================== */
.toolbar-header {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.title-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  
  i { font-size: 20px; margin-top: 2px; }
  h3 { margin: 0; font-size: 16px; font-weight: 800; }
  p { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  
  label { font-size: 12px; font-weight: 700; color: var(--text-muted); white-space: nowrap; }
}

.form-select-sm {
  padding: 4px 28px 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  font-size: 12px;
  font-weight: 700;
  background-color: #f8fafc;
  cursor: pointer;
  &:focus { border-color: var(--brand); outline: none; }
}

.divider-v {
  width: 1px; height: 24px; background: rgba(0,0,0,0.1);
}

.btn-link {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--brand-soft);
  transition: all 0.2s;
  
  &:hover { background: rgba(227, 61, 207, 0.15); transform: translateX(2px); }
}

.card-body-grid {
  padding: 20px;
  position: relative;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  
  @media(max-width: 820px) { grid-template-columns: 1fr; }
}

.mini-chart-card {
  background: #fdfdfd;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  
  h6 {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    text-align: center;
  }
}

.mini-metric-card {
  .metric-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 2px 2px;
  }

  .metric-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.06);

    span {
      font-size: 12px;
      color: var(--text-muted);
      font-weight: 700;
    }

    strong {
      font-size: 13px;
      color: var(--text-main);
      font-weight: 800;
      text-align: right;
    }
  }
}

.chart-area {
  position: relative;
  height: 280px;
  width: 100%;
}

.loading-overlay {
  position: absolute; inset: 0; background: rgba(255,255,255,0.8); z-index: 10;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}

.error-state {
  padding: 40px; text-align: center; color: #d97706; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  i { font-size: 24px; }
}

/* ========================================================== */
/* SEÇÃO 3: GRIDS FINAIS */
/* ========================================================== */
.grid-thirds {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  
  @media(max-width: 1000px) { grid-template-columns: 1fr; }
}

.grid-halves {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  
  @media(max-width: 800px) { grid-template-columns: 1fr; }
}

.grid-triples {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;

  @media(max-width: 1100px) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  @media(max-width: 800px) { grid-template-columns: 1fr; }
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;

  @media(max-width: 1080px) { grid-template-columns: 1fr; }
}

/* Utils */
.text-brand { color: var(--brand); }
.text-brand-dark { color: #b832a8; }
.full-width { width: 100%; }
