
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-md);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

h1, h2, h3 {
    font-family: var(--font-title);
    margin: 0 0 var(--sp-3);
    color: var(--color-text);
}

h1 {
    font-size: var(--fs-xl);
    font-weight: 700;
}

h2 {
    font-size: var(--fs-lg);
    font-weight: 600;
}

h3 {
    font-size: var(--fs-md);
    font-weight: 600;
}

/* === LAYOUT BÁSICO (se complementa con MainLayout.css) === */
.main-content {
    padding: var(--sp-5);
}

@media (max-width: 768px) {
    .main-content {
        padding: var(--sp-4);
    }
}

/* === CARDS / PANELES === */

.card {
    background: var(--color-surface);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.card, .panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--sp-4);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

.panel-title {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: var(--fs-lg);
}

/* === FORM CONTROLS === */
.input, input[type="text"], input[type="tel"], input[type="email"], select, textarea {
    width: 100%;
    background: var(--surface-0);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: var(--fs-sm);
    outline: none;
    transition: .15s border, .15s box-shadow, .15s background;
}

    .input:focus, input:focus, select:focus, textarea:focus {
        border-color: var(--color-primary);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
        background: var(--surface-1);
    }

label {
    display: block;
    font-size: var(--fs-sm);
    color: var(--color-text-2);
    margin-bottom: 6px;
}

/* === Flechita simple para todos los selects === */
select,
select.input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--color-text-2) 50%), linear-gradient(-45deg, transparent 50%, var(--color-text-2) 50%);
    background-position: calc(100% - 16px) 50%, calc(100% - 10px) 50%;
    background-size: 6px 6px;
    background-repeat: no-repeat;
    padding-right: 2.4rem;
}


/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-weight: 600;
    font-size: var(--fs-sm);
    cursor: pointer;
    user-select: none;
    transition: .15s transform, .15s background, .15s border-color, .15s color;
}

    .btn:active {
        transform: scale(.98);
    }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

    .btn-primary:hover {
        background: var(--color-primary-alt);
    }

.btn-ghost {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-border);
}

    .btn-ghost:hover {
        background: color-mix(in srgb, var(--color-primary) 8%, transparent);
        border-color: var(--color-primary);
    }

.btn-compact {
    padding: 6px 12px;
    font-size: var(--fs-xs);
}

/* === BADGES / CHIPS === */
    .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--color-border);
    background: var(--surface-1);
    color: var(--color-text);
}

/* ===============================
   ESTADOS
   =============================== */

/* Libre (verde) */
.chip--ok {
    background: color-mix(in srgb, var(--color-success) 12%, var(--surface-0));
    border-color: color-mix(in srgb, var(--color-success) 22%, var(--surface-0));
    color: #0d7a43;
}

/* Ocupado (amarillo) */
.chip--warn {
    background: color-mix(in srgb, var(--color-warning) 14%, var(--surface-0));
    border-color: color-mix(in srgb, var(--color-warning) 24%, var(--surface-0));
    color: #7a5b00;
}

