/* ================================================================
   SEMPRE CONECTADO — Design System v2.0
   "Botanical Terminal"
   Bricolage Grotesque · Plus Jakarta Sans · JetBrains Mono
   ================================================================ */

/* ── Tokens ─────────────────────────────────────────────────────── */
:root {
  --font-display: 'Bricolage Grotesque', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', monospace;

  --bg: #f2ebe1;
  --surface: rgba(255, 251, 245, 0.72);
  --surface-solid: #fffbf5;
  --surface-alt: #ede3d4;
  --ink: #1a1714;
  --muted: #7a7168;
  --line: rgba(170, 155, 130, 0.28);
  --brand: #0f7b66;
  --brand-strong: #0a5e4d;
  --accent: #e09422;
  --danger: #c0392b;
  --warning: #d4891a;
  --info: #2856b0;

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow: 0 4px 20px rgba(26,23,20,0.06), 0 1px 4px rgba(26,23,20,0.05);
  --shadow-lg: 0 12px 40px rgba(26,23,20,0.08), 0 2px 8px rgba(26,23,20,0.04);
  --shadow-xl: 0 24px 60px rgba(26,23,20,0.1);

  --transition: 220ms cubic-bezier(0.4,0,0.2,1);
  --ease-out-expo: cubic-bezier(0.19,1,0.22,1);
}

/* ── Keyframes ──────────────────────────────────────────────────── */
@keyframes sc-fadeInUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes sc-scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes sc-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(15,123,102,0.45); }
  50%     { box-shadow: 0 0 0 7px rgba(15,123,102,0); }
}
@keyframes sc-pulseWarn {
  0%,100% { box-shadow: 0 0 0 0 rgba(212,137,26,0.4); }
  50%     { box-shadow: 0 0 0 7px rgba(212,137,26,0); }
}
@keyframes sc-gradientFlow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── Base ───────────────────────────────────────────────────────── */
body {
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse at 18% 22%, rgba(15,123,102,0.06), transparent 48%),
    radial-gradient(ellipse at 82% 8%, rgba(224,148,34,0.04), transparent 38%),
    radial-gradient(ellipse at 45% 85%, rgba(40,86,176,0.03), transparent 42%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Dot-grid overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(26,23,20,0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: -1;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(15,123,102,0.18); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(15,123,102,0.32); }

/* Text selection */
::selection { background: rgba(15,123,102,0.15); color: var(--ink); }

/* Focus */
*:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── Typography ─────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); }
.code-badge, code, kbd, pre, samp { font-family: var(--font-mono); }

