/* ============================================================
   CRM Carlos Junior · Distribución Figuras PVC
   Archivo: css/style.css
   ============================================================ */

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

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #f0ede8;
  --border: #e2ddd8;
  --accent: #e8520a;
  --accent-light: #fff0ea;
  --accent2: #1a1a2e;
  --text: #1a1714;
  --muted: #8a8480;
  --green: #1a7a4a;
  --green-bg: #edfaf3;
  --red: #c0392b;
  --red-bg: #fdf0ee;
  --blue: #1a4fa0;
  --blue-bg: #eef3fc;
  --purple: #6a3fa0;
  --purple-bg: #f4effe;
  --yellow: #a06a00;
  --yellow-bg: #fdf6e3;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.10);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: "Plus Jakarta Sans", sans-serif; font-size: 14px; min-height: 100vh; }

/* HEADER */
header { background: var(--accent2); padding: 0 32px; display: flex; align-items: center; justify-content: space-between; height: 64px; position: sticky; top: 0; z-index: 100; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 38px; height: 38px; background: var(--accent); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #fff; }
.brand-name { font-weight: 700; font-size: 16px; color: #fff; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 1px; }
.header-stats { display: flex; gap: 24px; }
.hstat { text-align: right; }
.hstat-val { font-weight: 800; font-size: 20px; color: #fff; line-height: 1; }
.hstat-val.orange { color: var(--accent); }
.hstat-val.green { color: #4ecb8a; }
.hstat-label { font-size: 10px; color: rgba(255,255,255,.45); margin-top: 2px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; }

/* BADGE CALENDARIO */
.cal-badge { display: inline-flex; align-items: center; justify-content: center; background: var(--red); color: #fff; font-size: 10px; font-weight: 800; border-radius: 10px; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 5px; vertical-align: middle; line-height: 1; }

/* NAV TABS */
.nav-tabs { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 32px; display: flex; overflow-x: auto; }
.nav-tab { padding: 14px 18px 12px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; transition: all .15s; white-space: nowrap; user-select: none; }
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* TOOLBAR */
.toolbar { padding: 16px 32px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface); border-bottom: 1px solid var(--border); }
.search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 400px; }
.search-wrap input { width: 100%; background: var(--surface2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: 13px; padding: 9px 12px 9px 38px; outline: none; transition: border-color .2s; }
.search-wrap input:focus { border-color: var(--accent); }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; }
select { background: var(--surface2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: 13px; padding: 9px 12px; outline: none; cursor: pointer; }

/* NOTIFICACIÓN HOY */
.notif-hoy { display: flex; align-items: center; gap: 12px; background: #2a0e0e; border-top: 1px solid #7a1a1a; border-bottom: 1px solid #7a1a1a; padding: 11px 32px; }
.notif-icon { font-size: 20px; flex-shrink: 0; }
.notif-text { flex: 1; font-size: 13px; color: #ffaaaa; }
.notif-text strong { color: #ff6b6b; }
.notif-btn { background: #5c1a1a; color: #ff6b6b; border: 1.5px solid #8a2a2a; border-radius: 6px; font-family: inherit; font-size: 12px; font-weight: 700; padding: 6px 14px; cursor: pointer; white-space: nowrap; transition: all .15s; }
.notif-btn:hover { background: #7a1a1a; color: #fff; }
.notif-btn-red { background: #5c1a1a; color: #ff6b6b; border: 1.5px solid #8a2a2a; border-radius: 6px; font-family: inherit; font-size: 12px; font-weight: 700; padding: 6px 14px; cursor: pointer; white-space: nowrap; transition: all .15s; }
.notif-btn-red:hover { background: #7a1a1a; color: #fff; }

/* PROGRESS */
.progress-wrap { padding: 12px 32px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; }
.progress-label { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.progress-bar { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #ff8a4a); border-radius: 4px; transition: width .4s; }
.progress-pct { font-weight: 800; font-size: 13px; color: var(--accent); white-space: nowrap; min-width: 38px; }

/* BUTTONS */
.btn { background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); padding: 9px 18px; font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer; transition: opacity .15s; white-space: nowrap; }
.btn:hover { opacity: .88; }
.btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 9px 16px; font-family: inherit; font-weight: 600; font-size: 13px; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-outline.blue { border-color: #90b8f0; color: var(--blue); }
.btn-danger { background: var(--red); color: #fff; border: none; border-radius: var(--radius-sm); padding: 9px 16px; font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer; }
.btn-danger-sm { background: var(--red-bg); color: var(--red); border: 1.5px solid #f5c6c2; border-radius: var(--radius-sm); padding: 7px 12px; font-family: inherit; font-weight: 600; font-size: 12px; cursor: pointer; }

/* PAPELERA */
.papelera-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 32px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }

/* TABLA CLIENTES */
.table-wrap { padding: 0 24px 24px; overflow-x: auto; }
.client-table { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 1200px; }
.client-table thead tr { border-bottom: 2px solid var(--border); }
.client-table colgroup col:nth-child(1)  { width: 44px; }
.client-table colgroup col:nth-child(2)  { width: 220px; }
.client-table colgroup col:nth-child(3)  { width: 180px; }
.client-table colgroup col:nth-child(4)  { width: 140px; }
.client-table colgroup col:nth-child(5)  { width: 150px; }
.client-table colgroup col:nth-child(6)  { width: 120px; }
.client-table colgroup col:nth-child(7)  { width: 145px; }
.client-table colgroup col:nth-child(8)  { width: 145px; }
.client-table colgroup col:nth-child(9)  { width: 115px; }
.client-table colgroup col:nth-child(10) { width: 300px; }
.th { padding: 10px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); text-align: left; white-space: nowrap; user-select: none; cursor: pointer; }
.th:hover { color: var(--text); }
.th.sort-asc::after { content: ' ↑'; color: var(--accent); }
.th.sort-desc::after { content: ' ↓'; color: var(--accent); }
.th.no-sort { cursor: default; }
.th.no-sort:hover { color: var(--muted); }
.client-row { border-bottom: 1px solid var(--border); transition: background .12s; }
.client-row:hover { background: var(--surface2); }
.client-row td { padding: 11px 12px; vertical-align: middle; font-size: 13px; overflow: hidden; }
.th { overflow: hidden; }
.td-num { color: var(--muted); font-size: 12px; font-weight: 600; width: 36px; }
.td-nombre-wrap { min-width: 160px; }
.td-nombre { font-weight: 700; font-size: 13px; color: var(--text); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-nombre:hover { color: var(--accent); }
.td-sub { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: "DM Mono", monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-empresa { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-tel { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-tel a { color: #4db8ff; text-decoration: none; font-weight: 600; }
.td-tel a:hover { text-decoration: underline; }
.td-tel.sin-tel { color: var(--muted); }
.td-ciudad { font-weight: 600; font-size: 13px; }
.td-fecha { font-size: 12px; white-space: nowrap; }
.td-fecha .rel { font-size: 10px; color: var(--muted); margin-left: 4px; }
.td-fecha .rel.vencida { color: var(--red); font-weight: 700; }
.td-fecha .rel.hoy { color: var(--accent); font-weight: 700; }
.td-fecha .rel.pronto { color: var(--yellow); font-weight: 600; }
.td-notas-btn { background: var(--surface2); border: 1.5px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 11px; font-family: inherit; font-weight: 600; padding: 4px 9px; cursor: pointer; white-space: nowrap; transition: all .15s; }
.td-notas-btn:hover, .td-notas-btn.has-notas { border-color: #e8e0b0; color: var(--yellow); background: var(--yellow-bg); }
.td-actions { display: flex; gap: 5px; flex-wrap: nowrap; }
.act-btn { border-radius: 6px; font-size: 11px; font-family: inherit; font-weight: 700; padding: 5px 10px; cursor: pointer; white-space: nowrap; border: 1.5px solid transparent; transition: all .15s; }
.act-llamar { background: #0e2a1a; color: #4ecb8a; border-color: #1a5c38; }
.act-llamar:hover { background: #1a7a4a; color: #fff; }
.act-historial { background: var(--surface2); color: var(--muted); border-color: var(--border); }
.act-historial:hover { border-color: var(--accent); color: var(--accent); }
.act-editar { background: var(--blue-bg); color: var(--blue); border-color: #90b8f0; }
.act-editar:hover { background: var(--blue); color: #fff; }
.act-reset { background: var(--yellow-bg); color: var(--yellow); border-color: #e8d48a; }
.act-reset:hover { background: var(--yellow); color: #fff; }
.act-eliminar { background: var(--red-bg); color: var(--red); border-color: #f5c6c2; }
.act-eliminar:hover { background: var(--red); color: #fff; }
/* legacy - mantenidos por compatibilidad */
.card-btn { background: var(--surface2); border: 1.5px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 12px; font-family: inherit; font-weight: 600; padding: 5px 10px; cursor: pointer; transition: all .15s; }
.card-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.notes-badge { background: var(--yellow-bg); color: var(--yellow); border-radius: 6px; font-size: 10px; font-weight: 700; padding: 2px 7px; }

/* BADGES */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-pendiente { background: var(--purple-bg); color: var(--purple); }
.badge-llamado { background: var(--green-bg); color: var(--green); }
.badge-no-contesta { background: var(--yellow-bg); color: var(--yellow); }
.badge-sin-tel { background: var(--surface2); color: var(--muted); }

/* PAGINACIÓN */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 20px 32px; flex-wrap: wrap; }
.page-btn { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm); color: var(--muted); font-family: inherit; font-size: 13px; font-weight: 600; padding: 7px 13px; cursor: pointer; transition: all .15s; }
.page-btn:hover, .page-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.page-info { font-size: 12px; color: var(--muted); font-weight: 500; padding: 0 6px; }

/* EMPTY */
.empty { text-align: center; padding: 80px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 14px; }
.empty-title { font-weight: 700; font-size: 18px; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--muted); }

/* MODAL */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(26,23,20,.55); backdrop-filter: blur(3px); z-index: 200; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: 16px; width: 540px; max-width: 100%; box-shadow: var(--shadow-lg); overflow: hidden; flex-shrink: 0; }
.modal-wide { width: 720px; }
.modal-header { background: var(--accent2); padding: 22px 28px; display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-weight: 800; font-size: 18px; color: #fff; }
.modal-header .sub { font-size: 12px; color: rgba(255,255,255,.55); margin-top: 3px; }
.modal-close { background: rgba(255,255,255,.15); border: none; color: #fff; border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: rgba(255,255,255,.25); }
.modal-body { padding: 24px 28px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 16px 28px 24px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--border); }

/* FORMULARIO */
.perfil-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.perfil-section { margin-bottom: 20px; }
.perfil-section-title { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 12px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; background: var(--surface2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: 13px; padding: 9px 12px; outline: none; transition: border-color .2s; }
.form-group input:focus, .form-group textarea:focus { border-color: var(--accent); background: #fff; }
.form-group textarea { resize: vertical; min-height: 80px; }

/* BLOC DE NOTAS */
.notas-bloc { background: #fffef5; border: 1.5px solid #e8e0b0; border-radius: var(--radius); overflow: hidden; }
.notas-bloc-header { background: #f5f0d0; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; }
.notas-bloc-title { font-weight: 700; font-size: 12px; color: #7a6a00; }
.notas-entry { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px dashed #e8e0b0; }
.notas-entry:last-child { border-bottom: none; }
.notas-entry-fecha { font-size: 10px; color: #a09000; font-weight: 600; white-space: nowrap; padding-top: 2px; min-width: 72px; }
.notas-entry-texto { font-size: 13px; color: var(--text); flex: 1; line-height: 1.5; }
.notas-entry-del { background: none; border: none; color: #c0b080; cursor: pointer; font-size: 14px; padding: 0 4px; }
.notas-entry-del:hover { color: var(--red); }
.notas-add { display: flex; gap: 8px; padding: 10px 16px; }
.notas-add textarea { flex: 1; background: #fff; border: 1.5px solid #e8e0b0; border-radius: 8px; font-family: inherit; font-size: 13px; padding: 8px 12px; outline: none; resize: none; min-height: 60px; color: var(--text); }
.notas-add-btn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-family: inherit; font-weight: 700; font-size: 12px; cursor: pointer; align-self: flex-end; }
.notas-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 12px; }

/* HISTORIAL */
.historial-item { background: var(--surface2); border: 1.5px solid var(--border); border-left: 4px solid var(--green); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 8px; }
.historial-item.nc { border-left-color: var(--yellow); }
.historial-item.pend { border-left-color: var(--purple); }
.historial-fecha { font-weight: 700; font-size: 12px; color: var(--text); margin-bottom: 3px; display: flex; justify-content: space-between; }
.historial-nota { font-size: 12px; color: var(--muted); }

/* CALENDARIO */
.cal-wrap { padding: 24px 32px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.cal-titulo { font-weight: 800; font-size: 22px; color: var(--text); }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 8px; }
.cal-header-day { text-align: center; font-weight: 700; font-size: 11px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; padding: 6px 0; }
.cal-day { min-height: 80px; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 8px; cursor: pointer; transition: all .15s; box-shadow: var(--shadow); }
.cal-day:hover { border-color: var(--accent); }
.cal-day.hoy { border-color: var(--accent); background: var(--accent-light); }
.cal-day.seleccionado { border-color: var(--blue); background: var(--blue-bg); }
.cal-day.vacio { background: transparent; border-color: transparent; box-shadow: none; cursor: default; }
.cal-day-num { font-weight: 800; font-size: 14px; color: var(--text); margin-bottom: 5px; }
.cal-day.hoy .cal-day-num { color: var(--accent); }
.cal-pill { display: block; background: var(--blue-bg); color: var(--blue); border-radius: 5px; font-size: 10px; font-weight: 600; padding: 2px 6px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-pill.llamado { background: var(--green-bg); color: var(--green); }
.cal-pill.nc { background: var(--yellow-bg); color: var(--yellow); }
.cal-mas { font-size: 10px; color: var(--muted); font-weight: 600; }
.cal-detalle-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-top: 20px; box-shadow: var(--shadow); }
.cal-detalle-title { font-weight: 800; font-size: 16px; color: var(--text); margin-bottom: 14px; }
.cal-detalle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.cal-detalle-row:last-child { border-bottom: none; }

/* LOADING */
.loading { text-align: center; padding: 60px; color: var(--muted); font-size: 14px; }
.loading-spinner { display: inline-block; width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* TOAST */
.toast { position: fixed; bottom: 28px; right: 28px; background: var(--accent2); color: #fff; border-radius: var(--radius-sm); padding: 12px 20px; font-weight: 700; font-size: 13px; z-index: 400; transform: translateY(80px); opacity: 0; transition: all .3s; box-shadow: var(--shadow-lg); }
.toast.show { transform: translateY(0); opacity: 1; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* RESPONSIVE */
@media(max-width:700px) {
  header { padding: 12px 16px; height: auto; flex-wrap: wrap; gap: 10px; }
  .header-stats { gap: 14px; }
  .nav-tabs, .toolbar { padding: 0 16px; }
  .toolbar { padding: 12px 16px; }
  .table-wrap { padding: 0 12px 16px; }
  .td-empresa, .td-ciudad { display: none; }
  .cal-wrap { padding: 16px; }
  .perfil-cols { grid-template-columns: 1fr; }
  .modal-wide { width: 100%; }
}
