/* =====================================================================
   COMPONENTES BASE
   ===================================================================== */

/* ---------- Botones ---------- */
.btn-primary{background:var(--brand); color:#fff; border:none; padding:10px 16px; border-radius:9px; font-size:12.5px; font-weight:500; cursor:pointer; box-shadow:0 6px 16px -6px rgba(16,106,224,.45); display:inline-flex; align-items:center; gap:6px;}
.btn-secondary{background:#fff; border:1px solid var(--line); color:var(--text1); padding:10px 16px; border-radius:9px; font-size:12.5px; font-weight:500; cursor:pointer;}
.btn-ghost{background:none; border:none; color:var(--text2); padding:10px 12px; border-radius:9px; font-size:12.5px; cursor:pointer;}
.btn-danger{background:var(--danger-dim); border:1px solid rgba(196,67,46,.25); color:var(--danger); padding:10px 16px; border-radius:9px; font-size:12.5px; font-weight:500; cursor:pointer;}
.btn-icon{width:34px; height:34px; border-radius:9px; border:1px solid var(--line); background:#fff; display:inline-flex; align-items:center; justify-content:center; cursor:pointer; color:var(--text2); flex-shrink:0;}
.btn-icon:hover{background:var(--line-soft);}
.btn-icon.sm{width:28px; height:28px;}
.icon-btn{position:relative; width:34px; height:34px; border-radius:10px; display:flex; align-items:center; justify-content:center; color:var(--text2); cursor:pointer;}
.icon-btn:hover{background:var(--line-soft);}
.icon-btn .dot{position:absolute; top:7px; right:8px; width:6px; height:6px; border-radius:50%; background:var(--bronze); border:1.5px solid #fff;}
.avatar{width:30px; height:30px; border-radius:50%; background:linear-gradient(135deg,var(--brand),#4C8FED); display:flex; align-items:center; justify-content:center; color:#fff; font-size:11px; font-weight:600; font-family:var(--disp);}
.profile{display:flex; align-items:center; gap:9px; cursor:pointer;}
.profile .name{font-size:12.5px; font-weight:500; color:var(--text1);}
.profile .role{font-size:10.5px; color:var(--text3);}

/* ---------- Campos ---------- */
.field{display:flex; flex-direction:column; gap:5px;}
.field label{font-size:11.5px; color:var(--text3); font-family:var(--mono); text-transform:uppercase; letter-spacing:.04em;}
.field input, .field select, .field textarea{border:1px solid var(--line); border-radius:9px; padding:10px 12px; font-size:13px; font-family:var(--ui); width:100%;}
.field.fixed{max-width:170px;}          /* fecha, moneda, código: nunca crecen */
.form-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:var(--sp-4) var(--sp-5);}
.chip-select{display:flex; flex-wrap:wrap; gap:8px;}
.chip{display:flex; align-items:center; gap:6px; background:var(--line-soft); border:1px solid transparent; padding:7px 13px; border-radius:20px; font-size:12px; color:var(--text2); cursor:pointer;}
.chip.active{background:var(--brand-dim); border-color:var(--brand); color:var(--brand);}

/* ---------- Tarjetas / badges ---------- */
.card{background:var(--surface); border:1px solid var(--line); border-radius:16px; overflow:hidden; box-shadow:0 1px 2px rgba(16,20,30,.03), 0 12px 28px -14px rgba(16,20,30,.08);}
.pill{display:inline-flex; align-items:center; gap:6px; font-size:11px; font-weight:500; padding:4px 10px 4px 8px; border-radius:20px;}
.pill .dot{width:6px; height:6px; border-radius:50%;}
.pill.accent{background:var(--brand-dim); color:var(--brand);} .pill.accent .dot{background:var(--brand);}
.pill.bronze{background:var(--bronze-dim); color:var(--bronze);} .pill.bronze .dot{background:var(--bronze);}
.pill.success{background:var(--success-dim); color:var(--success);} .pill.success .dot{background:var(--success);}
.pill.muted{background:var(--line-soft); color:var(--text3);} .pill.muted .dot{background:var(--text3);}
.pill.danger{background:var(--danger-dim); color:var(--danger);} .pill.danger .dot{background:var(--danger);}

/* ---------- Tabla / listado ---------- */
.table-scroll{overflow-x:auto;}
th{text-align:left; font-family:var(--mono); font-weight:500; color:var(--text3); font-size:10px; text-transform:uppercase; letter-spacing:.06em; padding:13px 18px; border-bottom:1px solid var(--line); white-space:nowrap;}
td{padding:14px 18px; border-bottom:1px solid var(--line-soft); font-size:13px;}
tr:last-child td{border-bottom:none;}
tr.rowhover{cursor:pointer;}
tr.rowhover:hover td{background:rgba(16,106,224,.03);}
.code{font-family:var(--mono); font-size:12.5px; font-weight:500;}
.row-actions{display:flex; gap:4px; opacity:0; transition:opacity .12s ease;}
tr.rowhover:hover .row-actions{opacity:1;}

.filter-bar{position:sticky; top:0; z-index:5; padding:var(--sp-3) 0; background:rgba(250,251,252,.9); backdrop-filter:blur(6px);}
.filter-row{display:flex; gap:var(--sp-3); align-items:center; flex-wrap:wrap;}
.filter-row select, .filter-row input{border:1px solid var(--line); background:#fff; border-radius:9px; padding:8px 12px; font-size:12.5px;}
.filter-toggle{border:1px dashed var(--line); background:none; color:var(--text3); border-radius:9px; padding:8px 12px; font-size:12px; cursor:pointer; display:flex; align-items:center; gap:5px;}
.filter-more{max-height:0; overflow:hidden; transition:max-height .22s ease; display:flex; gap:var(--sp-3); flex-wrap:wrap;}
.filter-more.open{max-height:120px; padding-top:var(--sp-3);}
.pager{display:flex; justify-content:space-between; align-items:center; padding:13px 18px; font-size:11.5px; color:var(--text3); font-family:var(--mono); border-top:1px solid var(--line); flex-wrap:wrap; gap:8px;}

/* ---------- Kanban ---------- */
.kanban{display:grid; grid-template-columns:repeat(4,1fr); gap:10px;}
.kcol h3{font-size:11px; color:var(--text3); text-transform:uppercase; letter-spacing:.05em; margin:0 0 8px;}
.kcard{background:#fff; border:1px solid var(--line); border-radius:10px; padding:12px; margin-bottom:8px; cursor:pointer;}
.kcard.hot{border-color:var(--brand); background:var(--brand-dim);}
.kcard p{margin:0; font-size:13px; font-weight:500;}
.kcard .meta{font-size:11px; color:var(--text3); margin-top:4px;}

/* ---------- Tramos (ruta encadenada) ---------- */
.tramo-row{display:flex; align-items:center; gap:8px; background:var(--line-soft); border-radius:10px; padding:9px 12px; margin-bottom:6px; flex-wrap:wrap;}
.tramo-num{width:20px; height:20px; border-radius:50%; background:var(--brand); color:#fff; font-size:10px; display:flex; align-items:center; justify-content:center; flex-shrink:0;}

/* ---------- Stepper + tabs (detalle unificado de Cotización) ---------- */
.stepper{display:flex; align-items:center; gap:0; margin-bottom:var(--sp-5); background:#fff; border:1px solid var(--line); border-radius:12px; padding:14px 18px; overflow-x:auto;}
.step{display:flex; align-items:center; gap:8px; font-size:11.5px; color:var(--text3); white-space:nowrap;}
.step .dot3{width:20px; height:20px; border-radius:50%; background:var(--line-soft); border:1.5px solid var(--line); display:flex; align-items:center; justify-content:center; font-size:10px; color:var(--text3); flex-shrink:0;}
.step.done .dot3{background:var(--success); border-color:var(--success); color:#fff;}
.step.current .dot3{background:var(--brand); border-color:var(--brand); color:#fff;}
.step.current{color:var(--ink); font-weight:600;}
.step-line{flex:1; height:1.5px; background:var(--line); margin:0 8px; min-width:20px;}
.tabs{display:flex; gap:2px; border-bottom:1px solid var(--line); margin-bottom:var(--sp-5); overflow-x:auto;}
.tab{padding:9px 14px; font-size:12.5px; color:var(--text2); cursor:pointer; border-bottom:2px solid transparent; white-space:nowrap;}
.tab.active{color:var(--brand); border-bottom-color:var(--brand); font-weight:600;}

/* ---------- ActionBar / Drawer / Modal ---------- */
/* ---------- Panel lateral ancho — para formularios completos (varios campos),
   a diferencia del #drawer angosto (420px) que es solo para ediciones rápidas
   de 2-3 campos. Es navegación de página normal (sin fetch/JS), solo con el
   contenido alineado a la derecha y una animación de entrada sutil. ---------- */
.side-panel-page{ display:flex; justify-content:flex-end; }
.side-panel{
  width:100%; max-width:680px; background:var(--surface); border:1px solid var(--line); border-radius:16px;
  box-shadow:0 20px 50px -20px rgba(16,20,30,.18);
  animation:panelIn .22s cubic-bezier(.4,0,.2,1);
}
@keyframes panelIn{ from{ opacity:0; transform:translateX(20px);} to{opacity:1; transform:translateX(0);} }
.side-panel-head{ display:flex; justify-content:space-between; align-items:flex-start; padding:22px 26px; border-bottom:1px solid var(--line); }
.side-panel-body{ padding:26px; }
.side-panel.narrow{ max-width:460px; }

.sticky-actionbar{position:sticky; bottom:0; margin-top:var(--sp-6); background:rgba(255,255,255,.92); backdrop-filter:blur(8px); border-top:1px solid var(--line); padding:var(--sp-4) 0; display:flex; justify-content:flex-end; gap:var(--sp-2); box-shadow:0 -12px 24px -16px rgba(16,20,30,.08); flex-wrap:wrap;}

#overlay{position:fixed; inset:0; background:rgba(11,14,20,.32); backdrop-filter:blur(2px); z-index:40; opacity:0; pointer-events:none; transition:opacity .22s ease;}
#overlay.open{opacity:1; pointer-events:auto;}

#drawer{position:fixed; top:0; right:0; height:100vh; width:420px; max-width:92vw; background:#fff; z-index:50; box-shadow:-24px 0 60px -20px rgba(11,14,20,.25); transform:translateX(100%); transition:transform .28s cubic-bezier(.4,0,.2,1); display:flex; flex-direction:column;}
#drawer.open{transform:translateX(0);}
.drawer-head{padding:22px 24px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:flex-start;}
.drawer-body{padding:20px 24px; flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:14px;}
.drawer-foot{padding:16px 24px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:8px;}

#modal{position:fixed; top:50%; left:50%; transform:translate(-50%,-46%); width:380px; max-width:90vw; background:#fff; border-radius:16px; z-index:50; box-shadow:0 30px 60px -12px rgba(11,14,20,.3); opacity:0; pointer-events:none; transition:opacity .18s ease, transform .18s ease;}
#modal.open{opacity:1; pointer-events:auto; transform:translate(-50%,-50%);}
.modal-body{padding:26px;}
.modal-icon{width:44px; height:44px; border-radius:12px; background:var(--danger-dim); color:var(--danger); display:flex; align-items:center; justify-content:center; margin-bottom:14px;}

/* ---------- Estados: skeleton / empty / toast ---------- */
.skel{background:linear-gradient(90deg,var(--line-soft) 25%,var(--line) 37%,var(--line-soft) 63%); background-size:400% 100%; animation:skel 1.4s ease infinite; border-radius:6px;}
@keyframes skel{0%{background-position:100% 0;}100%{background-position:0 0;}}
.empty-state{display:flex; flex-direction:column; align-items:center; justify-content:center; padding:70px 20px; text-align:center;}
.empty-state .ic{width:52px; height:52px; border-radius:14px; background:var(--brand-dim); color:var(--brand); display:flex; align-items:center; justify-content:center; margin-bottom:16px;}
.empty-state h3{font-family:var(--disp); font-size:15px; margin:0 0 4px;}
.empty-state p{font-size:12.5px; color:var(--text3); margin:0 0 16px; max-width:280px;}

#toast-wrap{position:fixed; bottom:24px; right:24px; z-index:60; display:flex; flex-direction:column; gap:8px; max-width:calc(100vw - 32px);}
.toast{background:var(--ink); color:#fff; padding:12px 16px; border-radius:10px; font-size:12.5px; display:flex; align-items:center; gap:9px; box-shadow:0 12px 28px -8px rgba(0,0,0,.35); animation:toastIn .25s ease;}
.toast .dot2{width:7px; height:7px; border-radius:50%; background:var(--bronze); flex-shrink:0;}
.toast.success .dot2{background:#3DDC97;} .toast.danger .dot2{background:#E5745E;}
@keyframes toastIn{from{opacity:0; transform:translateY(8px);} to{opacity:1; transform:translateY(0);}}
