/* ============================================================
   Guardacampo — Custom Styles
   Dark security-system theme with sage-green accent
   ============================================================ */

:root {
  --gc-bg:           #0d1117;
  --gc-surface:      #161b24;
  --gc-surface-2:    #1e2533;
  --gc-border:       #2a3344;
  --gc-accent:       #5c8f48;
  --gc-accent-hover: #6aaa54;
  --gc-accent-dim:   rgba(92, 143, 72, 0.15);
  --gc-text:         #c8d3e0;
  --gc-muted:        #6a7d92;
  --gc-heading:      #e8edf2;
  --gc-green:        #3dba6c;
  --gc-red:          #e05252;
  --gc-yellow:       #d4a426;
  --gc-blue:         #4a8fc8;
  --gc-input-bg:     #1a2030;
  --gc-input-border: #2f3d52;
  --gc-shadow:       0 4px 24px rgba(0,0,0,0.45);
}

[data-theme="light"] {
  --gc-bg:           #f0f4f0;
  --gc-surface:      #ffffff;
  --gc-surface-2:    #eaf0e8;
  --gc-border:       #ccd8c4;
  --gc-accent:       #4a7a38;
  --gc-accent-hover: #3d6830;
  --gc-accent-dim:   rgba(74, 122, 56, 0.12);
  --gc-text:         #2c3a2c;
  --gc-muted:        #6a826a;
  --gc-heading:      #1a2a1a;
  --gc-green:        #2e8f50;
  --gc-red:          #c0392b;
  --gc-yellow:       #b8860b;
  --gc-blue:         #2c6fa8;
  --gc-input-bg:     #ffffff;
  --gc-input-border: #b0c4a8;
  --gc-shadow:       0 4px 24px rgba(0,0,0,0.12);
}

/* ── Base ── */
body { background-color: var(--gc-bg); color: var(--gc-text); font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }

/* ── Auth page ── */
.gc-auth-bg {
  background:
    radial-gradient(ellipse 800px 500px at 20% 40%, rgba(92, 143, 72, 0.06) 0%, transparent 70%),
    var(--gc-bg);
}
.gc-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--gc-surface);
  border: 1px solid var(--gc-border);
  border-radius: 14px;
  color: var(--gc-text);
}
.gc-logo-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--gc-accent-dim);
  border: 1px solid var(--gc-accent);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--gc-accent);
  font-size: 1.6rem;
}
.gc-divider { border-color: var(--gc-border); }

/* ── App layout ── */
.gc-app-bg { background-color: var(--gc-bg); min-height: 100vh; }

/* ── Navbar ── */
.gc-navbar {
  background: var(--gc-surface);
  border-bottom: 1px solid var(--gc-border);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.gc-brand-icon { color: var(--gc-accent); font-size: 1.3rem; }
.gc-brand-text  { color: var(--gc-heading); letter-spacing: 0.01em; }
.gc-nav-link {
  color: var(--gc-muted) !important;
  border-radius: 7px;
  padding: 6px 12px !important;
  transition: color 0.15s, background 0.15s;
  font-size: 0.9rem;
}
.gc-nav-link:hover,
.gc-nav-link.active {
  color: var(--gc-heading) !important;
  background: var(--gc-accent-dim);
}
.gc-nav-link.active { color: var(--gc-accent) !important; }
.navbar-toggler { border: none; }
.navbar-toggler:focus { box-shadow: none; }

/* ── Typography ── */
.gc-heading { color: var(--gc-heading); }
.gc-muted   { color: var(--gc-muted); }
.gc-accent  { color: var(--gc-accent); }
.gc-green   { color: var(--gc-green); }
.gc-red     { color: var(--gc-red); }
.gc-yellow  { color: var(--gc-yellow); }

/* ── Cards ── */
.gc-card {
  background: var(--gc-surface);
  border: 1px solid var(--gc-border);
  border-radius: 12px;
  color: var(--gc-text);
}
.gc-card-header {
  background: var(--gc-surface-2);
  border-bottom: 1px solid var(--gc-border);
  border-radius: 12px 12px 0 0 !important;
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--gc-heading);
}

