/* ============================================================
   style.css — Estilos globales del Uptime Monitor.
   Compartido por dashboard.php, search.php y login.php.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #FBF2E6;
  --card-1: #BBD257;
  --card-2: #DBEDDB;
  --text: #003E2B;
  --muted: #3f5b4c;
  --up: #003E2B;
  --down: #C0392B;
  --border: rgba(0, 62, 43, 0.18);
  --serif: 'DM Serif Display', serif;
  --sans: 'Plus Jakarta Sans', sans-serif;
  --mono: 'Plus Jakarta Sans', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

/* --- Layout de páginas "app" (dashboard, search) --- */
body.app-page { padding: 32px 20px 60px; }
.wrap { max-width: 880px; margin: 0 auto; }
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.logo { height: 30px; display: block; }
.url { color: var(--muted); font-family: var(--mono); font-size: 13px; display: flex; align-items: center; gap: 12px; }
.url a { color: var(--muted); }
.nav-links { color: var(--muted); font-family: var(--sans); font-size: 13px; display: flex; align-items: center; gap: 12px; }
.nav-links a { color: var(--text); font-weight: 600; }
.icon-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; color: var(--text);
  transition: background 0.15s; flex-shrink: 0;
}
.icon-link:hover { background: rgba(0,62,43,0.08); }
.icon-link svg { width: 16px; height: 16px; }

/* --- Botones de acción (refrescar / verificar) --- */
.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1.5px solid var(--text); color: var(--text); border-radius: 6px;
  padding: 6px 12px; font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  cursor: pointer; flex-shrink: 0; transition: background 0.15s;
}
.refresh-btn:hover { background: rgba(0,62,43,0.08); }
.refresh-btn.active { background: var(--text); color: var(--card-1); border-color: var(--text); }
.refresh-btn.active:hover { opacity: 0.88; background: var(--text); }
.refresh-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.refresh-btn.spinning svg { animation: spin 0.6s linear; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.verify-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--text); color: var(--card-1); border: none; border-radius: 6px;
  padding: 6px 12px; font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  cursor: pointer; flex-shrink: 0; transition: opacity 0.15s;
}
.verify-btn:hover { opacity: 0.88; }
.verify-btn:disabled { opacity: 0.6; cursor: default; }
.verify-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.verify-btn svg.spin { animation: spin 0.7s linear infinite; }

/* --- Popup de selección de ubicación --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,62,43,0.45);
  display: none; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg); border-radius: 16px; padding: 24px;
  width: 100%; max-width: 400px; max-height: 85vh; overflow-y: auto;
}
.modal h3 { font-family: var(--serif); font-weight: 400; font-size: 20px; margin: 0 0 16px; }
.location-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
  opacity: 0.55; margin: 14px 0 6px; font-family: var(--sans);
}
.location-group-label:first-of-type { margin-top: 0; }
.location-option {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--card-2); border: none; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 6px; font-family: var(--sans); font-size: 14px;
  color: var(--text); font-weight: 500; cursor: pointer; text-align: left;
  transition: background 0.12s;
}
.location-option:hover { background: var(--card-1); }
.location-option.global { font-weight: 700; background: var(--card-1); }
.location-option .flag { display: inline-flex; align-items: center; }
.modal-cancel {
  display: block; width: 100%; margin-top: 10px; background: none; border: 1px solid var(--text);
  color: var(--text); border-radius: 8px; padding: 9px; font-weight: 600; cursor: pointer;
  font-family: var(--sans); font-size: 13.5px;
}

/* --- Card de estado (dashboard) --- */
.status-card {
  background: var(--card-1);
  border-radius: 14px;
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 20px;
}
.status-info { display: flex; align-items: center; gap: 20px; min-width: 0; }
.status-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dot-wrap { position: relative; width: 16px; height: 16px; flex-shrink: 0; }
.dot { width: 16px; height: 16px; border-radius: 50%; position: relative; z-index: 1; }
.dot.up { background: var(--up); }
.dot.down { background: var(--down); }
.dot-ping { position: absolute; top: 0; left: 0; width: 16px; height: 16px; border-radius: 50%; }
.dot-ping.up { background: var(--up); animation: pulse 1.8s cubic-bezier(0,0,0.2,1) infinite; }
.dot-ping.down { background: var(--down); }
@keyframes pulse {
  0%   { transform: scale(1);   opacity: 0.55; }
  70%  { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}
.status-text { font-family: var(--serif); font-size: 26px; font-weight: 400; }
.status-sub { color: var(--muted); font-size: 13px; margin-top: 4px; font-family: var(--mono); }

/* --- Métricas de uptime --- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.metric { background: var(--card-2); border-radius: 14px; padding: 18px; }
.metric .label { color: var(--text); opacity: 0.75; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.metric .value { font-family: var(--serif); font-size: 30px; margin-top: 6px; }

/* --- Paneles genéricos --- */
.panel { background: var(--card-2); border-radius: 14px; padding: 20px; margin-bottom: 20px; }
.panel h2 { font-family: var(--serif); font-weight: 400; font-size: 20px; letter-spacing: 0; color: var(--text); margin: 0 0 16px; }
.see-all { font-family: var(--sans); font-size: 13px; font-weight: 500; }
.see-all a { color: var(--text); }

/* --- Formulario de filtros (search) --- */
form.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; opacity: 0.75; }
.field input, .field select {
  padding: 9px 10px; border-radius: 8px; border: 1px solid rgba(0,62,43,0.25);
  background: var(--bg); color: var(--text); font-size: 14px; font-family: var(--sans);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--text); }
