/* ═══════════════════════════════════════════════════════════
   GRUPOLAR — Dashboard Styles
   Dark industrial analytics theme with glassmorphism
   ═══════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Surface */
  --bg-base: #0a0a0f;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-elevated: rgba(255, 255, 255, 0.06);
  --bg-input: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.12);

  /* Palette */
  --primary: #00d4aa;
  --primary-dim: rgba(0, 212, 170, 0.15);
  --secondary: #6366f1;
  --secondary-dim: rgba(99, 102, 241, 0.15);
  --warning: #f59e0b;
  --warning-dim: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.15);
  --success: #22c55e;

  /* Text */
  --text-primary: #f0f0f5;
  --text-secondary: #9ca3af;
  --text-tertiary: #6b7280;

  /* Misc */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --blur: 20px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glow: 0 0 40px rgba(0, 212, 170, 0.06);
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle background gradient */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(0, 212, 170, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(99, 102, 241, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Header ────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  background: rgba(10, 10, 15, 0.82);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--border-subtle);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.header__logo {
  flex-shrink: 0;
}

.header__title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.header__subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.3px;
}

.header__meta {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header__clock {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.header__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot--connected {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot--disconnected {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Main Layout ───────────────────────────────────────── */
.main {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Sections ──────────────────────────────────────────── */
.section {
  background: var(--bg-card);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-glow);
  transition: border-color var(--transition);
}

.section:hover {
  border-color: var(--border-medium);
}

.section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section__title {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section__icon {
  font-size: 1.15rem;
}

/* ── Badge ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
}


/* ── Toolbar / Filters ─────────────────────────────────── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.toolbar__group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.toolbar__label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn--sm {
  font-size: 0.78rem;
  padding: 0.45rem 0.85rem;
}

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

.btn--primary:hover {
  background: #00e6b8;
  box-shadow: 0 0 20px rgba(0, 212, 170, 0.3);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn--ghost:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn--active {
  background: var(--primary-dim);
  color: var(--primary);
  border: 1px solid rgba(0, 212, 170, 0.3);
}

.btn--save {
  background: var(--secondary);
  color: #fff;
}

.btn--save:hover {
  background: #818cf8;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.btn-group {
  display: flex;
  gap: 0.35rem;
}

/* ── Select & Input ────────────────────────────────────── */
.select,
.input {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  outline: none;
  transition: all var(--transition);
  min-width: 0;
}

.select:focus,
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

.select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

/* ── Class Chips ───────────────────────────────────────── */
.class-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.chip--selected {
  background: var(--chip-color-dim, var(--primary-dim));
  color: var(--chip-color, var(--primary));
  border-color: var(--chip-color, var(--primary));
}

/* ── Chart ─────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 360px;
  max-height: 480px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Table ─────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.table thead {
  background: var(--bg-elevated);
}

.table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-subtle);
}

.table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

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

.table tbody tr:hover {
  background: var(--bg-card-hover);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table__empty {
  text-align: center;
  padding: 2rem 1rem !important;
  color: var(--text-tertiary) !important;
}

.table .count-cell {
  font-weight: 700;
  color: var(--warning);
  font-variant-numeric: tabular-nums;
}

/* ── Subsection (Filter Settings) ──────────────────────── */
.subsection {
  margin-top: 0.5rem;
}

.subsection__title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.subsection__desc {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-bottom: 1rem;
}

.filter-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.filter-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: all var(--transition);
}

.filter-card:hover {
  border-color: var(--border-medium);
}

.filter-card__title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--secondary);
}

.filter-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.filter-card__label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.filter-card__input {
  width: 90px;
  text-align: right;
}

.filter-card__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* ── Toast Notifications ───────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  animation: toast-in 0.35s ease;
  max-width: 380px;
}

.toast--success {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.25);
}

.toast--error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.25);
}

.toast--info {
  background: rgba(99, 102, 241, 0.12);
  color: var(--secondary);
  border-color: rgba(99, 102, 241, 0.25);
}

.toast.toast--out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 1024px) {
  .main {
    padding: 1rem;
  }

  .header {
    padding: 0.75rem 1rem;
  }



  .toolbar {
    gap: 0.75rem;
  }
}

@media (max-width: 640px) {
  .header {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }

  .header__meta {
    width: 100%;
    justify-content: center;
  }



  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar__group {
    width: 100%;
  }

  .btn-group {
    width: 100%;
  }

  .btn-group .btn {
    flex: 1;
    justify-content: center;
  }

  .chart-wrap {
    min-height: 260px;
  }

  .filter-cards {
    grid-template-columns: 1fr;
  }
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ── Camera Areas ──────────────────────────────────────── */
.areas-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.area-camera-group {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: all var(--transition);
}

.area-camera-group:hover {
  border-color: var(--border-medium);
}

.area-camera-group__title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--secondary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.area-item {
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.area-item:last-child {
  margin-bottom: 0;
}

.area-item:hover {
  border-color: var(--border-medium);
}

.area-item--inactive {
  opacity: 0.5;
}

.area-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.area-item__name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.area-item__status {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.area-item__status--active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.area-item__status--inactive {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.area-item__meta {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-bottom: 0.65rem;
}

.area-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.area-item__label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.area-item__input {
  flex: 1;
  text-align: right;
}

.area-item__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

/* ── Utility ───────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
