/* ============================================================
   TMS - Track Management System
   Track Group Chile · Identidad visual corporativa sobria
   ============================================================ */

:root{
  --tg-navy:      #0b2138;
  --tg-navy-2:    #123252;
  --tg-sidebar:   #002856;
  --tg-blue:      #1a56db;
  --tg-blue-light:#e8f0fe;
  --tg-accent:    #F26522;
  --tg-bg:        #f4f6f9;
  --tg-card-bg:   #ffffff;
  --tg-border:    #e2e6ec;
  --tg-text:      #1f2937;
  --tg-text-muted:#6b7280;

  --st-confirmado: #16a34a;
  --st-confirmado-bg: #e7f8ee;
  --st-pendiente:  #b45309;
  --st-pendiente-bg: #fef3e0;
  --st-cancelado:  #dc2626;
  --st-cancelado-bg: #fdeaea;
  --st-reprogramado: #2563eb;
  --st-reprogramado-bg: #e8f0fe;

  --sidebar-w: 250px;
}

.label-required::after{
  content: " *";
  color: var(--st-cancelado);
}

.direccion-suggest-wrap{ position:relative; }
.direccion-suggest-list{
  position:absolute; top:100%; left:0; right:0; z-index:1060;
  background:var(--tg-card-bg); border:1px solid var(--tg-border); border-radius:8px;
  margin-top:4px; box-shadow:0 6px 18px rgba(0,0,0,.12); overflow:hidden;
}
.direccion-suggest-item{
  padding:.45rem .75rem; font-size:.85rem; cursor:pointer;
}
.direccion-suggest-item:hover, .direccion-suggest-item.active{
  background:var(--tg-blue-light);
}
.direccion-suggest-item small{ display:block; color:var(--tg-text-muted); font-size:.72rem; }

*{box-sizing:border-box;}

html,body{
  height:100%;
}

body{
  background:var(--tg-bg);
  color:var(--tg-text);
  font-family:"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  font-size:.925rem;
}

a{text-decoration:none;}

/* ---------------- Auth pages (login / recuperar) ---------------- */
.auth-page{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  background:linear-gradient(135deg,var(--tg-navy) 0%, var(--tg-navy-2) 55%, var(--tg-accent) 140%);
  padding:1.5rem;
}
.auth-card{
  width:100%;
  max-width:400px;
  background:var(--tg-card-bg);
  border-radius:14px;
  box-shadow:0 20px 45px rgba(0,0,0,.25);
  padding:2.25rem 2rem;
}
.auth-logo{
  display:flex;
  align-items:center;
  gap:.6rem;
  margin-bottom:1.4rem;
}
.auth-logo .mark{
  width:42px;height:42px;border-radius:10px;
  background:var(--tg-navy);
  color:#fff;
  display:flex;align-items:center;justify-content:center;
  font-weight:700;font-size:1.1rem;
}
.auth-logo .name{font-weight:700;font-size:1.15rem;color:var(--tg-navy);line-height:1.1;}
.auth-logo .sub{font-size:.72rem;color:var(--tg-text-muted);letter-spacing:.03em;text-transform:uppercase;}
.auth-demo{
  background:var(--tg-blue-light);
  border:1px solid #cfe0fb;
  border-radius:8px;
  padding:.65rem .8rem;
  font-size:.78rem;
  color:var(--tg-navy-2);
}

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

