/* ============================================================
   WhatsApp Scheduler — Design System
   Paleta: verde WhatsApp #25D366 + oscuro #111B21
   ============================================================ */

:root {
  --color-bg:        #111B21;
  --color-surface:   #1F2C34;
  --color-surface2:  #2A3942;
  --color-border:    #374045;
  --color-green:     #25D366;
  --color-green-dk:  #1DA851;
  --color-text:      #E9EDEF;
  --color-muted:     #8696A0;
  --color-danger:    #F15C6D;
  --color-warning:   #FFBF00;
  --color-info:      #53BDEB;
  --radius-sm:       8px;
  --radius-md:       12px;
  --radius-lg:       20px;
  --shadow:          0 4px 24px rgba(0,0,0,.45);
  --font:            'Inter', system-ui, sans-serif;
  --transition:      .18s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-green); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 72px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  gap: 8px;
  flex-shrink: 0;
}
.sidebar .logo {
  width: 42px;
  height: 42px;
  background: var(--color-green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.sidebar .logo svg { width: 24px; height: 24px; fill: #fff; }
.nav-btn {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.nav-btn:hover, .nav-btn.active {
  background: var(--color-surface2);
  color: var(--color-green);
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn .tooltip {
  position: absolute;
  left: 56px;
  background: var(--color-surface2);
  color: var(--color-text);
  font-size: .78rem;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  border: 1px solid var(--color-border);
}
.nav-btn:hover .tooltip { opacity: 1; }

/* Main area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  height: 60px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 12px;
  flex-shrink: 0;
}
.topbar h1 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
}
.topbar .spacer { flex: 1; }

/* Pages */
.page {
  flex: 1;
  overflow-y: auto;
  padding: 32px 28px;
  display: none;
}
.page.active { display: block; }

/* ============================================================
   COMPONENTS
   ============================================================ */

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: .85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-muted);
  margin-bottom: 16px;
}

/* Status badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}
.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge-green  { color: var(--color-green);  background: rgba(37,211,102,.12); }
.badge-orange { color: var(--color-warning); background: rgba(255,191,0,.12); }
.badge-red    { color: var(--color-danger);  background: rgba(241,92,109,.12); }
.badge-muted  { color: var(--color-muted);   background: var(--color-surface2); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), opacity var(--transition);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--color-green); color: #000; }
.btn-primary:hover:not(:disabled) { background: var(--color-green-dk); }
.btn-secondary {
  background: var(--color-surface2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-border); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #d14156; }
.btn-sm { padding: 6px 14px; font-size: .82rem; }

/* Form */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-control {
  width: 100%;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--color-text);
  font-size: .92rem;
  outline: none;
  transition: border-color var(--transition);
}
.form-control:focus { border-color: var(--color-green); }
.form-control::placeholder { color: var(--color-muted); }
textarea.form-control { resize: vertical; min-height: 96px; }
select.form-control option { background: var(--color-surface2); }

/* Table */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
thead th {
  background: var(--color-surface2);
  padding: 10px 14px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-muted);
}
tbody td {
  padding: 12px 14px;
  border-top: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}
tbody tr:hover td { background: rgba(255,255,255,.03); }
.text-mono { font-family: 'SFMono-Regular', Consolas, monospace; font-size: .8rem; }
.text-muted { color: var(--color-muted); }
.text-green { color: var(--color-green); }

/* QR container */
.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
}
.qr-wrap img {
  width: 260px;
  height: 260px;
  border-radius: var(--radius-sm);
  border: 4px solid var(--color-surface2);
}
.qr-timer {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-warning);
  font-variant-numeric: tabular-nums;
}
.qr-instructions {
  text-align: center;
  color: var(--color-muted);
  font-size: .88rem;
  max-width: 280px;
  line-height: 1.55;
}

/* Alert / Toast */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: rgba(37,211,102,.12); border-left: 3px solid var(--color-green); }
.alert-error   { background: rgba(241,92,109,.12);  border-left: 3px solid var(--color-danger); }
.alert-info    { background: rgba(83,189,235,.12);   border-left: 3px solid var(--color-info); }

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: .88rem; }

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}
.stat-label {
  font-size: .75rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 4px;
}

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-logo .icon {
  width: 48px;
  height: 48px;
  background: var(--color-green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-logo .icon svg { width: 26px; height: 26px; fill: #fff; }
.login-logo h2 { font-size: 1.25rem; font-weight: 700; }
.login-logo p { font-size: .8rem; color: var(--color-muted); }

/* Radio options (tipo destino) */
.radio-opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface2);
  cursor: pointer;
  font-size: .88rem;
  font-weight: 500;
  color: var(--color-muted);
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  user-select: none;
}
.radio-opt input[type="radio"] { display: none; }
.radio-opt.active, .radio-opt:has(input:checked) {
  border-color: var(--color-green);
  color: var(--color-green);
  background: rgba(37,211,102,.08);
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: center;
}
.upload-zone:hover {
  border-color: var(--color-green);
  background: rgba(37,211,102,.04);
}
.upload-zone.dragover {
  border-color: var(--color-green);
  background: rgba(37,211,102,.08);
}
.upload-preview-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
#upload-icon { font-size: 2rem; }

/* Badge info */
.badge-info { color: var(--color-info); background: rgba(83,189,235,.12); }

/* Activity chart */
.chart-wrap {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  width: 100%;
  padding-top: 8px;
}
.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  height: 100%;
}
.chart-stacked {
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  width: 100%;
  flex: 1;
  min-height: 2px;
}
.chart-bar {
  width: 100%;
  min-height: 2px;
  transition: height .3s;
}
.chart-bar-enviado { background: var(--color-green, #25d366); border-radius: 2px 2px 0 0; }
.chart-bar-fallido  { background: var(--color-danger, #ef4444); }
.chart-bar-enviado:only-child { border-radius: 2px 2px 0 0; }
.chart-label {
  font-size: .6rem;
  color: var(--color-muted);
  text-align: center;
  white-space: nowrap;
  margin-top: 4px;
  line-height: 1;
}
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  font-size: .85rem;
  height: 100px;
  width: 100%;
}

/* Dashboard mini list */
.dash-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: .83rem;
}
.dash-list-item:last-child { border-bottom: none; }
.dash-list-dest {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-list-fecha {
  font-size: .74rem;
  color: var(--color-muted);
  white-space: nowrap;
}

/* hist-rango active */
.hist-rango.active {
  background: var(--color-green);
  color: #000;
  border-color: var(--color-green);
}

/* Responsive */
@media (max-width: 640px) {
  .sidebar { width: 56px; }
  .page { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
}

/* Grabación de audio/video */
@keyframes grabPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.85); }
}

/* Combo buscable de grupos */
.grupo-opt {
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background .15s;
}
.grupo-opt:last-child { border-bottom: none; }
.grupo-opt:hover, .grupo-opt.selected { background: rgba(37,211,102,.12); }
