/* ═══════════════════════════════════════════════════════════════════
   WalliCall Panel — Design System v3
   Fuentes : Sora (display) · Nunito Sans (body)
   Paleta  : idéntica al landing v4
   Filosofía: sala de control, no SaaS genérico
═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=Nunito+Sans:wght@300;400;600;700&display=swap');

/* ─────────────────────── TOKENS ─────────────────────── */
:root {
  --ink:     #07070e;
  --bg:      #0b0a16;
  --surface: #100f1e;
  --card:    #131225;
  --card2:   #18172e;
  --lift:    #1d1c38;

  --bd:  rgba(139,127,255,0.09);
  --bd2: rgba(139,127,255,0.18);
  --bd3: rgba(139,127,255,0.32);

  --p600: #3d35a0;
  --p500: #5848d0;
  --p400: #7a70e8;
  --p300: #a09aff;
  --p200: #c5c0ff;
  --p100: #edeaff;

  --t1: #f0f1f8;
  --t2: #b4b9d4;
  --t3: #6e7490;
  --t4: #3d4158;

  --acc:  #8b7fff;
  --acc2: #a397ff;
  --slv:  #c8cce0;
  --slvd: #868aaa;

  --go:    #22c98a;
  --go2:   rgba(34,201,138,0.12);
  --go3:   rgba(34,201,138,0.22);
  --warn:  #c8a820;
  --warn2: rgba(200,168,32,0.12);
  --warn3: rgba(200,168,32,0.22);
  --err:   #f07080;
  --err2:  rgba(240,112,128,0.10);
  --err3:  rgba(240,112,128,0.22);

  --ts-xs:   11px;
  --ts-sm:   12px;
  --ts-md:   13.5px;
  --ts-base: 14px;
  --ts-lg:   16px;
  --ts-xl:   20px;
  --ts-2xl:  24px;
  --ts-3xl:  28px;

  --ff-display: 'Sora', sans-serif;
  --ff-body:    'Nunito Sans', sans-serif;
  --ff-mono:    'Fira Code', 'Cascadia Code', 'Courier New', monospace;

  --r1: 5px;
  --r2: 8px;
  --r3: 12px;
  --r4: 16px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─────────────────────── RESET ─────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--t1);
  font-family: var(--ff-body);
  font-size: var(--ts-base);
  font-weight: 400;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

body::after {
  content: '';
  position: fixed; inset: 0; z-index: 9999;
  pointer-events: none;
  opacity: 0.016;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--p600); border-radius: 2px; }

a { color: var(--p300); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--acc2); }

/* ─────────────────────── LAYOUT ─────────────────────── */
.layout { display: flex; flex-direction: column; min-height: 100vh; }
.layout__body { display: flex; flex: 1; min-height: 0; height: calc(100vh - 56px); }

/* ─────────────────────── TOPBAR ─────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px;
  padding: 0 1.5rem;
  background: rgba(11,10,22,0.92);
  backdrop-filter: blur(24px) saturate(1.5);
  border-bottom: 1px solid var(--bd);
  position: relative;
}

.topbar::after {
  content: '';
  position: absolute; inset: auto 0 0 0; height: 1px;
  background: linear-gradient(90deg, transparent 10%, var(--p600) 50%, transparent 90%);
  opacity: 0.4;
  pointer-events: none;
}

.topbar__brand {
  font-family: var(--ff-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar__brand strong { color: var(--acc); font-weight: 800; }

.topbar__user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: var(--ts-sm);
  color: var(--t3);
}

/* ─────────────────────── SIDEBAR ─────────────────────── */
.sidebar {
  position: relative;
  width: 196px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::after {
  content: '';
  position: absolute; top: 0; right: 0; bottom: 0; width: 1px;
  background: linear-gradient(180deg, transparent 0%, var(--p600) 50%, transparent 100%);
  opacity: 0.2;
  pointer-events: none;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.7rem;
  gap: 1px;
  flex: 1;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.7rem;
  border-radius: var(--r2);
  font-size: var(--ts-md);
  font-weight: 500;
  color: var(--t2);
  transition: background 0.12s var(--ease-out), color 0.12s;
  position: relative;
}

.sidebar nav a:hover {
  background: rgba(139,127,255,0.06);
  color: var(--t1);
}

.sidebar nav a.active {
  background: rgba(139,127,255,0.11);
  color: var(--p300);
}

.sidebar nav a.active::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px;
  background: linear-gradient(180deg, var(--p400), var(--p300));
  border-radius: 0 2px 2px 0;
}

/* ─────────────────────── CONTENT ─────────────────────── */
.content {
  flex: 1;
  min-width: 0;
  padding: 1.75rem 2rem;
  overflow-y: auto;
  background-image:
    linear-gradient(var(--bd) 1px, transparent 1px),
    linear-gradient(90deg, var(--bd) 1px, transparent 1px);
  background-size: 52px 52px;
}

