/*
 * Capa visual compartida del ERP.
 *
 * Mantiene Bootstrap como base y normaliza únicamente medidas, estados y
 * ritmo visual. Los colores semánticos (éxito, peligro, aviso, información)
 * siguen siendo los de Bootstrap para no cambiar el significado de acciones.
 */
:root {
    --gestion-color-surface: #ffffff;
    --gestion-color-canvas: #f5f7fa;
    --gestion-color-border: #d8dee7;
    --gestion-color-text: #1f2937;
    --gestion-color-muted: #667085;
    --gestion-color-focus: rgba(13, 110, 253, .28);
    --gestion-radius-sm: .375rem;
    --gestion-radius: .625rem;
    --gestion-radius-lg: .875rem;
    --gestion-control-height-sm: 2.125rem;
    --gestion-control-height: 2.625rem;
    --gestion-control-height-lg: 3rem;
    --gestion-shadow-card: 0 .125rem .35rem rgba(31, 41, 55, .08);
}

.gestion-app-shell {
    min-width: 320px;
    color: var(--gestion-color-text);
    background: var(--gestion-color-canvas) !important;
    line-height: 1.5;
}

.gestion-app-shell .navbar-brand {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    font-size: clamp(1.05rem, 1.6vw, 1.35rem);
    line-height: 1.2;
}

.gestion-app-shell--office .gestion-office-navbar {
    z-index: 1030;
}

.corephia-brand {
    min-width: 0;
    gap: .55rem;
}

.corephia-brand__symbol {
    width: 2.8rem;
    height: auto;
    flex: 0 0 auto;
    color: #fff;
}

.corephia-auth-symbol {
    width: 7.75rem;
    height: auto;
    color: #fff;
}

.corephia-brand__name {
    letter-spacing: .055em;
}

.corephia-brand__tenant {
    max-width: min(31vw, 25rem);
    padding-left: .7rem;
    border-left: 1px solid rgba(255, 255, 255, .35);
    overflow: hidden;
    color: rgba(255, 255, 255, .88);
    font-size: .86em;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 991.98px) {
    .gestion-app-shell--office .gestion-office-navbar .navbar-collapse {
        max-height: calc(100vh - 4.5rem);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (max-width: 575.98px) {
    .corephia-brand__symbol {
        width: 2.35rem;
    }

    .corephia-brand__tenant {
        display: none;
    }
}

.gestion-app-shell h1,
.gestion-app-shell .h1 {
    letter-spacing: -.015em;
}

.gestion-app-shell h1.h3,
.gestion-app-shell .h3.fw-bold {
    font-size: clamp(1.55rem, 2.4vw, 2rem);
    line-height: 1.18;
}

.gestion-app-shell .text-muted,
.gestion-app-shell .form-text {
    color: var(--gestion-color-muted) !important;
}

/* Formularios: misma altura, borde y foco en todas las áreas Bootstrap. */
.gestion-app-shell .form-label {
    margin-bottom: .4rem;
    color: #344054;
    font-weight: 600;
}

.gestion-app-shell .form-control,
.gestion-app-shell .form-select {
    min-height: var(--gestion-control-height);
    border-color: var(--gestion-color-border);
    border-radius: var(--gestion-radius-sm);
    color: var(--gestion-color-text);
}

.gestion-app-shell .form-control-sm,
.gestion-app-shell .form-select-sm {
    min-height: var(--gestion-control-height-sm);
}

.gestion-app-shell .form-control-lg,
.gestion-app-shell .form-select-lg {
    min-height: var(--gestion-control-height-lg);
    font-size: 1rem;
}

.gestion-app-shell textarea.form-control {
    min-height: 6rem;
}

.gestion-app-shell .form-control:focus,
.gestion-app-shell .form-select:focus,
.gestion-app-shell .form-check-input:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 .2rem var(--gestion-color-focus);
}

.gestion-app-shell .form-control:disabled,
.gestion-app-shell .form-select:disabled,
.gestion-app-shell .form-control[readonly] {
    color: #475467;
    background-color: #eef1f5;
    opacity: 1;
}

.gestion-app-shell .form-check-input {
    width: 1.15rem;
    height: 1.15rem;
    border-color: #98a2b3;
}

.gestion-app-shell .invalid-feedback,
.gestion-app-shell .text-danger.small {
    margin-top: .35rem;
    font-weight: 600;
}

/* Acciones: misma huella táctil y alineación sin alterar su semántica. */
.gestion-app-shell .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    gap: .4rem;
    border-radius: var(--gestion-radius-sm);
    font-weight: 600;
    line-height: 1.2;
}

.gestion-app-shell .btn-sm {
    min-height: 2.125rem;
    padding: .35rem .7rem;
    font-size: .875rem;
}

.gestion-app-shell .btn-lg {
    min-height: 3rem;
    padding-inline: 1.15rem;
    font-size: 1rem;
}