/* ── Stat cards ── */
.gc-stat-value { font-size: 1.9rem; font-weight: 700; color: var(--gc-heading); line-height: 1.1; }
.gc-stat-icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.gc-stat-icon--blue   { background: rgba(74,143,200,0.15); color: var(--gc-blue);   }
.gc-stat-icon--green  { background: rgba(61,186,108,0.15); color: var(--gc-green);  }
.gc-stat-icon--red    { background: rgba(224,82,82,0.15);  color: var(--gc-red);    }
.gc-stat-icon--yellow { background: rgba(212,164,38,0.15); color: var(--gc-yellow); }

/* ── List inside cards ── */
.gc-list { max-height: 340px; overflow-y: auto; }
.gc-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gc-border);
  font-size: 0.875rem;
  transition: background 0.1s;
}
.gc-list-item:last-child { border-bottom: none; }
.gc-list-item:hover { background: var(--gc-surface-2); }
.gc-list-empty { color: var(--gc-muted); }

/* ── Inputs ── */
.gc-input, .form-control.gc-input, .form-select.gc-input {
  background: var(--gc-input-bg);
  border: 1px solid var(--gc-input-border);
  color: var(--gc-text);
  border-radius: 8px;
}
.gc-input:focus, .form-control.gc-input:focus, .form-select.gc-input:focus {
  background: var(--gc-input-bg);
  border-color: var(--gc-accent);
  color: var(--gc-text);
  box-shadow: 0 0 0 3px rgba(92,143,72,0.18);
}
.gc-input::placeholder { color: var(--gc-muted); }
.gc-input-icon {
  background: var(--gc-surface-2);
  border: 1px solid var(--gc-input-border);
  color: var(--gc-muted);
}
.form-select.gc-input option { background: var(--gc-input-bg); }