/* ─────────────────────── TYPOGRAPHY ─────────────────────── */
h1 {
  font-family: var(--ff-display);
  font-size: var(--ts-3xl);
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.5px;
  line-height: 1.15;
  margin-bottom: 1.25rem;
}

h2 {
  font-family: var(--ff-display);
  font-size: var(--ts-xl);
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.2px;
  margin-bottom: 0.9rem;
}

h3 {
  font-family: var(--ff-display);
  font-size: var(--ts-lg);
  font-weight: 600;
  color: var(--t2);
  margin-bottom: 0.7rem;
}

p { color: var(--t2); line-height: 1.7; font-size: var(--ts-md); }
small { font-size: var(--ts-sm); color: var(--t3); }
.mono  { font-family: var(--ff-mono); font-size: 12.5px; letter-spacing: 0.3px; }
.muted { color: var(--t3); font-size: var(--ts-sm); }

/* ─────────────────────── PAGE HEADER ─────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.35rem;
  gap: 1rem;
}
.page-header h1 { margin-bottom: 0; }

/* ─────────────────────── CARDS ─────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--r4);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.1rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.18s var(--ease-out);
}

.card::before {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent 10%, rgba(139,127,255,0.14) 50%, transparent 90%);
  pointer-events: none;
}

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

/* ─────────────────────── GRID ─────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.1rem;
}

.grid--4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
  margin-bottom: 1.1rem;
}

/* ─────────────────────── STAT CARDS ─────────────────────── */
.stat {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--r3);
  padding: 0.9rem 1.1rem 1rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.18s, transform 0.18s var(--ease-out);
}

.stat:hover { border-color: var(--bd2); transform: translateY(-2px); }

.stat::after {
  content: '';
  position: absolute; inset: auto 0 0 0; height: 2px;
  background: linear-gradient(90deg, var(--p600), var(--p400));
  opacity: 0.45;
}
.stat:hover::after { opacity: 0.75; }
.stat--ok::after   { background: linear-gradient(90deg, #0e8a5a, var(--go)); }
.stat--warn::after { background: linear-gradient(90deg, #8a6e00, var(--warn)); }

.stat::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 0% 0%, rgba(88,72,208,0.05), transparent);
  pointer-events: none;
}

.stat__num {
  font-family: var(--ff-display);
  font-size: var(--ts-2xl);
  font-weight: 700;
  color: var(--t1);
  line-height: 1.1;
  margin-bottom: 0.25rem;
  letter-spacing: -0.5px;
}

.stat--ok   .stat__num { color: var(--go); }
.stat--warn .stat__num { color: var(--warn); }

.stat__lbl {
  font-size: var(--ts-xs);
  font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.3;
}

/* ─────────────────────── BADGES ─────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: var(--ts-xs);
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.badge--admin  { background: rgba(88,72,208,0.16); border: 1px solid rgba(139,127,255,0.28); color: var(--p300); }
.badge--client { background: var(--go2); border: 1px solid rgba(34,201,138,0.28); color: var(--go); }

/* ─────────────────────── TAGS ─────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: var(--ts-xs);
  font-weight: 600;
  white-space: nowrap;
}

.tag::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tag--ok       { background: var(--go2);  border: 1px solid rgba(34,201,138,0.22); color: var(--go); }
.tag--ok::before { background: var(--go); }
.tag--warn     { background: var(--warn2); border: 1px solid rgba(200,168,32,0.22); color: var(--warn); }
.tag--warn::before { background: var(--warn); }
.tag--active   { background: var(--go2);  border: 1px solid rgba(34,201,138,0.22); color: var(--go); }
.tag--active::before { background: var(--go); }
.tag--inactive { background: rgba(62,68,88,0.25); border: 1px solid rgba(62,68,88,0.4); color: var(--t3); }
.tag--inactive::before { background: var(--t4); }
.tag--cancelled { background: var(--err2); border: 1px solid rgba(240,112,128,0.22); color: var(--err); }
.tag--cancelled::before { background: var(--err); }

/* ─────────────────────── ALERTS ─────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-radius: var(--r2);
  font-size: var(--ts-md);
  font-weight: 500;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.alert--ok    { background: var(--go2);   border: 1px solid rgba(34,201,138,0.2);  color: #3ddfaa; }
.alert--error { background: var(--err2);  border: 1px solid rgba(240,112,128,0.2); color: var(--err); }
.alert--warn  { background: var(--warn2); border: 1px solid rgba(200,168,32,0.2);  color: var(--warn); }

/* ─────────────────────── BUTTONS ─────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0.48rem 1rem;
  border-radius: var(--r1);
  font-family: var(--ff-body);
  font-size: var(--ts-md);
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
  transition: opacity 0.15s, transform 0.12s var(--ease-out), box-shadow 0.15s;
}

.btn:hover  { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn--primary {
  background: linear-gradient(135deg, var(--p500), var(--p400));
  color: #fff;
  box-shadow: 0 1px 12px rgba(88,72,208,0.28);
}
.btn--primary:hover { opacity: 0.9; box-shadow: 0 3px 18px rgba(88,72,208,0.42); color: #fff; }

.btn--ghost {
  background: transparent;
  color: var(--slv);
  border: 1px solid rgba(200,204,224,0.12);
}
.btn--ghost:hover { background: rgba(200,204,224,0.05); border-color: rgba(200,204,224,0.24); color: var(--t1); }

.btn--ok    { background: var(--go2);  border: 1px solid rgba(34,201,138,0.25);    color: var(--go); }
.btn--ok:hover { background: var(--go3); color: var(--go); }
.btn--danger { background: var(--err2); border: 1px solid rgba(240,112,128,0.25); color: var(--err); }
.btn--danger:hover { background: var(--err3); color: var(--err); }
.btn--sm { padding: 0.3rem 0.65rem; font-size: var(--ts-sm); }

/* ─────────────────────── FORMS ─────────────────────── */
label {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  font-size: var(--ts-sm);
  font-weight: 600;
  color: var(--t3);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--bd2);
  border-radius: var(--r1);
  padding: 0.55rem 0.8rem;
  color: var(--t1);
  font-family: var(--ff-body);
  font-size: var(--ts-base);
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--p400);
  box-shadow: 0 0 0 3px rgba(122,112,232,0.12);
}

