/* =========================================================
   CallDesk · Gestor de llamadas móvil
   Diseño: dark glass premium, mobile-first, textos grandes
   ========================================================= */

:root {
  --bg: #0b1020;
  --bg-2: #101731;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);

  --text: #f3f5fb;
  --text-2: #b6bdd3;
  --text-3: #7d86a5;

  --primary: #5b7cfa;
  --primary-2: #8a5cf6;
  --success: #22c55e;
  --success-2: #16a34a;
  --danger: #f43f5e;
  --danger-2: #e11d48;
  --warn: #f59e0b;
  --wa: #25d366;
  --wa-2: #128c7e;

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 8px 28px rgba(91, 124, 250, 0.35);

  --font-head: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 74px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(1200px 700px at 10% -10%, #1a2352 0%, transparent 55%),
              radial-gradient(900px 600px at 110% 20%, #2b1a4f 0%, transparent 55%),
              linear-gradient(180deg, var(--bg) 0%, #070b17 100%);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }

/* ---------- fondo animado ---------- */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; animation: float 16s ease-in-out infinite; }
.orb-a { width: 320px; height: 320px; background: #3b5bfd; top: -120px; left: -100px; }
.orb-b { width: 280px; height: 280px; background: #8a5cf6; top: 40%; right: -140px; animation-delay: -5s; }
.orb-c { width: 260px; height: 260px; background: #14b8a6; bottom: -120px; left: 20%; animation-delay: -10s; opacity: .35; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-30px) } }

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 14px) 18px 14px;
  background: rgba(11, 16, 32, 0.72);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: var(--shadow-glow); font-size: 1.25rem;
}
.brand-text h1 { margin: 0; font-family: var(--font-head); font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; }
.brand-text p { margin: 0; font-size: .9rem; color: var(--text-3); }

.icon-btn {
  width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 1.15rem;
  transition: transform .15s, background .15s;
}
.icon-btn:active { transform: scale(.94); background: var(--border-strong); }
.icon-btn-sm { width: 42px; height: 42px; border-radius: 13px; }

/* ---------- main / views ---------- */
.app-main { padding: 14px 16px calc(var(--nav-h) + var(--safe-bottom) + 24px); max-width: 640px; margin: 0 auto; }
.view { display: none; animation: fadeUp .25s ease; }
.view-active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

.view-title-row { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 14px; }
.view-title-row h2 { margin: 0; font-family: var(--font-head); font-size: 1.6rem; font-weight: 800; }

/* ---------- stats ---------- */
.stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 6px; text-align: center; display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font-family: var(--font-head); font-size: 1.55rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .74rem; color: var(--text-3); font-weight: 500; }
.stat-ok .stat-num { color: var(--success); }
.stat-bad .stat-num { color: var(--danger); }
.stat-wait .stat-num { color: var(--warn); }

.progress-wrap { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; padding: 0 2px; }
.progress-bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.progress-text { font-size: .9rem; color: var(--text-2); }

/* ---------- búsqueda / filtros ---------- */
.search-row { margin-bottom: 10px; }
.search-box {
  display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 54px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.search-box i { color: var(--text-3); }
.search-box input { flex: 1; background: none; border: 0; outline: 0; height: 100%; font-size: 1.05rem; }
.search-box input::placeholder { color: var(--text-3); }

.filter-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 10px 16px; border-radius: 99px; font-size: .95rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  transition: all .15s;
}
.chip:active { transform: scale(.96); }
.chip-active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; box-shadow: var(--shadow-glow); }

/* ---------- tarjetas de contacto ---------- */
.contact-list { display: flex; flex-direction: column; gap: 14px; }

.contact-card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 16px 14px; box-shadow: var(--shadow);
  animation: fadeUp .3s ease both;
}
.contact-card::before {
  content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 4px; border-radius: 0 4px 4px 0;
  background: var(--text-3); opacity: .5;
}
.contact-card[data-status="contesto"]::before { background: var(--success); opacity: 1; }
.contact-card[data-status="no_contesto"]::before { background: var(--danger); opacity: 1; }

.card-top { display: flex; align-items: center; gap: 12px; }
.avatar {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; color: #fff;
}
.card-info { flex: 1; min-width: 0; }
.card-name { margin: 0; font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; line-height: 1.25; word-break: break-word; }
.card-phone { margin: 3px 0 0; font-size: 1rem; color: var(--text-2); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; }
.badge-pendiente { background: rgba(245,158,11,.14); color: #fbbf24; }
.badge-contesto { background: rgba(34,197,94,.14); color: #4ade80; }
.badge-no_contesto { background: rgba(244,63,94,.14); color: #fb7185; }
.badge-time { background: var(--surface-2); color: var(--text-2); font-weight: 500; }
.badge-note { background: rgba(138,92,246,.16); color: #c4b5fd; }

.card-more { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: var(--text-3); font-size: 1.1rem; }
.card-more:active { background: var(--surface-2); }

/* botón principal de llamada */
.call-btn {
  margin-top: 14px; width: 100%; height: 62px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #fff; font-family: var(--font-head); font-size: 1.2rem; font-weight: 800;
  box-shadow: 0 10px 26px rgba(34,197,94,.35); text-decoration: none;
  transition: transform .12s, filter .12s;
}
.call-btn i { font-size: 1.35rem; }
.call-btn:active { transform: scale(.98); filter: brightness(1.08); }

/* fila de resultado */
.outcome-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.outcome-btn {
  height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 700; font-size: 1.02rem; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-2); transition: all .15s;
}
.outcome-btn i { font-size: 1.15rem; }
.outcome-btn:active { transform: scale(.97); }
.outcome-btn.is-active.outcome-yes { background: rgba(34,197,94,.18); border-color: var(--success); color: #4ade80; }
.outcome-btn.is-active.outcome-no { background: rgba(244,63,94,.18); border-color: var(--danger); color: #fb7185; }
.outcome-yes:not(.is-active):hover { border-color: rgba(34,197,94,.5); }
.outcome-no:not(.is-active):hover { border-color: rgba(244,63,94,.5); }

/* fila secundaria: voz + whatsapp */
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.action-btn {
  height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 700; font-size: 1rem; border: 1.5px solid transparent; color: #fff; transition: transform .12s;
}
.action-btn:active { transform: scale(.97); }
.action-btn i { font-size: 1.2rem; }
.action-voice { background: linear-gradient(135deg, #7c3aed, #5b7cfa); box-shadow: 0 8px 22px rgba(124,58,237,.3); }
.action-wa { background: linear-gradient(135deg, #25d366, #128c7e); box-shadow: 0 8px 22px rgba(37,211,102,.3); }

/* transcripción resumida en la tarjeta */
.card-transcript {
  margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(138,92,246,.10);
  border: 1px dashed rgba(196,181,253,.35); font-size: .98rem; color: #ddd6fe; line-height: 1.4;
}
.card-transcript i { margin-right: 8px; color: #c4b5fd; }

/* ---------- empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty-state i { font-size: 3.2rem; color: var(--text-3); margin-bottom: 14px; }
.empty-state h3 { margin: 0 0 6px; font-family: var(--font-head); font-size: 1.3rem; color: var(--text); }
.empty-state p { margin: 0; font-size: 1rem; }

/* ---------- historial ---------- */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-day { margin: 14px 2px 4px; font-size: .9rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.history-item {
  display: flex; gap: 12px; padding: 14px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--border);
}
.history-icon { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 1.15rem; color: #fff; }
.history-icon.t-llamada { background: linear-gradient(135deg,#22c55e,#16a34a); }
.history-icon.t-llamada.o-no_contesto { background: linear-gradient(135deg,#f43f5e,#e11d48); }
.history-icon.t-whatsapp { background: linear-gradient(135deg,#25d366,#128c7e); }
.history-icon.t-nota { background: linear-gradient(135deg,#7c3aed,#5b7cfa); }
.history-body { flex: 1; min-width: 0; }
.history-name { margin: 0; font-weight: 700; font-size: 1.05rem; }
.history-desc { margin: 2px 0 0; font-size: .95rem; color: var(--text-2); }
.history-transcript { margin: 8px 0 0; padding: 10px 12px; border-radius: 12px; background: rgba(138,92,246,.10); color: #ddd6fe; font-size: .95rem; }
.history-time { flex: 0 0 auto; text-align: right; font-size: .85rem; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- ajustes / cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.card-danger { border-color: rgba(244,63,94,.35); }
.field-label { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.field-hint { margin: 0; font-size: .92rem; color: var(--text-3); }
.field-hint code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; color: #c4b5fd; }

textarea, select {
  width: 100%; padding: 14px; border-radius: var(--radius-md); border: 1px solid var(--border-strong);
  background: rgba(0,0,0,.25); color: var(--text); font-size: 1.05rem; line-height: 1.45; outline: 0; resize: vertical;
}
textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,124,250,.25); }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }

/* ---------- botones genéricos ---------- */
.btn {
  height: 54px; padding: 0 18px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 700; font-size: 1.02rem; transition: transform .12s, filter .12s; flex: 1;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: var(--shadow-glow); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); }
.btn-danger { background: rgba(244,63,94,.16); border: 1px solid rgba(244,63,94,.5); color: #fb7185; }
.btn-whatsapp { background: linear-gradient(135deg, #25d366, #128c7e); color: #fff; box-shadow: 0 8px 22px rgba(37,211,102,.3); }
.btn-block { width: 100%; }
.btn-lg { height: 62px; font-size: 1.15rem; }
.text-btn { font-weight: 600; font-size: .95rem; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; }
.text-btn-danger { color: #fb7185; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-bottom)); padding: 8px 10px var(--safe-bottom);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(11,16,32,.82); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}
.nav-item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-3); border-radius: 14px; font-size: .8rem; font-weight: 600; transition: color .15s; }
.nav-item i { font-size: 1.35rem; }
.nav-active { color: #fff; }
.nav-active i { color: var(--primary); filter: drop-shadow(0 0 8px rgba(91,124,250,.7)); }
.nav-badge { position: absolute; top: 4px; right: calc(50% - 26px); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: .72rem; font-style: normal; font-weight: 700; display: grid; place-items: center; }

/* ---------- sheets (modales inferiores) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto;
  background: linear-gradient(180deg, #141c39, #0e1429);
  border: 1px solid var(--border-strong); border-bottom: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 10px 18px calc(22px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 14px;
  animation: slideUp .3s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 -20px 60px rgba(0,0,0,.5);
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0 } to { transform: none; opacity: 1 } }
.sheet-handle { width: 44px; height: 5px; border-radius: 99px; background: var(--border-strong); margin: 0 auto 4px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sheet-head h3 { margin: 0; font-family: var(--font-head); font-size: 1.35rem; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.sheet-sub { margin: 4px 0 0; color: var(--text-2); font-size: 1rem; }
.sheet-actions { display: flex; gap: 10px; }

.import-preview { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; padding: 4px 0; }
.preview-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-size: .95rem; }
.preview-item b { color: var(--text); }
.preview-item span { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.preview-count { font-weight: 700; color: #4ade80; font-size: .95rem; }

/* ---------- hoja de voz ---------- */
.voice-status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); font-size: 1rem; color: var(--text-2); }
.voice-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--text-3); flex: 0 0 auto; }
.voice-status.is-recording { border-color: rgba(244,63,94,.5); color: #fecdd3; }
.voice-status.is-recording .voice-dot { background: var(--danger); animation: blink 1s infinite; }
.voice-status.is-error { border-color: rgba(245,158,11,.5); color: #fde68a; }
@keyframes blink { 50% { opacity: .2 } }

.waveform { display: flex; align-items: center; justify-content: center; gap: 5px; height: 54px; }
.waveform span { width: 6px; height: 10px; border-radius: 99px; background: linear-gradient(180deg, #c4b5fd, #7c3aed); opacity: .35; transition: height .15s; }
.waveform.is-active span { opacity: 1; animation: wave 1s ease-in-out infinite; }
.waveform.is-active span:nth-child(odd) { animation-duration: .8s; }
.waveform.is-active span:nth-child(3n) { animation-duration: 1.2s; animation-delay: -.3s; }
.waveform.is-active span:nth-child(4n) { animation-delay: -.6s; }
@keyframes wave { 0%,100% { height: 10px } 50% { height: 44px } }

.transcript-box { position: relative; }
.transcript-box textarea { min-height: 130px; padding-bottom: 36px; }
.transcript-interim { position: absolute; left: 14px; right: 14px; bottom: 12px; font-size: .95rem; color: var(--text-3); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

.voice-controls { display: flex; justify-content: center; padding: 6px 0; }
.hold-btn {
  position: relative; width: 132px; height: 132px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: linear-gradient(135deg, #7c3aed, #5b7cfa); color: #fff;
  box-shadow: 0 14px 40px rgba(124,58,237,.45);
  user-select: none; -webkit-user-select: none; touch-action: none;
  transition: transform .15s, background .2s;
}
.hold-btn i { font-size: 2.4rem; }
.hold-btn small { font-size: .78rem; font-weight: 600; opacity: .9; }
.hold-ring { position: absolute; inset: -10px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); opacity: 0; }
.hold-btn.is-recording { transform: scale(1.08); background: linear-gradient(135deg, #f43f5e, #e11d48); box-shadow: 0 14px 44px rgba(244,63,94,.55); }
.hold-btn.is-recording .hold-ring { opacity: 1; animation: pulse 1.2s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.9); opacity: .9 } 100% { transform: scale(1.35); opacity: 0 } }

.wa-quick { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.wa-quick::-webkit-scrollbar { display: none; }

/* ---------- detalle ---------- */
.detail-timeline { display: flex; flex-direction: column; gap: 10px; max-height: 45dvh; overflow-y: auto; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px); transform: translateX(-50%);
  z-index: 100; padding: 14px 20px; border-radius: 16px; background: #1b2447; border: 1px solid var(--border-strong);
  color: #fff; font-weight: 600; font-size: 1rem; box-shadow: var(--shadow); max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 10px; animation: fadeUp .25s ease;
}
.toast.t-ok i { color: var(--success); }
.toast.t-err i { color: var(--danger); }
.toast.t-info i { color: var(--primary); }

/* ---------- tablets / escritorio ---------- */
@media (min-width: 720px) {
  .contact-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .app-main { max-width: 960px; }
  .sheet { border-radius: var(--radius-xl); margin-bottom: 24px; border-bottom: 1px solid var(--border-strong); }
  .sheet-backdrop { align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