/* ── Buttons ── */
.btn-gc {
  background: var(--gc-accent);
  border-color: var(--gc-accent);
  color: #fff;
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.btn-gc:hover, .btn-gc:focus {
  background: var(--gc-accent-hover);
  border-color: var(--gc-accent-hover);
  color: #fff;
}
.btn-gc-outline {
  background: transparent;
  border: 1px solid var(--gc-accent);
  color: var(--gc-accent);
  border-radius: 8px;
  transition: background 0.15s;
}
.btn-gc-outline:hover {
  background: var(--gc-accent-dim);
  color: var(--gc-accent);
}
.gc-btn-secondary {
  background: var(--gc-surface-2);
  border: 1px solid var(--gc-border);
  color: var(--gc-muted);
  border-radius: 8px;
}
.gc-btn-secondary:hover {
  background: var(--gc-border);
  color: var(--gc-text);
}
.gc-link { color: var(--gc-muted); text-decoration: none; }
.gc-link:hover { color: var(--gc-accent); }

/* ── Table ── */
.gc-table { color: var(--gc-text); margin: 0; --bs-table-bg: transparent; }
.gc-table thead th {
  background: var(--gc-surface-2);
  color: var(--gc-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-color: var(--gc-border);
  padding: 10px 14px;
}
.gc-table tbody tr { background: var(--gc-surface); border-color: var(--gc-border); }
.gc-table tbody td { padding: 10px 14px; vertical-align: middle; border-color: var(--gc-border); font-size: 0.875rem; }
.gc-table tbody tr:hover { background: var(--gc-surface-2); }
.gc-th-sort { cursor: pointer; -webkit-user-select: none; user-select: none; white-space: nowrap; }
.gc-th-sort:hover { color: var(--gc-text); }
.gc-sort-icon { font-size: 0.7rem; opacity: 0.35; margin-left: 2px; vertical-align: middle; }
.gc-th-sort.sort-asc .gc-sort-icon,
.gc-th-sort.sort-desc .gc-sort-icon { opacity: 1; color: var(--gc-accent); }
.gc-th-sort.sort-asc  .gc-sort-icon::before { content: "\F235"; } /* bi-arrow-up   */
.gc-th-sort.sort-desc .gc-sort-icon::before { content: "\F229"; } /* bi-arrow-down */

/* ── Badges ── */
.gc-badge-online  { background: rgba(61,186,108,0.15); color: var(--gc-green);  border: 1px solid rgba(61,186,108,0.3);  border-radius: 6px; padding: 2px 8px; font-size: 0.78rem; font-weight: 600; }
.gc-badge-offline { background: rgba(106,125,146,0.15); color: var(--gc-muted); border: 1px solid rgba(106,125,146,0.3); border-radius: 6px; padding: 2px 8px; font-size: 0.78rem; font-weight: 600; }
.gc-badge-alert   { background: rgba(224,82,82,0.15);  color: var(--gc-red);   border: 1px solid rgba(224,82,82,0.3);   border-radius: 6px; padding: 2px 8px; font-size: 0.78rem; font-weight: 600; }

/* ── Sensor filter ── */
.gc-sensor-filter-wrap { max-width: 260px; }

/* ── Chart frame ── */
.gc-chart-frame-body { height: 560px; }
.gc-chart-frame { width: 100%; height: 100%; border: none; border-radius: inherit; display: block; }

/* ── Map page layout ── */
.gc-map-page { height: calc(100vh - 56px); display: flex; flex-direction: column; }
.gc-map-body  { flex: 1; min-height: 0; }

/* ── Map toolbar / legend ── */
.gc-map-toolbar {
  background: var(--gc-surface);
  border-bottom: 1px solid var(--gc-border);
  color: var(--gc-heading);
  font-size: 0.9rem;
}
.gc-map-legend {
  background: var(--gc-surface);
  border-top: 1px solid var(--gc-border);
  color: var(--gc-muted);
  font-size: 0.82rem;
}
.gc-legend-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.gc-legend-online  { background: var(--gc-green); }
.gc-legend-offline { background: var(--gc-muted); }
.gc-legend-alert   { background: var(--gc-red); }

/* Leaflet popup */
.leaflet-popup-content-wrapper {
  background: var(--gc-surface);
  color: var(--gc-text);
  border: 1px solid var(--gc-border);
  border-radius: 10px;
  box-shadow: var(--gc-shadow);
}
.leaflet-popup-tip { background: var(--gc-surface); }
.leaflet-popup-content { margin: 10px 14px; font-size: 0.85rem; }
.leaflet-container { background: var(--gc-surface-2); }

/* ── Modal ── */
.gc-modal {
  background: var(--gc-surface);
  border: 1px solid var(--gc-border);
  border-radius: 14px;
  color: var(--gc-text);
}
.gc-modal-header {
  background: var(--gc-surface-2);
  border-bottom: 1px solid var(--gc-border);
  border-radius: 14px 14px 0 0;
  padding: 14px 18px;
}
.gc-modal-footer {
  background: var(--gc-surface-2);
  border-top: 1px solid var(--gc-border);
  border-radius: 0 0 14px 14px;
  padding: 12px 18px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gc-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gc-muted); }

/* ── Alert overrides ── */
.alert-danger  { background: rgba(224,82,82,0.12);  border-color: rgba(224,82,82,0.3);   color: #f08080; }
.alert-success { background: rgba(61,186,108,0.12); border-color: rgba(61,186,108,0.3);  color: var(--gc-green); }
.alert-info    { background: rgba(74,143,200,0.12); border-color: rgba(74,143,200,0.3);  color: #7ab8e8; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .page-content { padding: 16px !important; }
  .gc-stat-value { font-size: 1.5rem; }
}
