/*
 * Sistema de diseño — Joystickdemar CRM
 * Paleta y tipografía derivadas de joystickdemar.com (navy + neón arcade).
 */

:root {
  --bg: #071828;
  --surface: #0a1f38;
  --surface-2: #0d2648;
  --elevated: #0f2a40;
  --border: #1a3a5c;
  --border-strong: #28425a;

  --text: #f2f7fc;
  --text-muted: #7fa0c4;
  --text-faint: #4d6c8c;

  --cyan: #00c8ff;
  --cyan-bright: #00e5ff;
  --gold: #ffc840;
  --gold-bright: #ffe033;
  --magenta: #ff2daa;
  --red: #ff3333;
  --green: #44dd77;
  --whatsapp: #25d366;

  --font-display: "Press Start 2P", monospace;
  --font-heading: "Rajdhani", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-glow: 0 0 0 1px var(--border), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(0, 200, 255, 0.08), transparent),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(255, 45, 170, 0.06), transparent);
  background-attachment: fixed;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 0.5em;
  color: var(--text);
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

a { color: var(--cyan-bright); text-decoration: none; }
a:hover { color: var(--gold-bright); }

p { margin: 0 0 1em; }

small, .text-muted { color: var(--text-muted); }

code, .mono { font-family: "SFMono-Regular", Menlo, monospace; }

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: block;
  font-family: var(--font-display);
  font-size: 0.62rem;
  line-height: 1.6;
  color: var(--cyan-bright);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
  padding: 8px 10px 20px;
  letter-spacing: 0.02em;
}

.sidebar__brand span { color: var(--gold-bright); }

.nav-group {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
  border: 1px solid transparent;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-link.active {
  color: var(--cyan-bright);
  background: rgba(0, 200, 255, 0.08);
  border-color: rgba(0, 200, 255, 0.25);
}

.nav-link .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

.sidebar__footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.user-chip__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  color: #051220;
  flex-shrink: 0;
}

.user-chip__meta { min-width: 0; }
.user-chip__name { font-weight: 600; font-size: 0.9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip__role { font-size: 0.76rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.w-full { width: 100%; }

.btn-signout {
  display: block;
  margin-top: 10px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-faint);
  padding: 6px;
  border-radius: var(--radius-sm);
}
.btn-signout:hover { color: var(--red); background: rgba(255, 51, 51, 0.08); }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 60px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header__title p { margin: 4px 0 0; color: var(--text-muted); }

/* ---------- Flash ---------- */

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-weight: 500;
  border: 1px solid transparent;
}

.flash--notice { background: rgba(68, 221, 119, 0.1); border-color: rgba(68, 221, 119, 0.3); color: #8ff2b6; }
.flash--alert  { background: rgba(255, 51, 51, 0.1); border-color: rgba(255, 51, 51, 0.35); color: #ff9a9a; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease, background 0.12s ease;
}

.btn:hover { border-color: var(--cyan); color: var(--cyan-bright); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #051220;
}
.btn-primary:hover { background: var(--cyan-bright); border-color: var(--cyan-bright); color: #051220; }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.btn-danger { background: transparent; border-color: rgba(255, 51, 51, 0.4); color: #ff9a9a; }
.btn-danger:hover { background: rgba(255, 51, 51, 0.12); border-color: var(--red); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 0.82rem; }

.btn-whatsapp { background: var(--whatsapp); border-color: var(--whatsapp); color: #06210f; }
.btn-whatsapp:hover { filter: brightness(1.08); color: #06210f; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card + .card { margin-top: 0; }

.card__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.grid {
  display: grid;
  gap: 20px;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ---------- Stat tiles ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
}

.stat-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, var(--accent, var(--cyan)) 0%, transparent 55%);
  opacity: 0.06;
}

.stat-tile__label {
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stat-tile__value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--accent, var(--cyan-bright));
  text-shadow: 0 0 16px color-mix(in srgb, var(--accent, var(--cyan-bright)) 55%, transparent);
}

.stat-tile__hint { margin-top: 8px; font-size: 0.8rem; color: var(--text-faint); }

/* ---------- Table ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

table.data-table { width: 100%; border-collapse: collapse; background: var(--surface); }

.data-table th {
  text-align: left;
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(0, 200, 255, 0.04); }

.data-table tfoot td { background: var(--surface-2); border-bottom: none; border-top: 2px solid var(--border-strong); }

.data-table .row-link { color: var(--text); font-weight: 600; }
.data-table .row-link:hover { color: var(--cyan-bright); }

.actions-cell { text-align: right; white-space: nowrap; }
.actions-cell .btn { margin-left: 6px; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state__code {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--gold-bright);
  display: block;
  margin-bottom: 14px;
  letter-spacing: 0.04em;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  background: var(--surface-2);
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--cyan   { color: var(--cyan-bright);   border-color: rgba(0, 200, 255, 0.4);   background: rgba(0, 200, 255, 0.1); }
.badge--gold   { color: var(--gold-bright);   border-color: rgba(255, 200, 64, 0.4);  background: rgba(255, 200, 64, 0.1); }
.badge--magenta{ color: var(--magenta);       border-color: rgba(255, 45, 170, 0.4);  background: rgba(255, 45, 170, 0.1); }
.badge--green  { color: var(--green);         border-color: rgba(68, 221, 119, 0.4);  background: rgba(68, 221, 119, 0.1); }
.badge--red    { color: #ff9a9a;              border-color: rgba(255, 51, 51, 0.4);   background: rgba(255, 51, 51, 0.1); }
.badge--muted  { color: var(--text-faint);    border-color: var(--border);            background: transparent; }

/* ---------- Filters / tabs ---------- */

.filter-tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }

.filter-tabs a {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.filter-tabs a:hover { color: var(--text); border-color: var(--text-muted); }
.filter-tabs a.active { color: #051220; background: var(--cyan-bright); border-color: var(--cyan-bright); }

/* ---------- Forms ---------- */

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="password"],
.field input[type="date"],
.field input[type="datetime-local"],
.field select,
.field textarea {
  width: 100%;
  background: var(--elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
}

.field textarea { resize: vertical; min-height: 90px; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 200, 255, 0.18);
}

.field-hint { font-size: 0.78rem; color: var(--text-faint); margin-top: 4px; }

.field-error { font-size: 0.8rem; color: #ff9a9a; margin-top: 4px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }

.error-summary {
  background: rgba(255, 51, 51, 0.08);
  border: 1px solid rgba(255, 51, 51, 0.35);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 18px;
  color: #ff9a9a;
}
.error-summary strong { display: block; margin-bottom: 6px; color: #fff; }
.error-summary ul { margin: 0; padding-left: 18px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ---------- Inline lists ---------- */

.list-clean { list-style: none; margin: 0; padding: 0; }

.list-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.list-item:last-child { border-bottom: none; }

.list-item__meta { font-size: 0.8rem; color: var(--text-faint); margin-top: 2px; }

/* ---------- Auth pages (Devise) ---------- */

.auth-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  isolation: isolate;
}

.auth-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 200, 255, 0.035) 0px,
    rgba(0, 200, 255, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
}

.arcade-deco {
  --rot: 0deg;
  position: fixed;
  z-index: -1;
  pointer-events: none;
  opacity: 0.16;
  filter: drop-shadow(0 0 22px currentColor);
  transform: rotate(var(--rot));
  animation: arcade-float 8s ease-in-out infinite;
}

.arcade-deco svg { display: block; width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

@keyframes arcade-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -16px; }
}

@media (max-width: 760px) {
  .arcade-deco { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .arcade-deco { animation: none; }
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: var(--shadow-glow), 0 0 60px rgba(0, 200, 255, 0.05);
}

.auth-card__brand {
  font-family: var(--font-display);
  font-size: 0.8rem;
  line-height: 1.8;
  color: var(--cyan-bright);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
  text-align: center;
  margin-bottom: 22px;
  letter-spacing: 0.02em;
}

.auth-card__brand span { color: var(--gold-bright); }

.auth-card__title {
  font-size: 1.2rem;
  text-align: center;
  margin-bottom: 24px;
  color: var(--text);
}

.auth-card .field:last-of-type { margin-bottom: 18px; }

.field--checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.field--checkbox input { width: auto; }

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

.auth-links { margin-top: 20px; text-align: center; font-size: 0.85rem; color: var(--text-muted); }
.auth-links a { display: block; margin-top: 8px; }
.auth-links button { display: block; margin: 8px auto 0; }

.auth-card__coin {
  margin-top: 26px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  opacity: 0.85;
  animation: coin-blink 1.6s steps(1) infinite;
}

@keyframes coin-blink {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card__coin { animation: none; }
}