.sidebar{
  width:var(--sidebar-w);
  flex:0 0 var(--sidebar-w);
  background:var(--tg-sidebar);
  color:#dbe4f0;
  position:fixed;
  top:0;left:0;bottom:0;
  display:flex;
  flex-direction:column;
  z-index:1030;
  transition:transform .2s ease;
}
.sidebar .brand{
  display:flex;
  align-items:center;
  gap:.6rem;
  padding:1.15rem 1.1rem;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.sidebar .brand .mark{
  width:36px;height:36px;border-radius:9px;
  background:var(--tg-accent);
  color:#fff;
  display:flex;align-items:center;justify-content:center;
  font-weight:800;font-size:.95rem;
}
.sidebar .brand .name{font-weight:700;color:#fff;font-size:1rem;line-height:1.1;}
.sidebar .brand .sub{font-size:.68rem;color:#8fa3bf;text-transform:uppercase;letter-spacing:.04em;}

.sidebar-nav{
  flex:1 1 auto;
  overflow-y:auto;
  padding:.75rem .6rem;
}
.sidebar-nav .nav-link, .sidebar-foot .nav-link{
  display:flex;
  align-items:center;
  gap:.7rem;
  color:#c3d1e3;
  padding:.62rem .8rem;
  border-radius:8px;
  font-size:.87rem;
  font-weight:500;
  margin-bottom:.15rem;
}
.sidebar-nav .nav-link i, .sidebar-foot .nav-link i{width:1.1rem;text-align:center;font-size:.95rem;}
.sidebar-nav .nav-link:hover, .sidebar-foot .nav-link:hover{background:rgba(255,255,255,.06);color:#fff;}
.sidebar-nav .nav-link.active, .sidebar-foot .nav-link.active{
  background:var(--tg-accent);
  color:#fff;
  font-weight:700;
}
.sidebar-nav .nav-section{
  font-size:.66rem;
  text-transform:uppercase;
  letter-spacing:.06em;
  color:#6f84a0;
  padding:.9rem .8rem .3rem;
}

.sidebar-foot{
  padding:.8rem;
  border-top:1px solid rgba(255,255,255,.08);
}
.sidebar-foot #btn-logout{color:#f2c4c4;}
.sidebar-foot #btn-logout:hover{background:rgba(220,38,38,.15);color:#ffd6d6;}

.main-col{
  margin-left:var(--sidebar-w);
  flex:1 1 auto;
  display:flex;
  flex-direction:column;
  min-height:100vh;
  width:calc(100% - var(--sidebar-w));
}

.topbar{
  background:#fff;
  border-bottom:1px solid var(--tg-border);
  padding:.7rem 1.4rem;
  display:flex;
  align-items:center;
  justify-content:space-between;
  position:sticky;
  top:0;
  z-index:1020;
}
.topbar .page-title{font-weight:700;font-size:1.05rem;color:var(--tg-navy);margin:0;}
.topbar .page-title small{display:block;font-weight:400;font-size:.74rem;color:var(--tg-text-muted);}

.topbar .user-chip{
  display:flex;align-items:center;gap:.6rem;
  padding:.3rem .5rem .3rem .3rem;
  border-radius:24px;
  border:1px solid var(--tg-border);
}
.avatar{
  width:34px;height:34px;border-radius:50%;
  background:var(--tg-navy);color:#fff;
  display:flex;align-items:center;justify-content:center;
  font-weight:700;font-size:.85rem;
}
.topbar .user-chip .avatar{}
.topbar .user-chip .u-name{font-size:.82rem;font-weight:600;line-height:1.1;}
.topbar .user-chip .u-role{font-size:.7rem;color:var(--tg-text-muted);}

.sidebar-toggle-btn{display:none;}

.content-area{
  padding:1.4rem;
  flex:1 1 auto;
}

/* ---------------- Cards / KPI ---------------- */
.kpi-card,.panel-card{
  background:var(--tg-card-bg);
  border:1px solid var(--tg-border);
  border-radius:12px;
  padding:1rem 1.1rem;
  height:100%;
}
.kpi-card .kpi-label{font-size:.74rem;color:var(--tg-text-muted);text-transform:uppercase;letter-spacing:.03em;font-weight:600;}
.kpi-card .kpi-value{font-size:1.7rem;font-weight:700;color:var(--tg-navy);line-height:1.15;margin-top:.15rem;}
.kpi-card .kpi-sub{font-size:.76rem;color:var(--tg-text-muted);margin-top:.2rem;}
.kpi-card .kpi-icon{
  width:38px;height:38px;border-radius:9px;
  display:flex;align-items:center;justify-content:center;
  font-size:1rem;
}

.panel-card .panel-head{
  display:flex;align-items:center;justify-content:space-between;
  margin-bottom:.75rem;
}
.panel-card .panel-head h6{margin:0;font-weight:700;color:var(--tg-navy);font-size:.9rem;}
.chart-toggle .btn{padding:.15rem .5rem;font-size:.72rem;}

/* ---------------- Nav pills (tabs de estado) ---------------- */
.nav-pills .nav-link{color:var(--tg-navy);}
.nav-pills .nav-link.active,
.nav-pills .show > .nav-link{
  background-color:var(--tg-navy);
  color:#fff;
}

/* ---------------- Status badges ---------------- */
.badge-status{
  font-size:.72rem;
  font-weight:700;
  padding:.32rem .6rem;
  border-radius:20px;
  display:inline-flex;align-items:center;gap:.35rem;
}
.badge-status::before{content:"";width:7px;height:7px;border-radius:50%;background:currentColor;}
.badge-confirmado{color:var(--st-confirmado);background:var(--st-confirmado-bg);}
.badge-pendiente{color:var(--st-pendiente);background:var(--st-pendiente-bg);}
.badge-cancelado{color:var(--st-cancelado);background:var(--st-cancelado-bg);}
.badge-reprogramado{color:var(--st-reprogramado);background:var(--st-reprogramado-bg);}

/* ---------------- Tables ---------------- */
.table-tms{background:#fff;}
.table-tms thead th{
  background:#f8fafc;
  font-size:.72rem;
  text-transform:uppercase;
  letter-spacing:.03em;
  color:var(--tg-text-muted);
  font-weight:700;
  border-bottom:1px solid var(--tg-border);
  white-space:nowrap;
}
.table-tms td{vertical-align:middle;font-size:.85rem;}
.table-tms tbody tr:hover{background:#f8fafc;}
.table-tms tbody tr.tr-highlight{background:var(--tg-blue-light);transition:background .3s ease;}

.zone-pill{
  display:inline-block;padding:.15rem .55rem;border-radius:20px;font-size:.72rem;font-weight:600;
}
.zone-Norte{background:#e8f0fe;color:#1d4ed8;}
.zone-Oriente{background:#fdf1e7;color:#c2410c;}
.zone-Sur{background:#eafaf0;color:#15803d;}
.zone-Poniente-Centro{background:#f3e8fd;color:#7e22ce;}

/* ---------------- Misc ---------------- */
.card-filter-bar{
  background:#fff;border:1px solid var(--tg-border);border-radius:12px;
  padding:.8rem 1rem;margin-bottom:1.1rem;
}
.section-title{font-weight:700;color:var(--tg-navy);font-size:1rem;margin-bottom:.9rem;}
.avatar-sm{
  width:30px;height:30px;border-radius:50%;
  background:var(--tg-blue-light);color:var(--tg-navy);
  display:flex;align-items:center;justify-content:center;font-weight:700;font-size:.72rem;
}
.tech-agenda-col{border-left:3px solid var(--tg-border);padding-left:.7rem;}
.mini-cal-day{
  aspect-ratio:1/1;border:1px solid var(--tg-border);border-radius:8px;
  padding:.3rem;font-size:.72rem;background:#fff;cursor:pointer;
}
.mini-cal-day.today{border-color:var(--tg-accent);border-width:2px;}
.mini-cal-day.selected{background:var(--tg-blue-light);border-color:var(--tg-blue);}
.mini-cal-day .d-num{font-weight:700;color:var(--tg-navy);}
.mini-cal-day .d-count{font-size:.66rem;color:var(--tg-text-muted);}

#map{height:calc(100vh - 230px);min-height:420px;border-radius:12px;overflow:hidden;z-index:1;}
.map-legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block;margin-right:.35rem;}

.alert-reagenda{border-left:4px solid var(--st-cancelado);}

.servicio-bloque{
  background:#f8fafc;
  border:1px solid var(--tg-border);
  border-radius:10px;
  padding:.9rem 1rem;
  margin-bottom:.9rem;
}
.servicio-bloque .servicio-titulo{
  font-size:.72rem;font-weight:700;color:var(--tg-navy);
  text-transform:uppercase;letter-spacing:.03em;
}

/* ---------------- Calendario de técnicos (Seguimiento) ---------------- */
.tcal-outer{
  overflow:auto;
  max-height:460px;
  border:1px solid var(--tg-border);
  border-radius:10px;
  position:relative;
}
.tcal-row{
  display:flex;
  min-height:86px;
  border-bottom:1px solid var(--tg-border);
}
.tcal-row:last-child{border-bottom:none;}
.tcal-row.tcal-header{
  position:sticky;top:0;z-index:5;
  background:#fff;
  min-height:32px;
  border-bottom:1px solid var(--tg-border);
}
.tcal-label{
  flex:0 0 auto;
  position:sticky;left:0;z-index:2;
  background:#fff;
  display:flex;align-items:center;gap:.5rem;
  padding:.4rem .7rem;
  border-right:1px solid var(--tg-border);
}
.tcal-header .tcal-label{
  z-index:6;
  font-weight:700;font-size:.72rem;color:var(--tg-text-muted);
  text-transform:uppercase;letter-spacing:.03em;
}
.tcal-tecnico-nombre{font-size:.82rem;font-weight:700;color:var(--tg-navy);line-height:1.15;}
.tcal-tecnico-zona{font-size:.7rem;color:var(--tg-text-muted);}
.tcal-track{position:relative;flex:0 0 auto;}
.tcal-hour-label{
  position:absolute;top:0;bottom:0;
  display:flex;align-items:center;
  padding-left:.35rem;
  font-size:.7rem;color:var(--tg-text-muted);font-weight:600;
  border-left:1px solid var(--tg-border);
}
.tcal-block{
  position:absolute;top:6px;bottom:6px;
  border-radius:6px;
  padding:.2rem .45rem;
  overflow:hidden;
  cursor:pointer;
  display:flex;flex-direction:column;justify-content:center;
  line-height:1.15;
  border:1px solid rgba(0,0,0,.08);
  box-shadow:0 1px 2px rgba(0,0,0,.08);
  transition:filter .15s;
}
.tcal-block:hover{filter:brightness(.96);}
.tcal-block strong{font-size:.72rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.tcal-block span{font-size:.66rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;opacity:.85;display:block;}
.tcal-block .tcal-block-atraso-label{font-weight:700;opacity:1;}
.tcal-block-pendiente{background:var(--st-pendiente-bg);color:var(--st-pendiente);}
.tcal-block-confirmado{background:var(--st-confirmado-bg);color:var(--st-confirmado);}
.tcal-block-cancelado{background:var(--st-cancelado-bg);color:var(--st-cancelado);}
.tcal-block-reprogramado{background:var(--st-reprogramado-bg);color:var(--st-reprogramado);}
.tcal-block-atraso{
  background:#dc2626;color:#fff;border:1px solid #b91c1c;
  animation:tcal-atraso-pulse 1.6s ease-in-out infinite;
}
.tcal-block-atraso span{opacity:1;}
@keyframes tcal-atraso-pulse{
  0%,100%{box-shadow:0 0 0 0 rgba(220,38,38,.55);}
  50%{box-shadow:0 0 0 4px rgba(220,38,38,0);}
}
.tcal-nowline{
  position:absolute;top:0;bottom:0;
  width:2px;background:#dc2626;
  z-index:4;
  pointer-events:none;
}
.tcal-nowline::before{
  content:"";
  position:absolute;top:-4px;left:-4px;
  width:10px;height:10px;border-radius:50%;
  background:#dc2626;
}

@media (max-width: 991.98px){
  .sidebar{transform:translateX(-100%);}
  .sidebar.open{transform:translateX(0);}
  .main-col{margin-left:0;width:100%;}
  .sidebar-toggle-btn{display:inline-flex;}
}
