/* ═══════════════════════════════════════════════════════════════
   dark.css — WhatsApp Master Portal · Dark Theme
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --bg-page:      #0f1117;
  --bg-card:      #161b27;
  --bg-input:     #1a2133;
  --bg-hover:     #1e2840;
  --border:       #1e2535;
  --border-focus: #25d366;

  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:     #4a5568;

  --green:   #25d366;
  --green-dim: rgba(37, 211, 102, 0.12);
  --blue:    #63b3ed;
  --blue-dim:  rgba(99, 179, 237, 0.12);
  --orange:  #f6ad55;
  --orange-dim: rgba(246, 173, 85, 0.12);
  --red:     #fc8181;
  --red-dim:   rgba(252, 129, 129, 0.12);

  --header-h: 56px;
  --radius:   10px;
  --radius-sm: 6px;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Header ──────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.header-brand .brand-icon {
  width: 32px;
  height: 32px;
  background: var(--green);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.header-brand .brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.2px;
}

.header-brand .brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: -2px;
}

/* Nav links */
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--green-dim);
  color: var(--green);
}

/* Online badge */
.badge-online {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--green-dim);
  color: var(--green);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-online::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.7); }
}

/* Avatar */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #25d366, #128c7e);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.avatar-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.avatar-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* Salir button */
.btn-salir {
  padding: 6px 14px;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(252, 129, 129, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

.btn-salir:hover {
  background: rgba(252, 129, 129, 0.2);
}

/* ── Page layout ─────────────────────────────────────────────── */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ── Stat cards ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card .stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}

.stat-card .stat-value {
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
}

.stat-card .stat-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-green  .stat-value { color: var(--green); }
.stat-blue   .stat-value { color: var(--blue); }
.stat-orange .stat-value { color: var(--orange); }
.stat-red    .stat-value { color: var(--red); }

/* ── Section box ─────────────────────────────────────────────── */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

.section-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--bg-hover); }

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 48px;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-green   { background: var(--green-dim);  color: var(--green); }
.badge-blue    { background: var(--blue-dim);   color: var(--blue); }
.badge-orange  { background: var(--orange-dim); color: var(--orange); }
.badge-red     { background: var(--red-dim);    color: var(--red); }
.badge-gray    { background: rgba(148,163,184,.1); color: var(--text-muted); }

/* ── Progress bar ────────────────────────────────────────────── */
.quota-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.quota-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--green);
  transition: width .3s;
}

.quota-fill.warn  { background: var(--orange); }
.quota-fill.full  { background: var(--red); }

.quota-text {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity .15s, transform .1s;
}

.btn:hover   { opacity: .85; }
.btn:active  { transform: scale(.97); }

.btn-green  { background: var(--green);  color: #0f1117; }
.btn-blue   { background: var(--blue);   color: #0f1117; }
.btn-orange { background: var(--orange); color: #0f1117; }
.btn-red    { background: var(--red);    color: #0f1117; }
.btn-ghost  { background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border); }

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 5px;
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.form-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color .15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-note {
  background: var(--blue-dim);
  border-left: 3px solid var(--blue);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--blue);
  margin: 12px 0;
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border-left: 3px solid;
}

.alert-success { background: var(--green-dim);  border-color: var(--green);  color: var(--green); }
.alert-error   { background: var(--red-dim);    border-color: var(--red);    color: var(--red); }
.alert-warning { background: var(--orange-dim); border-color: var(--orange); color: var(--orange); }

/* ── Modal ───────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active { display: flex; }

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 2px;
  transition: color .15s;
}

.modal-close:hover { color: var(--text-primary); }

/* ── Progress (creation) ─────────────────────────────────────── */
.creation-progress {
  display: none;
  margin: 16px 0;
}

.creation-progress.active { display: block; }

.progress-track {
  background: var(--border);
  border-radius: 6px;
  height: 24px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #128c7e);
  width: 0%;
  transition: width .3s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #0f1117;
}

/* ── Toast ───────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: #0f1117;
  z-index: 9999;
  display: none;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}

#toast.show          { display: block; }
#toast.toast-success { background: var(--green); }
#toast.toast-error   { background: var(--red); color: white; }

/* ── Mono IP ─────────────────────────────────────────────────── */
.ip-mono {
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-dim);
  padding: 2px 7px;
  border-radius: 4px;
}

.tag-fixed {
  font-size: 10px;
  background: var(--orange-dim);
  color: var(--orange);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* ── Log entry ───────────────────────────────────────────────── */
.log-entry {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 13px;
}

.log-entry:last-child { border-bottom: none; }

.log-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 140px;
  font-family: 'SF Mono', 'Courier New', monospace;
}

.log-detail { color: var(--text-secondary); flex: 1; }

/* ── Add-form row ────────────────────────────────────────────── */
.add-form {
  padding: 18px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.add-form .field { display: flex; flex-direction: column; gap: 5px; }

.add-form label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
}

.add-form input {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  width: 210px;
  transition: border-color .15s;
}

.add-form input:focus {
  outline: none;
  border-color: var(--green);
}

.add-form input::placeholder { color: var(--text-muted); }

/* ── Utility ─────────────────────────────────────────────────── */
.text-green  { color: var(--green); }
.text-blue   { color: var(--blue); }
.text-orange { color: var(--orange); }
.text-red    { color: var(--red); }
.text-muted  { color: var(--text-muted); }

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.mt-4        { margin-top: 4px; }
.mb-0        { margin-bottom: 0 !important; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-nav { display: none; }
  .form-row   { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .container  { padding: 16px; }
}