/* Fuera de servicio (gris) */
.chip--muted {
    background: color-mix(in srgb, #9aa0a6 14%, var(--surface-0));
    border-color: color-mix(in srgb, #9aa0a6 24%, var(--surface-0));
    color: #4a4f55;
}

/* Desconectado (rojo) */
.chip--danger {
    background: color-mix(in srgb, var(--color-danger) 14%, var(--surface-0));
    border-color: color-mix(in srgb, var(--color-danger) 24%, var(--surface-0));
    color: #8b1e1e;
}

/* Sin estado (neutral, distinto a muted) */
.chip--light {
    background: color-mix(in srgb, #9aa0a6 10%, var(--surface-0));
    border-color: color-mix(in srgb, #9aa0a6 18%, var(--surface-0));
    color: var(--color-text-2);
}

:root[data-theme="dark"] .chip--muted {
    background: color-mix(in srgb, #9aa0a6 26%, var(--color-surface));
    border-color: color-mix(in srgb, #9aa0a6 38%, var(--color-surface));
    color: var(--color-text);
}

:root[data-theme="dark"] .chip--light {
    background: color-mix(in srgb, #9aa0a6 12%, var(--color-surface));
    border-color: color-mix(in srgb, #9aa0a6 24%, var(--color-surface));
    color: var(--color-text-2);
}

:root[data-theme="dark"] .chip--ok {
    background: color-mix(in srgb, var(--color-success) 18%, var(--color-surface));
    border-color: color-mix(in srgb, var(--color-success) 32%, var(--color-surface));
    color: #b7f3d4;
}

:root[data-theme="dark"] .chip--warn {
    background: color-mix(in srgb, var(--color-warning) 20%, var(--color-surface));
    border-color: color-mix(in srgb, var(--color-warning) 36%, var(--color-surface));
    color: #ffe2a3;
}

:root[data-theme="dark"] .chip--danger {
    background: color-mix(in srgb, var(--color-danger) 20%, var(--color-surface));
    border-color: color-mix(in srgb, var(--color-danger) 36%, var(--color-surface));
    color: #ffd1d1;
}

/* Link del nombre de conductor en la grilla */
.driver-link {
    display: inline-block;
    padding: 4px 0;
}

/* En mobile, un poco más de área para el dedo */
@media (max-width: 768px) {
    .driver-link {
        padding: 8px 0;
    }
}


/* === DIALOG / MODAL sencillo === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
}

.dialog {
    width: min(920px, 100%);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.dialog-header, .dialog-footer {
    padding: var(--sp-4);
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    border-bottom: 1px solid var(--color-border);
}

.dialog-title {
    font: 700 var(--fs-lg)/1 var(--font-title);
}

.dialog-body {
    padding: var(--sp-4);
    display: grid;
    gap: var(--sp-4);
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-3);
    border-top: 1px solid var(--color-border);
}

.dialog--lg {
    max-width: 900px;
}

.dialog-body--scroll {
    max-height: 60vh;
    overflow-y: auto;
}

/* ===== Google Maps InfoWindow ===== */
.gm-style .gm-style-iw {
    padding: 8px !important;
    overflow: hidden !important;
    max-height: none !important;
}

/* Fondo del contenedor de InfoWindow (evita franja blanca) */
.gm-style .gm-style-iw-c {
    background: #1f1f22;
    border: 1px solid #2f2f34;
    box-shadow: none;
}

.gm-style .gm-style-iw-d {
    overflow: hidden !important;
}

/* ================================
   Google Maps InfoWindow
   ================================ */

/* Ocultar botón cerrar */
.gm-style .gm-ui-hover-effect {
    display: none !important;
}

/* Eliminar espacio reservado para la X */
.gm-style .gm-style-iw-c {
    padding-top: 8px !important;
}

/* Evitar scroll interno */
.gm-style .gm-style-iw-d {
    overflow: hidden !important;
    max-height: none !important;
}

/* Ajuste general del contenedor */
.gm-style .gm-style-iw {
    padding: 0 !important;
}

/* Flecha del InfoWindow */
.gm-style .gm-style-iw-t::after {
    background: #1f1f22;
    box-shadow: none;
    border-color: #1f1f22;
}

.gm-style .gm-style-iw-t::before {
    background: #2f2f34;
    box-shadow: none;
    border-color: #2f2f34;
}

/* Forzar flecha oscura en modo oscuro */
:root[data-theme="dark"] .gm-style .gm-style-iw-c,
.app-shell.dark-mode-global .gm-style .gm-style-iw-c {
    background: #1f1f22 !important;
    border-color: #2f2f34 !important;
}

:root[data-theme="dark"] .gm-style .gm-style-iw-t,
.app-shell.dark-mode-global .gm-style .gm-style-iw-t {
    background: transparent !important;
    filter: none !important;
}

:root[data-theme="dark"] .gm-style .gm-style-iw-t::after,
.app-shell.dark-mode-global .gm-style .gm-style-iw-t::after {
    background: #1f1f22 !important;
    border-color: #1f1f22 !important;
    box-shadow: none !important;
    filter: none !important;
}

:root[data-theme="dark"] .gm-style .gm-style-iw-t::before,
.app-shell.dark-mode-global .gm-style .gm-style-iw-t::before {
    background: #2f2f34 !important;
    border-color: #2f2f34 !important;
    box-shadow: none !important;
    filter: none !important;
}



/* ===== Table wrapper (scroll horizontal si hace falta) ===== */
.table-wrapper {
    width: 100%;
}

.table-wrapper--scroll {
    overflow-x: auto;
}

@media (max-width: 768px) {
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 720px;
    }
}



/* === TABLAS BASE === */
.table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: var(--fs-sm);
}

    .table thead th {
        background: var(--table-header);
        color: var(--color-text);
        text-align: left;
        padding: 10px 14px;
        font: 600 var(--fs-sm)/1 var(--font-title);
        border-bottom: 1px solid var(--color-border);
    }

    .table tbody td {
        padding: 10px 14px;
        font-size: var(--fs-sm);
        border-bottom: 1px solid var(--color-border);
    }

    .table tbody tr:nth-child(even) {
        background: var(--surface-1);
    }

    .table tbody tr:hover {
        background: color-mix(in srgb, var(--color-primary) 4%, var(--surface-1));
    }

/* Variante con header rojo de marca */
.table--brand thead th {
    background: var(--color-primary);
    color: #fff;
}

.table--brand .rz-paginator {
    justify-content: center;
    padding: 10px;
}

/* Centrado por columna en TripDetails */
.table--brand thead th:nth-child(1),
.table--brand tbody td:nth-child(1),
.table--brand thead th:nth-child(2),
.table--brand tbody td:nth-child(2),
.table--brand thead th:nth-child(3),
.table--brand tbody td:nth-child(3),
.table--brand thead th:nth-child(4),
.table--brand tbody td:nth-child(4) {
    text-align: center;
}

/* Cuando el TH tiene botón (orden), asegurá que quede centrado también */
.table--brand thead th .th-sort {
    justify-content: center;
}

.action-center {
    display: flex;
    justify-content: center;
    align-items: center;
}


/* ===== Footer / Paginado (GLOBAL) ===== */

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-3);
    padding: 8px 10px 2px;
}

.table-footer__right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.table-footer__left strong {
    font-weight: 500;
}

.page-size {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.page-size .text-muted {
    white-space: nowrap;
    display: none;
}

.page-size .input.small {
    width: auto;
    min-width: 72px;
    padding-right: 2rem;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-indicator {
    font-weight: 600;
    color: var(--color-text-2);
}

.btn-mini {
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-2);
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
}

    .btn-mini:hover {
        box-shadow: var(--shadow-sm);
    }

    .btn-mini:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .btn-mini.is-active {
        border-color: var(--color-brand, var(--color-border));
        font-weight: 600;
    }


/* ===== SORT HEADERS ===== */
.th-sort {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    user-select: none;
}

    .th-sort:focus {
        outline: none;
    }

    .th-sort:hover .sort-icon {
        opacity: 1;
        transform: translateY(-1px);
    }

.sort-icon {
    font-size: 0.85rem;
    opacity: 0.6;
    transition: opacity 120ms ease, transform 120ms ease;
}

    .sort-icon.is-active {
        opacity: 1;
    }


.table--brand thead th {
    position: relative;
}

    .table--brand thead th:hover {
        filter: brightness(1.02);
    }

/* ===== SCROLLBARS ===== */
:root {
    --scrollbar-track: var(--surface-0);
    --scrollbar-thumb: color-mix(in srgb, var(--color-primary) 35%, transparent);
    --scrollbar-thumb-hover: color-mix(in srgb, var(--color-primary) 55%, transparent);
}

/* ===== MAP INFO WINDOW ===== */
.map-info-window {
    font-family: var(--font-body);
    max-width: 240px;
    padding: 8px 10px;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

.map-info-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
}

.map-info-meta {
    font-size: 0.72rem;
    color: var(--color-text-2);
    margin-bottom: 6px;
}

.map-info-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.78rem;
    margin-bottom: 6px;
}

.map-info-row:last-child {
    margin-bottom: 0;
}

.map-info-label {
    color: var(--color-text-2);
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.map-info-value {
    color: var(--color-text);
}

:root[data-theme="dark"] .map-info-title,
:root[data-theme="dark"] .map-info-value {
    color: #ffffff;
}

:root[data-theme="dark"] .map-info-meta,
:root[data-theme="dark"] .map-info-label {
    color: var(--color-text-2);
}

:root[data-theme="dark"] .map-info-window {
    background: #1f1f22;
    border-color: #2f2f34;
    box-shadow: none;
}

.map-info-window .chip {
    font-size: 0.7rem;
    padding: 1px 8px;
    border-radius: 999px;
}

:root[data-theme="dark"] {
    --scrollbar-track: var(--color-surface);
    --scrollbar-thumb: color-mix(in srgb, var(--color-primary) 55%, transparent);
    --scrollbar-thumb-hover: color-mix(in srgb, var(--color-primary) 70%, transparent);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}