.gestion-app-shell .btn:focus-visible,
.gestion-app-shell a:focus-visible,
.gestion-app-shell summary:focus-visible {
    outline: 3px solid var(--gestion-color-focus);
    outline-offset: 2px;
}

.gestion-app-shell .btn:disabled,
.gestion-app-shell .btn.disabled {
    cursor: not-allowed;
    opacity: .62;
}

/* Contenedores, tablas y avisos. */
.gestion-app-shell .card {
    border-color: var(--gestion-color-border);
    border-radius: var(--gestion-radius);
    background: var(--gestion-color-surface);
}

.gestion-app-shell .card.shadow-sm,
.gestion-app-shell .card.shadow {
    box-shadow: var(--gestion-shadow-card) !important;
}

.gestion-app-shell .card-header {
    padding: .85rem 1rem;
    border-bottom-color: var(--gestion-color-border);
    border-radius: var(--gestion-radius) var(--gestion-radius) 0 0 !important;
}

.gestion-app-shell .card-body {
    padding: 1rem;
}

.gestion-app-shell .alert {
    padding: .9rem 1rem;
    border-radius: var(--gestion-radius);
    line-height: 1.45;
}

.gestion-app-shell .table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.gestion-app-shell .table > :not(caption) > * > * {
    padding: .75rem .7rem;
    border-bottom-color: #e4e7ec;
}

.gestion-app-shell .table thead th {
    color: #344054;
    font-size: .82rem;
    font-weight: 750;
    letter-spacing: .015em;
    vertical-align: bottom;
}

.gestion-app-shell .table tbody tr:last-child > * {
    border-bottom-width: 0;
}

.gestion-app-shell .badge {
    padding: .42em .65em;
    border-radius: 999px;
    font-weight: 700;
}

.gestion-app-shell .pagination .page-link {
    min-width: 2.5rem;
    min-height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Cabeceras compuestas que se repiten en formularios, listados y detalles. */
.gestion-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.gestion-page-header__title {
    margin-bottom: .25rem;
    font-size: clamp(1.55rem, 2.4vw, 2rem);
    font-weight: 750;
    line-height: 1.18;
}

.gestion-page-header__subtitle {
    margin-bottom: 0;
    color: var(--gestion-color-muted);
}

.gestion-page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
}

.gestion-confirmation-card {
    max-width: 56.25rem;
}

.gestion-col-cantidad,
.gestion-col-iva {
    width: 14%;
}

.gestion-col-precio {
    width: 18%;
}

.gestion-col-eliminar {
    width: 8%;
}

/* Componentes operativos del conductor. */
.gestion-driver-balance,
.gestion-driver-action {
    font-size: .95rem;
}

.gestion-driver-action {
    border-radius: .5rem;
}

.gestion-driver-mode {
    border-radius: .9375rem;
}

.gestion-route-map {
    width: 100%;
    height: 18.75rem;
    border-radius: 0 0 var(--gestion-radius-sm) var(--gestion-radius-sm);
}

.gestion-route-order {
    z-index: 10;
    font-size: 1rem;
}

.gestion-map-popup {
    min-width: 9.375rem;
    padding: .3125rem;
    color: #111827;
}

.gestion-meta-label {
    font-size: .65rem;
}

.gestion-meta-value {
    font-size: .8rem;
}

.gestion-notes-label {
    font-size: .6rem;
}

/* Acceso y recuperación de clave. */
.gestion-auth-container {
    min-height: min(70vh, 720px);
}

.gestion-auth-card {
    overflow: hidden;
    border: 0;
    border-radius: var(--gestion-radius-lg);
}

.gestion-auth-icon {
    width: 3rem;
    height: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    font-size: 1.35rem;
}

.gestion-auth-card form p {
    display: grid;
    gap: .4rem;
    margin-bottom: 1rem;
}

.gestion-auth-card form p > label {
    color: #344054;
    font-weight: 600;
}

.gestion-auth-card form input:not([type="hidden"]),
.gestion-auth-card form select,
.gestion-auth-card form textarea {
    width: 100%;
    min-height: var(--gestion-control-height);
    padding: .5rem .75rem;
    border: 1px solid var(--gestion-color-border);
    border-radius: var(--gestion-radius-sm);
    color: var(--gestion-color-text);
    background: var(--gestion-color-surface);
}

.gestion-auth-card form input:not([type="hidden"]):focus,
.gestion-auth-card form select:focus,
.gestion-auth-card form textarea:focus {
    outline: 0;
    border-color: #86b7fe;
    box-shadow: 0 0 0 .2rem var(--gestion-color-focus);
}

/* Ayuda contextual reutilizable en oficina, conductor y administración. */
.gestion-help-backdrop[hidden] {
    display: none;
}

.gestion-help-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    justify-content: flex-end;
    background: rgba(15, 23, 42, .62);
}

.gestion-help-open {
    overflow: hidden;
}