/* ── Cards (Glassmorphism) ──────────────────────────────────────── */
.stats-card,
.mobile-card,
.table-container,
.status-legend-card {
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stats-card:hover,
.mobile-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* Staggered entrance */
.stats-card            { animation: sc-fadeInUp 650ms var(--ease-out-expo) both; }
.stats-card:nth-child(1) { animation-delay: 50ms; }
.stats-card:nth-child(2) { animation-delay: 120ms; }
.stats-card:nth-child(3) { animation-delay: 190ms; }
.stats-card:nth-child(4) { animation-delay: 260ms; }

.mobile-card            { animation: sc-fadeInUp 600ms var(--ease-out-expo) both; }
.mobile-card:nth-child(1) { animation-delay: 80ms; }
.mobile-card:nth-child(2) { animation-delay: 150ms; }
.mobile-card:nth-child(3) { animation-delay: 220ms; }
.mobile-card:nth-child(4) { animation-delay: 290ms; }
.mobile-card:nth-child(5) { animation-delay: 360ms; }
.mobile-card:nth-child(n+6) { animation-delay: 430ms; }

.table-container { animation: sc-fadeInUp 650ms var(--ease-out-expo) 200ms both; }

/* ── Dashboard Header ───────────────────────────────────────────── */
.main-header {
  background: linear-gradient(135deg, #082822 0%, #0c4238 28%, #0f7b66 62%, #17a68c 100%);
  background-size: 200% 200%;
  animation: sc-gradientFlow 18s ease infinite;
}

.main-header::after { border-color: rgba(255,255,255,0.1); }

.hero-kicker {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.2em;
  font-size: 0.72rem;
}
.hero-subtitle { font-family: var(--font-body); }

.user-pill {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}

/* ── Stats ──────────────────────────────────────────────────────── */
.stats-icon {
  background: rgba(15,123,102,0.08);
  color: var(--brand);
  border-radius: var(--radius-md);
  transition: transform var(--transition);
}
.stats-card:hover .stats-icon { transform: scale(1.08); }

.stats-label {
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  font-weight: 700;
}

.stats-value { font-family: var(--font-display); }

/* ── Status Dots & Pills ────────────────────────────────────────── */
.device-dot--online {
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(15,123,102,0.15);
  animation: sc-pulse 2.2s ease-in-out infinite;
}

.device-dot--restarting {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(212,137,26,0.15);
  animation: sc-pulseWarn 1.8s ease-in-out infinite;
}

.device-status-pill {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  border-radius: var(--radius-sm);
}

.device-status-pill--online {
  background: rgba(15,123,102,0.08);
  border-color: rgba(15,123,102,0.18);
  color: var(--brand-strong, #0a5e4d);
}

.device-status-pill--restarting {
  background: rgba(212,137,26,0.08);
  border-color: rgba(212,137,26,0.18);
  color: #8c611c;
}

.device-status-pill--offline {
  background: rgba(192,57,43,0.06);
  border-color: rgba(192,57,43,0.15);
  color: var(--danger);
}

/* ── Code Badge ─────────────────────────────────────────────────── */
.code-badge {
  font-family: var(--font-mono);
  background: rgba(15,123,102,0.05);
  border: 1px solid rgba(15,123,102,0.12);
  color: #0a5e4d;
  border-radius: var(--radius-sm);
  letter-spacing: 0.03em;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-body);
  font-weight: 700;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-cta {
  background: var(--surface-solid);
  border: 1.5px solid rgba(170,155,130,0.35);
  color: var(--brand);
}
.btn-cta:hover {
  background: #fff;
  border-color: var(--brand);
  color: var(--brand);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(15,123,102,0.12);
}

.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover {
  background: #0a5e4d;
  border-color: #0a5e4d;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(15,123,102,0.25);
}

.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover {
  background: #a93226;
  border-color: #a93226;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(192,57,43,0.25);
}

.btn-warning { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-warning:hover {
  background: #c98520;
  border-color: #c98520;
  color: #fff;
  transform: translateY(-1px);
}

.action-btn {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.45);
  backdrop-filter: blur(8px);
  transition: all var(--transition);
}
.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.action-btn--history:hover { border-color: var(--brand); color: var(--brand); }
.action-btn--reset:hover   { border-color: var(--accent); color: #b87a1c; }
.action-btn--delete:hover  { border-color: var(--danger); color: var(--danger); }
.action-btn--config:hover  { border-color: var(--info); color: var(--info); }

/* ── Bootstrap Form Override ────────────────────────────────────── */
.form-control:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.2rem rgba(15,123,102,0.18);
}

.form-check-input:checked {
  background-color: var(--brand);
  border-color: var(--brand);
}

/* ── Tables ─────────────────────────────────────────────────────── */
.table th {
  font-family: var(--font-display);
  background: rgba(15,123,102,0.04);
  letter-spacing: 0.1em;
  font-weight: 700;
}
.table td { border-color: var(--line); }
.table-hover tbody tr:hover { background-color: rgba(15,123,102,0.03); }
.device-name { font-weight: 700; }
.device-name:hover { color: var(--brand); }

/* ── Desktop Nav (higher specificity to beat inline) ────────────── */
nav.sc-desktop-nav {
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid rgba(255,255,255,0.5);
  box-shadow: 0 1px 12px rgba(26,23,20,0.04);
  height: 64px;
}
nav.sc-desktop-nav .sc-desktop-nav__brand {
  font-family: var(--font-display);
  color: var(--brand);
  font-weight: 800;
  letter-spacing: -0.02em;
}
nav.sc-desktop-nav .sc-desktop-nav__links a {
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
nav.sc-desktop-nav .sc-desktop-nav__links a:hover {
  background: rgba(15,123,102,0.06);
  color: var(--brand);
}
nav.sc-desktop-nav .sc-desktop-nav__links a.active {
  background: rgba(15,123,102,0.08);
  color: var(--brand);
}
nav.sc-desktop-nav .sc-desktop-nav__links .btn-logout {
  color: var(--danger);
  border-color: var(--line);
}
nav.sc-desktop-nav .sc-desktop-nav__links .btn-logout:hover {
  background: rgba(192,57,43,0.06);
  border-color: var(--danger);
}

/* ── Mobile Card Header ─────────────────────────────────────────── */
.mobile-card .card-header {
  background: rgba(15,123,102,0.03);
  font-family: var(--font-display);
}

/* ── Modals ─────────────────────────────────────────────────────── */
.modal-content {
  background: var(--surface-solid);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: sc-scaleIn 280ms var(--ease-out-expo);
}
.modal-header.bg-danger {
  background: linear-gradient(135deg, #b83227, #e74c3c) !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header.bg-warning {
  background: linear-gradient(135deg, #c9892d, #e8a838) !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-footer .btn-secondary {
  background: var(--surface-alt);
  border-color: var(--line);
  color: var(--muted);
}
.modal-footer .btn-secondary:hover { background: #e0d5c5; }

/* ── Login Page ─────────────────────────────────────────────────── */
.login-panel { font-family: var(--font-body); }

.login-heading {
  font-family: var(--font-display);
  font-size: 1.85rem;
  letter-spacing: -0.03em;
  animation: sc-fadeInUp 700ms var(--ease-out-expo) 100ms both;
}
.login-sub { animation: sc-fadeInUp 700ms var(--ease-out-expo) 200ms both; }

#login-form { animation: sc-fadeInUp 700ms var(--ease-out-expo) 280ms both; }

.login-visual {
  background: linear-gradient(135deg, #082822 0%, #0c4238 28%, #0f7b66 62%, #17a68c 100%);
}

.visual-title {
  font-family: var(--font-display);
  font-size: 2.3rem;
  letter-spacing: -0.02em;
}
.visual-pill {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
}

.btn-login {
  background: linear-gradient(135deg, #082822 0%, #0d6b58 50%, #17a68c 100%);
  font-family: var(--font-body);
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}
.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15,123,102,0.3);
}

.form-input {
  font-family: var(--font-body);
  border-radius: var(--radius-sm);
  border-color: var(--line);
  transition: all var(--transition);
}
.form-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15,123,102,0.12);
}

.auth-link, .auth-links a { color: var(--brand); }
.auth-link:hover, .auth-links a:hover { color: #0a5e4d; }

.btn-install { color: var(--brand); border-color: var(--brand); }
.btn-install:hover { background: var(--brand); color: #fff; }

/* ── Cookie Consent ─────────────────────────────────────────────── */
.cookie-btn.accept { background: var(--brand); border-color: var(--brand); }
.cookie-btn.accept:hover { background: #0a5e4d; border-color: #0a5e4d; }

/* ── Push Notifications ─────────────────────────────────────────── */
.btn-notif { font-family: var(--font-body); border-radius: var(--radius-sm); }
.btn-notif.active {
  background: rgba(15,123,102,0.75);
  border-color: rgba(15,123,102,0.9);
}

.push-toast { border-radius: var(--radius-md); font-family: var(--font-body); }
.push-toast.toast-ok { background: #0a5e4d; }

.push-banner { background: linear-gradient(90deg, #082822, #0c3830); border-left-color: var(--brand); }
.push-banner i { color: #4ad4b5; }
.push-banner button { background: var(--brand); color: #fff; }
.push-banner button:hover { background: #0a5e4d; }

.push-suggest-bar { background: #0a2e26; border-left-color: var(--brand); }
.push-suggest-bar i { color: #4ad4b5; }
.push-suggest-bar button { background: var(--brand); color: #fff; }
.push-suggest-bar button:hover { background: #0a5e4d; }

#push-error-box button { background: var(--brand); }
#push-error-box button:hover { background: #0a5e4d; }

/* ── PWA Nav ────────────────────────────────────────────────────── */
.pwa-nav { font-family: var(--font-body); }
.pwa-nav .pwa-active { color: var(--brand); }
.pwa-nav .pwa-nav-add i { color: var(--brand); }

#ptr-indicator {
  background: var(--brand);
  font-family: var(--font-body);
  box-shadow: 0 4px 18px rgba(15,123,102,0.35);
}

#sc-toast { background: var(--brand); }

/* ── iOS Install Banner ─────────────────────────────────────────── */
#ios-install-banner { background: #0a2e26; border-top-color: #143d34; }
#ios-install-banner .ios-text strong { color: #4ad4b5; }

/* ── Hamburger & Mobile Menu ────────────────────────────────────── */
.mobile-hamburger { border-radius: var(--radius-sm); backdrop-filter: blur(8px); }
.mobile-menu-dropdown { background: #0c2e26; box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.mobile-menu-dropdown a { font-family: var(--font-body); color: #c8e6df; }
.mobile-menu-dropdown a:active { background: rgba(255,255,255,0.05); }

/* ── Content Head ───────────────────────────────────────────────── */
.content-head h2 { font-family: var(--font-display); }

/* ── Empty State ────────────────────────────────────────────────── */
.empty-state i { color: var(--brand); }

/* ── Edit Page ──────────────────────────────────────────────────── */
.card { border-radius: var(--radius-lg); border-color: rgba(255,255,255,0.5); }
.badge { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.03em; }

.btn-outline-success { color: var(--brand); border-color: var(--brand); }
.btn-outline-success:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

.btn-outline-warn { color: var(--accent); border-color: var(--accent); }
.btn-outline-warn:hover { background: var(--accent); color: #fff; }

/* ── Status Legend ──────────────────────────────────────────────── */
.status-legend-header { font-family: var(--font-display); }

/* ── Reduced Motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
