/* RuteaLog — estilos base */

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

:root {
    --color-primario: #2563eb;
    --color-primario-hover: #1d4ed8;
    --color-fondo: #f1f5f9;
    --color-card: #ffffff;
    --color-texto: #1e293b;
    --color-texto-suave: #64748b;
    --color-borde: #e2e8f0;
    --color-error: #dc2626;
    --color-exito: #16a34a;
    --radio: 8px;
    --sombra: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --sombra-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

body { font-family: system-ui, -apple-system, sans-serif; color: var(--color-texto); background: var(--color-fondo); }

/* ── Layout con navbar + sidebar ── */
.app-layout { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.navbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem; height: 56px; flex-shrink: 0;
    background: var(--color-primario); color: #fff;
    box-shadow: var(--sombra); z-index: 100;
}
.navbar-brand a { color: #fff; text-decoration: none; font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.logo-icon { font-size: .9rem; }
.navbar-menu { display: flex; align-items: center; gap: 1rem; }
.navbar-user { font-size: .9rem; opacity: .85; }
.btn-nav { color: #fff; text-decoration: none; font-size: .9rem; border: 1px solid rgba(255,255,255,.4); padding: .3rem .8rem; border-radius: var(--radio); transition: background .15s; }
.btn-nav:hover { background: rgba(255,255,255,.15); }

.app-body { display: flex; flex: 1; overflow: hidden; min-height: 0; }

/* ── Sidebar ── */
.sidebar { width: 220px; height: 100%; background: #1e293b; padding: 1rem 0; flex-shrink: 0; overflow-y: auto; }
.sidebar-section { margin-bottom: .25rem; }
.sidebar-label { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: none; cursor: pointer; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: .45rem 1.25rem .35rem; transition: color .12s; }
.sidebar-label:hover { color: #94a3b8; }
.sidebar-chevron { font-size: .6rem; transition: transform .2s; display: inline-block; }
.sidebar-section.collapsed .sidebar-chevron { transform: rotate(-90deg); }
.sidebar-items { overflow: hidden; max-height: 500px; transition: max-height .22s ease, opacity .18s ease; opacity: 1; }
.sidebar-section.collapsed .sidebar-items { max-height: 0; opacity: 0; }
.sidebar-link { display: block; padding: .55rem 1.25rem; color: #94a3b8; text-decoration: none; font-size: .9rem; transition: background .12s, color .12s; border-left: 3px solid transparent; }
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.sidebar-link.active { background: rgba(37,99,235,.2); color: #93c5fd; border-left-color: #3b82f6; }

/* main-content: flex column, sin scroll propio — cada página controla su scroll */
.main-content { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

/* Flash messages: fixed sobre cualquier capa (mapa, modales) */
.flash-zone { position: fixed; top: 56px; left: 0; right: 0; z-index: 9999; padding: 0 1.5rem; pointer-events: none; }
.flash-zone .message { pointer-events: auto; }

/* Contenido scrolleable para páginas normales */
.page-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 2rem 1.5rem; }

/* ── Split layout: panel fijo + tabla scrolleable ── */
.panel-fijo {
    flex-shrink: 0;
    padding: 1.25rem 1.5rem .75rem;
    background: #fff;
    border-bottom: 1px solid var(--color-borde);
}
.panel-scroll {
    flex: 1;
    overflow: auto;
    min-height: 0;
    background: #fff;
    /* sin padding-top: la tabla arranca pegada al borde del panel-fijo */
    padding: 0 0 1.5rem;
}

/* thead sticky dentro del panel-scroll: se fija al llegar al borde superior */
.panel-scroll .pedidos-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;   /* igual que .table th normal */
    z-index: 10;
    box-shadow: 0 2px 0 var(--color-borde);  /* replica el border-bottom cuando pegado */
}

/* paginación con margen dentro del panel */
.panel-scroll .pagination { padding: .75rem 1rem 0; }

/* ── Layout login ── */
.login-layout {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--color-primario);
}
.login-container { width: 100%; max-width: 400px; padding: 1rem; }
.login-card {
    background: var(--color-card); border-radius: 12px;
    padding: 2.5rem 2rem; box-shadow: var(--sombra-md);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo h1 { font-size: 1.8rem; color: var(--color-primario); margin: .5rem 0 .25rem; }
.login-logo .logo-icon { font-size: 2rem; color: var(--color-primario); }
.login-logo p { color: var(--color-texto-suave); font-size: .9rem; }

/* ── Formularios ── */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .4rem; color: var(--color-texto); }
.form-input {
    width: 100%; padding: .65rem .85rem;
    border: 1px solid var(--color-borde); border-radius: var(--radio);
    font-size: 1rem; transition: border-color .15s, box-shadow .15s;
    background: #fff; color: var(--color-texto);
}
.form-input:focus { outline: none; border-color: var(--color-primario); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

/* ── Botones ── */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .7rem 1.5rem; background: var(--color-primario); color: #fff;
    border: none; border-radius: var(--radio); font-size: 1rem; font-weight: 500;
    cursor: pointer; transition: background .15s;
    text-decoration: none;
}
.btn-primary:hover { background: var(--color-primario-hover); }
.btn-block { width: 100%; }

/* ── Flash messages ── */
.message { padding: .75rem 1rem; border-radius: var(--radio); margin-bottom: 1rem; font-size: .9rem; }
.message.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.message.error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.message.warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.message.info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Navbar extras ── */
.badge-rol { font-size: .7rem; background: rgba(255,255,255,.2); padding: .15rem .4rem; border-radius: 4px; margin-left: .4rem; }

/* ── Cards ── */
.card { background: var(--color-card); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; margin-bottom: 1.5rem; padding: 1.25rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-borde); margin: -1.25rem -1.25rem 1.25rem; }
.card-header h3 { margin: 0; font-size: 1rem; }
.form-card { padding: 1.5rem; }
.detail-grid { display: grid; grid-template-columns: 320px 1fr; gap: 1.5rem; }
.detail-card { padding: 1.25rem; }

/* ── Page header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.4rem; }
.header-actions { display: flex; gap: .5rem; }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; font-weight: 600; color: var(--color-texto-suave); text-transform: uppercase; letter-spacing: .05em; padding: .75rem 1rem; border-bottom: 2px solid var(--color-borde); background: #f8fafc; }
.table td { padding: .7rem 1rem; border-bottom: 1px solid var(--color-borde); font-size: .9rem; vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; }
.row-inactivo td { opacity: .5; }
.text-suave { color: var(--color-texto-suave); font-size: .85rem; display: block; }
td.text-suave { display: table-cell; }
.text-center { text-align: center; }
td small.text-suave { margin-top: .15rem; }
.actions { white-space: nowrap; text-align: right; }

/* ── Detail list ── */
.detail-list { display: grid; grid-template-columns: 140px 1fr; gap: .5rem .75rem; font-size: .9rem; margin: 0; }
.detail-list dt { color: var(--color-texto-suave); font-weight: 500; align-self: center; }
.detail-list dd { margin: 0; align-self: center; }

/* ── Badges ── */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-ok  { background: #dcfce7; color: #166534; }
.badge-off { background: #f1f5f9; color: #64748b; }
.plan-trial      { background: #fef9c3; color: #854d0e; }
.plan-starter    { background: #dbeafe; color: #1e40af; }
.plan-pro        { background: #ede9fe; color: #5b21b6; }
.plan-enterprise { background: #fce7f3; color: #9d174d; }
.rol-admin       { background: #fee2e2; color: #991b1b; }
.rol-planificador{ background: #dbeafe; color: #1e40af; }
.rol-supervisor  { background: #f0fdf4; color: #166534; }
.rol-superadmin  { background: #1e293b; color: #93c5fd; }

/* ── Buttons ── */
.btn-secondary { display: inline-flex; align-items: center; padding: .55rem 1rem; background: #fff; color: var(--color-texto); border: 1px solid var(--color-borde); border-radius: var(--radio); font-size: .9rem; text-decoration: none; cursor: pointer; transition: background .15s; }
.btn-secondary:hover { background: #f8fafc; }
.btn-sm { display: inline-block; padding: .3rem .7rem; font-size: .8rem; border-radius: 6px; border: 1px solid var(--color-borde); text-decoration: none; cursor: pointer; background: #fff; color: var(--color-texto); transition: background .12s; }
.btn-sm:hover { background: #f1f5f9; }
.btn-sm.btn-danger  { border-color: #fca5a5; color: var(--color-error); padding: .3rem .7rem; font-size: .8rem; display: inline-block; }
.btn-sm.btn-success { border-color: #86efac; color: var(--color-exito); padding: .3rem .7rem; font-size: .8rem; display: inline-block; }
.btn-sm.btn-primary { background: var(--color-primario); color: #fff; border-color: var(--color-primario); }
.btn-danger { display: inline-flex; align-items: center; padding: .55rem 1rem; background: #fff; color: var(--color-error); border: 1px solid #fca5a5; border-radius: var(--radio); font-size: .9rem; cursor: pointer; transition: background .15s; }
.btn-danger:hover { background: #fff1f2; }

/* ── Form layout ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group-check { display: flex; align-items: center; gap: .5rem; padding-top: 1.75rem; }
.form-check { width: 1rem; height: 1rem; cursor: pointer; }
.form-actions { display: flex; align-items: center; gap: .75rem; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--color-borde); }
.form-group .error-message { color: var(--color-error); font-size: .8rem; margin-top: .25rem; display: block; }
select.form-input { appearance: auto; }

/* ── Pagination ── */
.pagination { display: flex; gap: .4rem; justify-content: center; margin-top: 1.5rem; }
.pagination a, .pagination span { padding: .4rem .75rem; border: 1px solid var(--color-borde); border-radius: 6px; font-size: .85rem; text-decoration: none; color: var(--color-texto); }
.pagination .current { background: var(--color-primario); color: #fff; border-color: var(--color-primario); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* Flash dentro de login card */
.login-card .message { margin-bottom: 1rem; }

/* ── Dashboard placeholder ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem; }
.page-header h2 { font-size: 1.5rem; color: var(--color-texto); margin: 0; }
.header-actions { display: flex; gap: .5rem; }
.dashboard-placeholder { background: var(--color-card); border-radius: var(--radio); padding: 2rem; box-shadow: var(--sombra); }

/* ── Importaciones ── */
.import-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .import-layout { grid-template-columns: 1fr; } }

.upload-zone { border: 2px dashed var(--color-borde); border-radius: var(--radio); padding: 2.5rem 1.5rem; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; position: relative; }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--color-primario); background: #f0f5ff; }
.upload-zone.has-file { border-color: var(--color-exito); background: #f0faf4; }
.upload-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.upload-link { color: var(--color-primario); cursor: pointer; text-decoration: underline; }
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-name-display { margin-top: .75rem; font-size: .9rem; color: var(--color-exito); font-weight: 500; }

.import-help .table-compact td, .import-help .table-compact th { padding: .35rem .5rem; font-size: .82rem; }

/* ── Resultado de importación ── */
.result-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; padding: 1.5rem; border-radius: var(--radio); }
.result-ok  { background: #f0faf4; border: 1px solid #86efac; }
.result-warn { background: #fff8ed; border: 1px solid #fcd34d; }
.result-stat { text-align: center; }
.stat-num { display: block; font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--color-suave); text-transform: uppercase; letter-spacing: .05em; }
@media (max-width: 700px) { .result-summary { grid-template-columns: 1fr 1fr; } }

.row-error { background: #fff5f5 !important; }
.text-center { text-align: center; }
.text-exito { color: var(--color-exito); }
.text-error { color: var(--color-error); }
.text-suave { color: var(--color-suave); }

.badge-ok         { background: #d1fae5; color: #065f46; }
.badge-warn       { background: #fef9c3; color: #92400e; }
.badge-off        { background: #fee2e2; color: #991b1b; }
.badge-info       { background: #dbeafe; color: #1e40af; }
.badge-pendiente  { background: #e0e7ff; color: #3730a3; }
.badge-asignado   { background: #fef9c3; color: #854d0e; }
.badge-en-ruta    { background: #dbeafe; color: #1e40af; }
.card-header      { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

/* ── Pedidos ── */
.estado-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.estado-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .85rem; border: 1px solid var(--color-borde); border-radius: 99px; font-size: .85rem; text-decoration: none; color: var(--color-texto); background: #fff; transition: border-color .15s, background .15s; }
.estado-chip:hover { border-color: var(--color-primario); background: #f0f5ff; }
.estado-chip.active { background: var(--color-primario); color: #fff; border-color: var(--color-primario); }
.chip-count { font-size: .75rem; background: rgba(0,0,0,.1); border-radius: 99px; padding: 0 .4rem; min-width: 1.4rem; text-align: center; }
.estado-chip.active .chip-count { background: rgba(255,255,255,.25); }

.filtros-card { padding: 1rem 1.25rem; margin-bottom: 1.25rem; }
.filtros-form { margin: 0; }
.filtros-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.filtro-busqueda { flex: 1; min-width: 200px; }
.filtros-row .form-input { margin: 0; }

.pedidos-table .col-num { text-align: right; white-space: nowrap; }
.pedidos-table .col-fecha { white-space: nowrap; }
.pedidos-table .acciones-cell { white-space: nowrap; text-align: right; }
.ventana-cell { white-space: nowrap; }
.ventana-tag { display: inline-block; font-size: .75rem; background: #e0e7ff; color: #3730a3; border-radius: 4px; padding: .1rem .45rem; margin-right: .25rem; white-space: nowrap; }
.ventana-tag-lg { font-size: .9rem; padding: .3rem .75rem; margin-right: .4rem; }
.cliente-nombre { font-weight: 500; }
.cliente-cod { font-size: .8rem; font-family: monospace; }
.mono { font-family: monospace; font-size: .9rem; }

/* ── Detalle pedido ── */
.detalle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 800px) { .detalle-grid { grid-template-columns: 1fr; } }
.card-title { font-size: 1rem; font-weight: 600; margin: 0 0 1rem; color: var(--color-suave); text-transform: uppercase; letter-spacing: .05em; }
.dl-detalle { display: grid; grid-template-columns: auto 1fr; gap: .35rem .75rem; font-size: .9rem; margin: 0; }
.dl-detalle dt { color: var(--color-suave); font-weight: 500; white-space: nowrap; }
.dl-detalle dd { margin: 0; }
.estado-acciones { display: flex; gap: .5rem; flex-wrap: wrap; }

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

/* ── Flota: skill pills ── */
.form-section-title { font-size: .8rem; font-weight: 600; color: var(--color-texto-suave); text-transform: uppercase; letter-spacing: .05em; margin: 1.5rem 0 .75rem; padding-bottom: .5rem; border-bottom: 1px solid var(--color-borde); }
.skills-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.skill-pill { position: relative; }
.skill-pill input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.skill-pill label { display: inline-flex; align-items: center; padding: .35rem .85rem; border: 1px solid var(--color-borde); border-radius: 99px; font-size: .85rem; cursor: pointer; transition: all .12s; background: #fff; color: var(--color-texto); user-select: none; }
.skill-pill label:hover { border-color: var(--color-primario); background: #f0f5ff; }
.skill-pill input:checked + label { background: var(--color-primario); color: #fff; border-color: var(--color-primario); }
.skill-pill input:checked + label:hover { background: var(--color-primario-hover); }

/* ── Ruteo ── */
.ruteo-grid { display: grid; grid-template-columns: 340px 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .ruteo-grid { grid-template-columns: 1fr; } }
.card-header-line { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
/* Tabla edge-to-edge dentro de .card: cancela el padding del card */
.card-table { margin: 0 -1.25rem -1.25rem; overflow-x: auto; }
.card-table .table { margin: 0; }
/* Tabla como unico hijo directo de card (listas ABMC sin header): edge-to-edge */
.card > .table { margin: 0 -1.25rem -1.25rem; width: calc(100% + 2.5rem); }
.vehiculo-list { display: flex; flex-direction: column; gap: .5rem; }
.vehiculo-row { display: flex; align-items: flex-start; gap: .6rem; padding: .6rem .4rem; border-radius: var(--radio); cursor: pointer; transition: background .1s; }
.vehiculo-row:hover { background: #f8fafc; }
.vehiculo-row input[type="checkbox"] { margin-top: .15rem; flex-shrink: 0; }
.vehiculo-info { display: flex; flex-direction: column; gap: .15rem; }
.ventana-tag { display: inline-block; font-size: .78rem; color: var(--color-texto-suave); background: #f1f5f9; border-radius: 4px; padding: .1rem .4rem; }
.stats-row { display: flex; flex-wrap: wrap; gap: 1.25rem 2rem; }
.stat-item { display: flex; flex-direction: column; gap: .2rem; }
.stat-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--color-texto-suave); }
.stat-value { font-size: 1.25rem; font-weight: 700; }
.dot-color { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.alert-warning { background: #fef9c3; border: 1px solid #fde047; border-radius: var(--radio); padding: .6rem .9rem; font-size: .88rem; color: #713f12; }
.filtros-inline .form-row { flex-wrap: nowrap; }
.btn-lg { padding: .65rem 1.5rem; font-size: 1rem; }

/* ── Modal genérico ── */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:1000; display:flex; align-items:center; justify-content:center; }
.modal-box { background:#fff; border-radius:var(--radio); box-shadow:var(--sombra-md); display:flex; flex-direction:column; max-height:90vh; }
.modal-header { display:flex; align-items:center; justify-content:space-between; padding:.9rem 1.1rem; border-bottom:1px solid var(--color-borde); }
.modal-body { flex:1; overflow-y:auto; padding:1rem 1.1rem; }
.modal-footer { display:flex; justify-content:flex-end; gap:.6rem; padding:.75rem 1.1rem; border-top:1px solid var(--color-borde); }
.modal-cerrar { background:none; border:none; cursor:pointer; font-size:1.1rem; color:var(--color-texto-suave); line-height:1; padding:.2rem .4rem; border-radius:4px; }
.modal-cerrar:hover { background:#f1f5f9; }
.btn-warn-coords { background:#dc2626; color:#fff; border:none; cursor:pointer; font-size:.72rem; font-weight:700; padding:.15rem .4rem; border-radius:4px; line-height:1.4; vertical-align:middle; letter-spacing:.02em; }
.btn-warn-coords:hover { background:#b91c1c; }
tr.fila-sin-coords { background:#fef3c7 !important; }
tr.fila-sin-coords:hover { background:#fde68a !important; }

/* ── Estrategia de optimización ── */
.estrategia-opcion { display:flex; align-items:flex-start; gap:.6rem; flex:1; min-width:200px; padding:.65rem .75rem; border-radius:var(--radio); border:2px solid var(--color-borde); cursor:pointer; transition:border-color .15s,background .15s; }
.estrategia-opcion:has(input:checked) { border-color:var(--color-primario); background:#eef2ff; }
.estrategia-opcion input[type="radio"] { margin-top:.2rem; flex-shrink:0; accent-color:var(--color-primario); }
.estrategia-body { display:flex; flex-direction:column; gap:.2rem; }
.estrategia-body strong { font-size:.9rem; }
.estrategia-body span { font-size:.8rem; color:var(--color-texto-suave); line-height:1.35; }

/* ── Ruteo ver — split layout ── */
.ruteo-ver-layout { display:flex; flex:1; min-height:0; overflow:hidden; }
.ruteo-rutas-panel { width:400px; flex-shrink:0; overflow-y:auto; background:var(--color-fondo); border-right:1px solid var(--color-borde); padding:.75rem; }
.ruteo-mapa-panel { flex:1; min-width:0; position:relative; }
.ruta-card { background:#fff; border-radius:var(--radio); padding:.65rem .75rem; margin-bottom:.6rem; cursor:pointer; border-left:4px solid transparent; transition:box-shadow .15s,border-color .15s; }
.ruta-card:hover { box-shadow:var(--sombra-md); }
.ruta-card-activa { box-shadow:var(--sombra-md); }
.ruta-card-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:.4rem; }

.btn-link-small {
    background: none;
    border: none;
    color: var(--color-primario);
    font-size: .8rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.btn-link-small:hover { opacity: .75; }

@keyframes spin { to { transform: rotate(360deg); } }