.gestion-help-panel {
    width: min(520px, 96vw);
    height: 100vh;
    overflow: auto;
    border-left: 1px solid rgba(148, 163, 184, .35);
    background: #0f172a;
    color: #e5e7eb;
    box-shadow: -18px 0 40px rgba(0, 0, 0, .35);
}

.gestion-help-panel__header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.4rem;
    border-bottom: 1px solid rgba(148, 163, 184, .24);
    background: #111827;
}

.gestion-help-panel__header h2 {
    margin: .2rem 0 .3rem;
    color: #f9fafb;
    font-size: 1.45rem;
}

.gestion-help-panel__header p,
.gestion-help-panel__count {
    margin: 0;
    color: #9ca3af;
    font-size: .78rem;
    font-weight: 600;
}

.gestion-help-panel__eyebrow {
    color: #93c5fd;
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.gestion-help-panel__close {
    width: 2.5rem;
    height: 2.5rem;
    flex: 0 0 2.5rem;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: var(--gestion-radius-sm);
    background: #1f2937;
    color: #f9fafb;
    cursor: pointer;
    font-size: 1.1rem;
}

.gestion-help-panel__tools {
    position: sticky;
    top: 5.7rem;
    z-index: 2;
    display: grid;
    gap: .55rem;
    padding: .8rem 1.2rem;
    border-bottom: 1px solid rgba(148, 163, 184, .24);
    background: #0f172a;
}

.gestion-help-search {
    position: relative;
}

.gestion-help-search .bi {
    position: absolute;
    top: 50%;
    left: .75rem;
    transform: translateY(-50%);
    color: #93c5fd;
    pointer-events: none;
}

.gestion-help-search input {
    width: 100%;
    min-height: 2.5rem;
    padding: .5rem .75rem .5rem 2.35rem;
    border: 1px solid rgba(147, 197, 253, .42);
    border-radius: var(--gestion-radius-sm);
    background: #1f2937;
    color: #f9fafb;
}

.gestion-help-search input::placeholder {
    color: #9ca3af;
}

.gestion-help-search input:focus {
    outline: 2px solid rgba(147, 197, 253, .55);
    outline-offset: 1px;
    border-color: #93c5fd;
}

.gestion-help-panel__content {
    padding: 1rem 1.2rem 1.4rem;
    counter-reset: gestion-help-section;
}

.gestion-help-card {
    position: relative;
    margin-bottom: .8rem;
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, .24);
    border-radius: .5rem;
    background: #111827;
}

.gestion-help-card::before {
    counter-increment: gestion-help-section;
    content: counter(gestion-help-section);
    position: absolute;
    top: .85rem;
    right: .85rem;
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(59, 130, 246, .16);
    color: #93c5fd;
    font-size: .75rem;
    font-weight: 900;
}

.gestion-help-card h3 {
    margin: 0 2.4rem .6rem 0;
    color: #f9fafb;
    font-size: 1.05rem;
}

.gestion-help-card div {
    color: #d1d5db;
    font-size: .9rem;
    line-height: 1.55;
}

.gestion-help-card small {
    display: inline-block;
    margin-top: .7rem;
    color: #93c5fd;
}

.gestion-help-card.is-help-hidden {
    display: none;
}

.gestion-help-match {
    padding: 0 .08em;
    border-radius: .1875rem;
    background: #fde68a;
    color: #111827;
    box-shadow: 0 0 0 1px rgba(251, 191, 36, .35);
}

.gestion-help-panel__empty {
    padding: 1rem;
    border: 1px dashed rgba(148, 163, 184, .34);
    border-radius: .5rem;
    color: #d1d5db;
    background: rgba(17, 24, 39, .72);
}

/* Las tablas con formularios necesitan controles algo más compactos. */
.gestion-app-shell .table .form-control:not(.form-control-lg),
.gestion-app-shell .table .form-select:not(.form-select-lg) {
    min-height: 2.25rem;
    padding-top: .35rem;
    padding-bottom: .35rem;
}

@media (max-width: 767.98px) {
    .gestion-app-shell .container,
    .gestion-app-shell .container-fluid {
        --bs-gutter-x: 1.25rem;
    }

    .gestion-app-shell .navbar .btn,
    .gestion-app-shell--conductor .btn {
        min-height: 2.75rem;
    }

    .gestion-page-header,
    .gestion-page-actions {
        align-items: stretch;
    }

    .gestion-page-actions,
    .gestion-page-actions .btn,
    .gestion-page-actions form,
    .gestion-page-actions form .btn {
        width: 100%;
    }

    .gestion-app-shell .card-body {
        padding: .9rem;
    }

    .gestion-app-shell .table > :not(caption) > * > * {
        padding: .65rem .55rem;
    }

    .gestion-help-panel {
        width: 100vw;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gestion-app-shell *,
    .gestion-app-shell *::before,
    .gestion-app-shell *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