input::placeholder, textarea::placeholder { color: var(--t4); font-size: var(--ts-md); }

input[type="number"].input-inline {
  width: 82px; display: inline-block;
  padding: 0.3rem 0.5rem; font-size: var(--ts-sm);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bd);
}

/* ─────────────────────── TABLES ─────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r3);
  border: 1px solid var(--bd);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ts-md);
}

.table thead tr { background: var(--surface); }

.table th {
  padding: 0.58rem 0.9rem;
  text-align: left;
  font-size: var(--ts-xs);
  font-weight: 700;
  color: var(--t3);
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--bd2);
}

.table td {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--bd);
  color: var(--t1);
  vertical-align: middle;
}

.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: rgba(139,127,255,0.035); }
.table tbody tr:last-child td { border-bottom: none; }

.actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.inline  { display: inline; }

/* ─────────────────────── KV TABLE ─────────────────────── */
.kv { width: 100%; border-collapse: collapse; }

.kv th, .kv td {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--bd);
  text-align: left;
  vertical-align: top;
  font-size: var(--ts-md);
}

.kv th {
  width: 38%;
  font-size: var(--ts-sm);
  font-weight: 600;
  color: var(--t3);
  padding-right: 1rem;
}

.kv td { color: var(--t1); }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: none; }

/* ─────────────────────── DIVIDER ─────────────────────── */
.divider { height: 1px; background: var(--bd); margin: 1.1rem 0; }

/* ─────────────────────── LOGIN PAGE ─────────────────────── */
body.blank {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 55% at 50% 45%, rgba(88,72,208,0.09) 0%, transparent 65%),
    linear-gradient(var(--bd) 1px, transparent 1px),
    linear-gradient(90deg, var(--bd) 1px, transparent 1px);
  background-size: auto, 52px 52px, 52px 52px;
  padding: 1rem;
}

.login-wrap {
  width: 100%;
  max-width: 380px;
  animation: fadeUp 0.4s var(--ease-out) both;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1.5rem;
}

.login-logo img {
  width: 52px; height: 52px;
  border-radius: 13px;
  border: 1px solid var(--bd2);
  object-fit: cover;
}

.login-logotype {
  font-family: var(--ff-display);
  font-size: 21px;
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.3px;
}

.login-logotype em { color: var(--acc); font-style: normal; }

.login-card {
  background: var(--card);
  border: 1px solid var(--bd2);
  border-radius: var(--r4);
  padding: 1.75rem 1.65rem 1.5rem;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent 5%, var(--p500) 50%, transparent 95%);
  opacity: 0.5;
  pointer-events: none;
}

.login-card__sub {
  font-size: var(--ts-md);
  color: var(--t3);
  margin-bottom: 1.35rem;
}

.login-card label { margin-bottom: 0.8rem; }

.login-card .btn--primary {
  width: 100%;
  padding: 0.62rem;
  font-size: var(--ts-base);
  margin-top: 0.3rem;
}

/* ─────────────────────── SIP CREDENTIALS ─────────────────────── */
.sip-value {
  font-family: var(--ff-mono);
  background: var(--surface);
  border: 1px solid var(--bd2);
  border-radius: var(--r1);
  padding: 0.42rem 0.8rem;
  color: var(--p300);
  font-size: 12.5px;
  letter-spacing: 0.5px;
  display: inline-block;
}

/* ─────────────────────── ANIMATIONS ─────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ─────────────────────── RESPONSIVE ─────────────────────── */
@media (max-width: 900px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { padding: 1rem 0.9rem; }
  .topbar  { padding: 0 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .row { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
}