.filters button {
  padding: 10px 18px; border-radius: 8px; border: none;
  background: var(--text); color: var(--card-1); font-weight: 700; cursor: pointer; font-size: 14px;
  font-family: var(--sans);
}
.filters button:hover { opacity: 0.9; }
.filters .clear { background: none; border: 1px solid var(--text); color: var(--text); font-weight: 600; }

.summary { display: flex; gap: 24px; margin: 18px 0 4px; font-size: 13px; }
.summary strong { font-family: var(--serif); font-weight: 400; font-size: 18px; display: block; }

/* --- Gráfico de tiempo de respuesta (dashboard) --- */
canvas { width: 100%; height: 140px; display: block; cursor: crosshair; }
.chart-wrap { position: relative; }
.chart-tooltip {
  position: absolute; pointer-events: none; opacity: 0; transition: opacity 0.1s;
  background: var(--text); color: var(--card-1); font-family: var(--sans);
  font-size: 12px; padding: 6px 10px; border-radius: 6px; white-space: nowrap;
  transform: translate(-50%, -100%); top: 0; left: 0; z-index: 2;
}
.chart-tooltip strong { display: block; font-size: 12.5px; }
.chart-tooltip span { opacity: 0.8; font-size: 11px; }

/* --- Tablas de historial --- */
table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 13px; }
.table-scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll-x table { min-width: 700px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid rgba(0,62,43,0.15); white-space: nowrap; }
th { color: var(--text); opacity: 0.7; font-weight: 600; font-size: 11px; text-transform: uppercase; }
.badge { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.badge.up { background: var(--up); }
.badge.down { background: var(--down); }
.err { color: var(--down); }
.empty { text-align: center; padding: 30px 0; opacity: 0.7; font-size: 14px; }
.manual-badge { display: inline-flex; align-items: center; gap: 3px; color: var(--text); opacity: 0.75; font-size: 12px; font-weight: 600; }
.manual-badge svg { width: 10px; height: 10px; flex-shrink: 0; }

/* --- Paginación (search) --- */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  margin-top: 18px; font-size: 13px; font-family: var(--sans);
}
.pagination a, .pagination span.disabled {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 14px; border-radius: 8px; font-weight: 600; text-decoration: none;
}
.pagination a { background: var(--card-1); color: var(--text); }
.pagination a:hover { opacity: 0.85; }
.pagination span.disabled { background: transparent; color: var(--muted); opacity: 0.5; }
.pagination .page-indicator { color: var(--muted); font-weight: 500; }

footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 30px; }

/* --- Página de configuración --- */
.save-banner {
  background: var(--card-1); color: var(--text); font-weight: 700; font-size: 14px;
  padding: 12px 16px; border-radius: 10px; margin-bottom: 20px;
}
.help-text { color: var(--muted); font-size: 13px; margin: -6px 0 16px; line-height: 1.5; }
.help-text code { background: rgba(0,62,43,0.08); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.settings-grid .field { width: 100%; }
.toggle-row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; margin-bottom: 16px; cursor: pointer; }
.toggle-row input { width: 16px; height: 16px; accent-color: var(--text); cursor: pointer; }
.test-btn {
  background: none; border: 1px solid var(--text); color: var(--text); border-radius: 8px;
  padding: 8px 14px; font-family: var(--sans); font-size: 13px; font-weight: 600; cursor: pointer;
}
.test-btn:hover { background: rgba(0,62,43,0.08); }
.test-btn:disabled { opacity: 0.6; cursor: default; }
.test-result { margin-left: 10px; font-size: 13px; font-weight: 600; }
.test-result.ok { color: var(--up); }
.test-result.fail { color: var(--down); }
.btn-save {
  display: block; width: 100%; padding: 13px; border-radius: 10px; border: none;
  background: var(--text); color: var(--card-1); font-weight: 700; cursor: pointer; font-size: 15px;
  font-family: var(--sans); margin-top: 4px;
}
.btn-save:hover { opacity: 0.9; }

/* ============================================================
   Página de login — reglas con selector de etiqueta genérico
   (input, button, label, h1) van SIEMPRE bajo .auth-page para
   no filtrarse a los formularios de dashboard/search.
   ============================================================ */
