/* ============================================================
   ZYRA CRM — Estilos base
   Paleta: Fondo #F8F9FA | Texto #2C2C2A | Sidebar #4A1A6B
           Acento #5DCAA5 | Alerta #D85A30
   ============================================================ */

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

/* Fix: evita que display:flex/grid de la clase sobreescriba el atributo hidden */
[hidden] { display: none !important; }

:root {
  --bg:        #F8F9FA;
  --text:      #2C2C2A;
  --sidebar:   #4A1A6B;
  --accent:    #5DCAA5;
  --alert:     #D85A30;
  --surface:   #FFFFFF;
  --border:    #E0E0DF;
  --muted:     #6B6B68;
  --radius:    8px;
  --shadow:    0 2px 8px rgba(0,0,0,.08);
}

html { font-size: 16px; }

body {
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ── LOGIN ── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: var(--sidebar);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--sidebar);
  text-align: center;
  letter-spacing: 4px;
}

.login-tagline {
  text-align: center;
  color: var(--muted);
  margin-bottom: 2rem;
  font-size: .9rem;
}

/* ── FORMULARIOS ── */
.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.25rem; }

label { font-weight: 500; font-size: .9rem; }

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
select,
textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  transition: border-color .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── BOTONES ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-danger   { background: var(--alert);   color: #fff; }
.btn-ghost    { background: transparent;    color: inherit; }
.btn-full     { width: 100%; }

/* ── DASHBOARD ── */
.dashboard {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 4px;
  text-align: center;
  padding: 0 1rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.15);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  flex: 1;
}