body.auth-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.auth-page .auth-shell { width: 100%; max-width: 320px; position: relative; z-index: 1; min-height: 1px; }
.auth-page .card { background: var(--card-1); border-radius: 14px; padding: 36px; width: 100%; max-width: 320px; box-shadow: 0 0 50px rgba(187,210,87,0.25); }

/* --- Portal de partículas --- */
#portalCanvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.portal-orb-wrap {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1;
}
.portal-orb {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 132px; height: 132px; border: none; background: none; padding: 0; cursor: pointer;
  filter: drop-shadow(0 0 26px rgba(187,210,87,0.75)) drop-shadow(0 0 60px rgba(187,210,87,0.35));
  animation: portalPulse 2.8s ease-in-out infinite;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.portal-orb .orb-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.portal-orb:hover { transform: scale(1.05); }
.portal-orb.hidden { opacity: 0; transform: scale(0.6); pointer-events: none; }
@keyframes portalPulse {
  0%, 100% { filter: drop-shadow(0 0 26px rgba(187,210,87,0.75)) drop-shadow(0 0 60px rgba(187,210,87,0.35)); }
  50%      { filter: drop-shadow(0 0 38px rgba(187,210,87,0.95)) drop-shadow(0 0 85px rgba(187,210,87,0.5)); }
}
.portal-hint {
  position: relative; z-index: 1;
  font-family: var(--sans); font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text); opacity: 0.8; line-height: 1.35; text-align: center;
  pointer-events: none;
}
.auth-content {
  opacity: 0; transform: scale(0.85) translateY(6px); pointer-events: none;
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(.2,.8,.2,1);
}
.auth-content.visible { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
.auth-page h1 { font-family: var(--serif); font-weight: 400; color: var(--text); font-size: 24px; margin: 0 0 24px; text-align: center; }
.auth-page label { display: block; color: var(--text); opacity: 0.75; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.auth-page input {
  width: 100%; padding: 10px 12px; margin-bottom: 16px; border-radius: 8px;
  border: 1px solid rgba(0,62,43,0.25); background: var(--bg); color: var(--text); font-size: 14px;
  font-family: var(--sans); box-sizing: border-box;
}
.auth-page input:focus { outline: none; border-color: var(--text); }
.auth-page .password-wrap { position: relative; margin-bottom: 16px; }
.auth-page .password-wrap input { padding-right: 40px; margin-bottom: 0; }
.auth-page .toggle-password {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; background: none; border: none; padding: 0; margin: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text); opacity: 0.6;
}
.auth-page .toggle-password:hover { opacity: 1; }
.auth-page .toggle-password svg { width: 18px; height: 18px; }
.auth-page .toggle-password .eye-off { display: none; }
.auth-page .btn-primary {
  width: 100%; padding: 11px; border-radius: 8px; border: none;
  background: var(--text); color: var(--card-1); font-weight: 700; cursor: pointer; font-size: 14px;
  font-family: var(--sans);
}
.auth-page .btn-primary:hover { opacity: 0.9; }
.top-logo {
  position: fixed; top: calc(50% - 235px); left: 0; right: 0;
  z-index: 2; display: flex; justify-content: center; align-items: center;
  pointer-events: none;
}
.top-logo img { height: 38px; display: block; }
@media (max-height: 620px) {
  .top-logo { top: 24px; }
}
@media (max-width: 480px) {
  .auth-page .auth-shell { max-width: 300px; }
  .auth-page .card { padding: 28px 24px; }
  .top-logo { top: calc(50% - 205px); }
  .top-logo img { height: 34px; }
}
.auth-page .error { color: var(--down); font-size: 13px; margin-bottom: 16px; text-align: center; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
  body.app-page { padding: 20px 14px 40px; }
  .wrap { max-width: 100%; }
  header { gap: 8px; }
  .logo { height: 24px; }
  .url { font-size: 12px; gap: 8px; }
  .nav-links { font-size: 12px; }

  .status-card { padding: 18px; gap: 14px; }
  .status-info { gap: 12px; width: 100%; }
  .status-text { font-size: 21px; }
  .status-sub { font-size: 12px; }
  .status-actions { width: 100%; justify-content: stretch; }
  .verify-btn, .refresh-btn { flex: 1 1 auto; justify-content: center; padding: 9px 10px; font-size: 12px; }

  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { padding: 14px; }
  .metric .value { font-size: 24px; }

  .panel { padding: 16px; }
  .panel h2 { font-size: 17px; }
  .see-all { display: block; margin-top: 4px; }

  canvas { height: 110px; }

  form.filters { flex-direction: column; align-items: stretch; gap: 10px; }
  .field { width: 100%; }
  .field input, .field select { width: 100%; }
  .filters button { width: 100%; }
  .summary { gap: 16px; flex-wrap: wrap; }

  table { font-size: 12px; }
  th, td { padding: 7px 8px; }

  .settings-grid { grid-template-columns: 1fr; }
  .test-result { display: block; margin-left: 0; margin-top: 6px; }
}

@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
  .status-info { flex-wrap: wrap; }
}