.nav-item {
  padding: .85rem 1.5rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover,
.nav-item.active {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.sidebar-logout {
  margin: 0 1rem 1rem;
  color: rgba(255,255,255,.6);
  font-size: .9rem;
}
.sidebar-logout:hover { color: #fff; }

/* ── CONTENIDO PRINCIPAL ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.topbar h2 { font-size: 1.25rem; font-weight: 600; }
.agent-name { color: var(--muted); font-size: .9rem; }

.view-container {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

/* ── TARJETAS / TABLA ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}

thead th {
  text-align: left;
  padding: .75rem 1rem;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--muted);
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

tbody td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover { background: #f3f4f6; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: .2em .7em;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
}
.badge-green  { background: #d1f5ea; color: #0d6b4a; }
.badge-orange { background: #ffe4d6; color: #993c18; }
.badge-purple { background: #ede0f8; color: #4A1A6B; }
.badge-gray   { background: #e9e9e7; color: #4a4a47; }

/* ── MENSAJES ── */
.error-msg   { color: var(--alert); font-size: .9rem; margin-bottom: .75rem; }
.placeholder { color: var(--muted); text-align: center; padding: 3rem 0; }

/* ── PANEL DE AGENTE: Barra de estadísticas ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
  text-align: center;
}
.stat-green  { border-left-color: var(--accent); }
.stat-orange { border-left-color: var(--alert); }
.stat-gray   { border-left-color: var(--muted); }
.stat-purple { border-left-color: var(--sidebar); }

.stat-num   { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: .78rem; color: var(--muted); }

.meta-bar  { width: 100%; height: 5px; background: var(--border); border-radius: 3px; margin-top: .4rem; }
.meta-fill { height: 100%; background: var(--sidebar); border-radius: 3px; transition: width .4s; }

/* ── PANEL DE LLAMADA ACTIVA ── */
.call-panel { display: flex; flex-direction: column; gap: 1rem; }

.client-card { }
.client-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.client-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
}
.client-name  { font-size: 1.2rem; font-weight: 700; margin: 0 0 .2rem; }
.client-phone { color: var(--muted); font-size: .95rem; }

.client-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.detail-item  { display: flex; flex-direction: column; gap: .2rem; }
.detail-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.detail-value { font-size: 1rem; font-weight: 500; }

/* ── CRONÓMETRO / SEMÁFORO ── */
.timer-card { text-align: center; padding: 1.25rem 1.5rem; }

.timer-display {
  font-size: 4.5rem;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1;
  padding: .5rem 0 .75rem;
  transition: color .4s;
}
.semaforo-verde    { color: var(--accent); }
.semaforo-amarillo { color: #D4A017; }
.semaforo-naranja  { color: var(--alert); }
.semaforo-rojo     { color: #B91C1C; animation: titilar 1s ease-in-out infinite; }

@keyframes titilar {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}

.semaforo-labels {
  display: flex;
  justify-content: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.s-label {
  font-size: .72rem;
  font-weight: 700;
  padding: .2em .65em;
  border-radius: 999px;
}
.s-label.verde    { background: #d1f5ea; color: #0d6b4a; }
.s-label.amarillo { background: #fef3c7; color: #92400e; }
.s-label.naranja  { background: #ffe4d6; color: #993c18; }
.s-label.rojo     { background: #fee2e2; color: #991b1b; }

/* ── SCRIPT ADAPTATIVO ── */
.script-card { }
.script-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .85rem;
}
.script-title { font-size: 1rem; font-weight: 700; }
.script-tag {
  font-size: .72rem;
  font-weight: 700;
  padding: .2em .6em;
  border-radius: 999px;
  background: #ede0f8;
  color: var(--sidebar);
}
.script-content { display: flex; flex-direction: column; gap: .6rem; }
.script-line {
  font-size: 1.05rem;
  padding: .75rem 1rem;
  background: var(--bg);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  line-height: 1.5;
}

/* ── BOTONES DE RESULTADO ── */
.result-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-top: .25rem;
}
.btn-result {
  padding: 1rem .75rem;
  font-size: .95rem;
  border-radius: var(--radius);
  font-weight: 700;
}
.btn-venta       { background: var(--accent);  color: #fff; }
.btn-cancelado   { background: var(--alert);   color: #fff; }
.btn-no-contesta { background: var(--muted);   color: #fff; }
.btn-aplazar     { background: var(--sidebar); color: #fff; }
.btn-result:disabled { opacity: .5; cursor: not-allowed; }

/* ── LISTA DE LEADS PARA LLAMAR ── */
.lead-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.lead-list-header h3 { font-size: 1.05rem; font-weight: 700; }

.lead-call-list { display: flex; flex-direction: column; gap: .6rem; }
.lead-call-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1rem;
  background: var(--bg);
  border-radius: var(--radius);
  gap: 1rem;
}
.lead-call-info {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}
.lead-call-info strong {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lead-call-sub {
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-sm { padding: .55rem .9rem; font-size: .875rem; white-space: nowrap; }

/* ── MOBILE FIRST ── */
@media (max-width: 680px) {
  .sidebar { width: 100%; min-height: auto; flex-direction: row; align-items: center; padding: .75rem 1rem; }
  .sidebar-logo { padding: 0 1rem 0 0; border-bottom: none; font-size: 1.4rem; }
  .sidebar-nav { flex-direction: row; padding: 0; gap: .25rem; }
  .nav-item { padding: .5rem .75rem; font-size: .85rem; }
  .sidebar-logout { display: none; }
  .dashboard { flex-direction: column; }
  .view-container { padding: 1rem; }
  .topbar { padding: 1rem; }
  thead { display: none; }
  tbody td { display: block; padding: .4rem 1rem; }
  tbody td::before { content: attr(data-label) ': '; font-weight: 600; }
}

@media (min-width: 520px) {
  .stats-bar { grid-template-columns: repeat(4, 1fr); }
}

/* ── VISTA PEDIDOS ── */
.orders-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 680px) {
  .orders-stats-grid { grid-template-columns: 1fr 1fr; }
}

.orders-filtros-bar {
  display: flex;
  gap: .65rem;
  align-items: center;
  flex-wrap: wrap;
  padding: .85rem 1.25rem;
  margin-bottom: 1rem;
}
.orders-filtros-bar select {
  padding: .4rem .75rem;
  font-size: .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--sidebar);
}

.modal-resumen {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.modal-resumen-row { font-size: .9rem; line-height: 1.5; }
.modal-total { font-weight: 700; color: var(--accent); font-size: 1rem; }

.modal-btns {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: .5rem;
}

.btn-modal-cancel {
  background: #e9e9e7; color: var(--text);
  border: none; border-radius: var(--radius);
  padding: .65rem 1.25rem; font-size: .9rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: opacity .15s;
}
.btn-modal-cancel:hover { opacity: .8; }

.btn-modal-confirm {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  padding: .65rem 1.25rem; font-size: .9rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: opacity .15s;
}
.btn-modal-confirm:hover    { opacity: .88; }
.btn-modal-confirm:disabled { opacity: .5; cursor: not-allowed; }

.modal-error { color: var(--alert); font-size: .85rem; margin-top: .5rem; }

/* ── Sesión 16: Badges de entrega y aplazado ── */
.badge-entrega-normal {
  display: inline-block; padding: .25rem .6rem; border-radius: 20px;
  background: #E5E7EB; color: #374151; font-size: .78rem; font-weight: 600; margin-top: .25rem;
}
.badge-entrega-aplazada {
  display: inline-block; padding: .25rem .6rem; border-radius: 20px;
  background: #FEF3C7; color: #92400E; font-size: .78rem; font-weight: 600; margin-top: .25rem;
}
.badge-yellow  { background: #FEF3C7 !important; color: #92400E !important; }
.badge-alert   { background: #FEE2E2 !important; color: #D85A30 !important; }

/* ── Sección de fecha en modal de pedido ── */
.modal-entrega-section {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem; margin: .75rem 0; background: #F9FAFB;
}
.modal-entrega-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem;
}
.modal-entrega-title { font-weight: 600; font-size: .88rem; }
.entrega-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .25rem; }

/* ── Modal aplazar (mobile-first) ── */
.modal-aplazar { width: min(520px, 96vw); }
.aplazar-advertencia-roja {
  background: #FEF2F2; border: 1px solid #D85A30; border-radius: var(--radius);
  padding: .6rem .75rem; font-size: .83rem; margin-bottom: .75rem; color: #7F1D1D;
}
.aplazar-intentos { font-size: .83rem; color: var(--muted); margin-bottom: .5rem; }
.aplazar-motivos { margin-bottom: .75rem; }
.aplazar-radio {
  display: flex; align-items: center; gap: .4rem; font-size: .85rem;
  padding: .3rem 0; cursor: pointer;
}
.aplazar-radio input[type="radio"] { cursor: pointer; }
.aplazar-field { margin-bottom: .65rem; }
.aplazar-field label { display: block; font-size: .83rem; font-weight: 600; margin-bottom: .25rem; }
.aplazar-field input[type="date"] {
  padding: .35rem .5rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .85rem; font-family: inherit;
}

/* ── Badges de lead aplazado y reciclado ── */
.badge-aplazado  { background: #FED7AA; color: #9A3412; }
.badge-reciclado { background: #E5E7EB; color: #374151; }

@media (max-width: 600px) {
  .modal-aplazar { width: 100vw; min-height: 100vh; border-radius: 0; margin: 0; }
  .modal-overlay { align-items: flex-start; }
}
