/* =========================================================
   Fleet Control - app.css
   Base visual para WebApp Blazor + BlazorBootstrap
   ========================================================= */

/* =========================================================
   1) Base global
   ========================================================= */

html,
body {
    font-family: 'Roboto', sans-serif;
    font-weight: normal;
    font-size: 0.9rem;
}

main {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

.card {
    background-color: var(--bs-card-bg);
}

a,
.btn-link {
    color: var(--fleet-link-color, #006bb7);
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

h1:focus {
    outline: none;
}

.centeredContainer {
    text-align: center;
}

.form-actions .btn {
    min-width: 120px;
}

/* =========================================================
   2) Variables de tema
   ========================================================= */

[data-bs-theme="light"] {
    --fleet-link-color: #006bb7;

    --bb-sidebar2-background-color: #ffffff;
    --bb-sidebar2-top-row-background-color: #0ea5e9;
    --bb-sidebar2-top-row-border-color: rgba(14, 165, 233, .25);
    --bb-sidebar2-title-text-color: #ffffff;
    --bb-sidebar2-brand-icon-color: #ffffff;
    --bb-sidebar2-nav-item-text-active-color-rgb: 14, 165, 233;
}

[data-bs-theme="dark"] {
    --fleet-link-color: #22d3ee;

    --bs-body-bg: #07111f;
    --bs-body-color: #e5eefb;
    --bs-tertiary-bg: rgba(15, 23, 42, .72);
    --bs-border-color: rgba(148, 163, 184, .18);
    --bs-primary: #06b6d4;
    --bs-primary-rgb: 6, 182, 212;

    --bb-sidebar2-background-color: #0b1220;
    --bb-sidebar2-top-row-background-color: #0b1220;
    --bb-sidebar2-title-text-color: #ffffff;
    --bb-sidebar2-brand-icon-color: #22d3ee;
    --bb-sidebar2-nav-item-text-color: rgba(226, 232, 240, .88);
    --bb-sidebar2-nav-item-text-active-color-rgb: 255, 255, 255;
}

/* =========================================================
   3) Layout / fondos de contenido
   ========================================================= */

[data-bs-theme="light"] main,
[data-bs-theme="light"] .content {
    background:
        radial-gradient(circle at 80% 12%, rgba(14, 165, 233, .08), transparent 28%),
        linear-gradient(135deg, #f8fafc 0%, #eef6ff 100%);
    color: #0f172a;
}

[data-bs-theme="dark"] main,
[data-bs-theme="dark"] .content {
    background:
        radial-gradient(circle at 78% 18%, rgba(14, 165, 233, .12), transparent 30%),
        radial-gradient(circle at 35% 85%, rgba(37, 99, 235, .10), transparent 32%),
        linear-gradient(135deg, #07111f 0%, #0b1220 48%, #0b1f3a 100%);
    color: #e5eefb;
}

[data-bs-theme="dark"] .content {
    position: relative;
}

[data-bs-theme="dark"] .content::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .10;
    background-image: radial-gradient(circle, rgba(34, 211, 238, .65) 1px, transparent 1.6px);
    background-size: 24px 24px;
    mask-image: radial-gradient(circle at 58% 42%, black 0%, transparent 72%);
}

[data-bs-theme="dark"] .content > * {
    position: relative;
    z-index: 1;
}

/* =========================================================
   4) Sidebar / top row
   ========================================================= */

[data-bs-theme="light"] .sidebar,
[data-bs-theme="light"] .bb-sidebar2,
[data-bs-theme="light"] .bb-sidebar2-top-row {
    border-color: rgba(14, 165, 233, .20) !important;
}

[data-bs-theme="light"] .bb-sidebar2-top-row,
[data-bs-theme="light"] .sidebar .top-row {
    border-bottom: 1px solid rgba(14, 165, 233, .22) !important;
    box-shadow: none !important;
}

[data-bs-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #08111f 0%, #0b1220 58%, #0d1b2f 100%) !important;
    border-right: 1px solid rgba(148, 163, 184, .18);
}

[data-bs-theme="dark"] .top-row {
    background: rgba(15, 23, 42, .82) !important;
    border-bottom: 1px solid rgba(148, 163, 184, .18) !important;
    backdrop-filter: blur(16px);
}

[data-bs-theme="dark"] .sidebar .nav-link.active,
[data-bs-theme="dark"] .sidebar .nav-item .active,
[data-bs-theme="dark"] .bb-sidebar2 .nav-link.active,
[data-bs-theme="dark"] .nav-pills .nav-link.active {
    background: linear-gradient(90deg, rgba(6, 182, 212, .95), rgba(37, 99, 235, .85)) !important;
    color: #ffffff !important;
    box-shadow: inset 3px 0 0 rgba(255, 255, 255, .38);
}

[data-bs-theme="dark"] .sidebar .nav-link:hover,
[data-bs-theme="dark"] .bb-sidebar2 .nav-link:hover {
    background: rgba(34, 211, 238, .08) !important;
    color: #ffffff !important;
}

/* =========================================================
   5) Fleet componentes genéricos
   ========================================================= */

.fleet-section-title,
.fleet-section-title-action-accordion {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--bs-body-color);
}

.fleet-section-title i {
    margin-right: .5rem;
    color: var(--bs-primary);
}

[data-bs-theme="dark"] .fleet-section-title {
    margin-top: 1.35rem;
    margin-bottom: 1.2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, .18);
    color: #f8fafc;
    font-weight: 650;
    letter-spacing: .01em;
}

[data-bs-theme="dark"] .fleet-section-title i {
    color: #22d3ee;
}

.fleet-card {
    background-color: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    padding: 1rem;
}

[data-bs-theme="dark"] .fleet-card {
    background: rgba(15, 23, 42, .50);
    border-color: rgba(148, 163, 184, .18);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .16);
}

.fleet-status-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    background-color: var(--bs-tertiary-bg);
}

.fleet-status-icon {
    font-size: 1.4rem;
    color: var(--bs-primary);
}

.fleet-status-value {
    font-weight: 500;
}

.fleet-actions-panel {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
}

.fleet-tab-panel {
    border: 1px solid var(--bs-border-color);
    border-top: none;
    border-radius: 0 0 .5rem .5rem;
    padding: 1rem;
    min-height: 300px;
}

.tenant-allowed-row {
    opacity: .55;
}

.app-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.accordion-last-report {
    margin-left: 24px;
    font-size: .80rem;
}

/* Colores semánticos usados en acciones/consola */
.fleet-sync { color: #0d6efd; }
.fleet-realtime { color: #198754; }
.fleet-admin { color: #fd7e14; }
.fleet-communication { color: #6f42c1; }
.fleet-diagnostic { color: #6c757d; }
.fleet-assistence { color: #0dcaf0; }

/* =========================================================
   6) Dashboard
   ========================================================= */

.dashboard-alerts-body {
    max-height: 260px;
    overflow-y: auto;
}

/* =========================================================
   7) Browser / Grid / BlazorBootstrap
   ========================================================= */

/* Tabla base */
.table thead th,
.table thead th *,
.grid thead th,
.grid thead th * {
    font-family: 'Roboto', sans-serif !important;
}

.table thead th,
.grid thead th {
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .015em;
    text-transform: uppercase;
}

.table thead th svg,
.table thead th i,
.table thead th .bi,
.grid thead th svg,
.grid thead th i,
.grid thead th .bi {
    font-family: "bootstrap-icons" !important;
    font-size: .82rem;
    font-weight: normal !important;
    vertical-align: middle;
    opacity: .9;
}

[data-bs-theme="light"] .table {
    --bs-table-striped-bg: rgba(15, 23, 42, .035);
    --bs-table-hover-bg: rgba(14, 165, 233, .065);
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: #e5eefb;
    --bs-table-border-color: rgba(148, 163, 184, .15);
    --bs-table-striped-bg: rgba(255, 255, 255, .025);
    --bs-table-striped-color: #e5eefb;
    --bs-table-hover-bg: rgba(34, 211, 238, .055);
    --bs-table-hover-color: #ffffff;

    margin-bottom: 0;
    color: #e5eefb;
    border-color: rgba(148, 163, 184, .15);
}

[data-bs-theme="dark"] .table > :not(caption) > * > * {
    border-color: rgba(148, 163, 184, .14);
    background-color: transparent;
}

[data-bs-theme="dark"] .table thead th {
    background: rgba(15, 23, 42, .78);
    color: #f8fafc;
    border-bottom: 1px solid rgba(34, 211, 238, .28);
    vertical-align: middle;
}

[data-bs-theme="dark"] .table thead tr:nth-child(2) th,
[data-bs-theme="dark"] .table thead tr:nth-child(2) td {
    background: rgba(15, 23, 42, .48);
}

[data-bs-theme="dark"] .table tbody tr {
    transition: background-color .15s ease, color .15s ease;
}

[data-bs-theme="dark"] .table tbody tr:hover {
    background: rgba(34, 211, 238, .055);
}

[data-bs-theme="dark"] .table td,
[data-bs-theme="dark"] .table th {
    padding-top: .72rem;
    padding-bottom: .72rem;
}

/* Browser card */
.fleet-browser-card {
    width: 100%;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid var(--bs-border-color);
}

[data-bs-theme="light"] .fleet-browser-card {
    background: rgba(255, 255, 255, .72);
    border-color: rgba(148, 163, 184, .26);
    box-shadow:
        0 18px 42px rgba(15, 23, 42, .06),
        0 1px 0 rgba(255, 255, 255, .9) inset;
}

[data-bs-theme="dark"] .fleet-browser-card {
    background: rgba(15, 23, 42, .46);
    border-color: rgba(148, 163, 184, .18);
    box-shadow:
        0 24px 70px rgba(0, 0, 0, .22),
        0 1px 0 rgba(255, 255, 255, .04) inset;
    backdrop-filter: blur(10px);
}

.fleet-browser-card .table {
    margin-bottom: 0;
}

.fleet-browser-card .table thead tr:first-child th:first-child {
    border-top-left-radius: 16px;
}

.fleet-browser-card .table thead tr:first-child th:last-child {
    border-top-right-radius: 16px;
}

.fleet-browser-card .table,
.fleet-browser-card .table > :not(caption) > * > * {
    border-left-width: 0;
    border-right-width: 0;
}

.fleet-browser-card .table > :not(caption) > * > *:first-child {
    border-left-width: 0;
}

.fleet-browser-card .table > :not(caption) > * > *:last-child {
    border-right-width: 0;
}

[data-bs-theme="light"] .fleet-browser-card .table thead th {
    background: linear-gradient(180deg, #f8fbff 0%, #eef7ff 100%);
    color: #0f172a;
    border-bottom-color: rgba(14, 165, 233, .18);
}

[data-bs-theme="light"] .fleet-browser-card .table thead tr:nth-child(2) th,
[data-bs-theme="light"] .fleet-browser-card .table thead tr:nth-child(2) td {
    background: #f8fafc;
    border-bottom: 1px solid rgba(148, 163, 184, .22);
}

[data-bs-theme="dark"] .fleet-browser-card .table thead th {
    background: linear-gradient(180deg, rgba(15, 23, 42, .92) 0%, rgba(15, 23, 42, .72) 100%);
    border-bottom-color: rgba(34, 211, 238, .26);
}

[data-bs-theme="dark"] .fleet-browser-card .table thead tr:nth-child(2) th,
[data-bs-theme="dark"] .fleet-browser-card .table thead tr:nth-child(2) td {
    background: rgba(15, 23, 42, .54);
    border-bottom: 1px solid rgba(34, 211, 238, .16);
}

/* Footer / paginación del Browser card */
.fleet-browser-card .pagination {
    margin-bottom: 0;
}

.fleet-browser-card .grid-pagination,
.fleet-browser-card .bb-grid-pagination,
.fleet-browser-card .table-responsive + div,
.fleet-browser-card nav {
    padding: .45rem .95rem .65rem;
}

.fleet-browser-card > div:last-child {
    padding-bottom: .45rem;
}

.fleet-browser-card .row:last-child {
    padding: .45rem .95rem .65rem;
    margin-left: 0;
    margin-right: 0;
}

/* Paginación */
[data-bs-theme="dark"] .pagination .page-link {
    background-color: rgba(15, 23, 42, .62);
    border-color: rgba(148, 163, 184, .20);
    color: #cbd5e1;
}

[data-bs-theme="dark"] .pagination .page-link:hover {
    background-color: rgba(34, 211, 238, .10);
    border-color: rgba(34, 211, 238, .32);
    color: #ffffff;
}

[data-bs-theme="dark"] .pagination .active .page-link,
[data-bs-theme="dark"] .page-item.active .page-link {
    background: linear-gradient(135deg, #2563eb, #06b6d4);
    border-color: transparent;
    color: #ffffff;
}

/* =========================================================
   8) Formularios / inputs / validaciones
   ========================================================= */

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text {
    background-color: rgba(15, 23, 42, .72);
    border-color: rgba(148, 163, 184, .24);
    color: #e5eefb;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: rgba(15, 23, 42, .92);
    border-color: #22d3ee;
    color: #ffffff;
    box-shadow: 0 0 0 .2rem rgba(34, 211, 238, .14);
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: rgba(226, 232, 240, .46);
}

[data-bs-theme="dark"] .table .btn,
[data-bs-theme="dark"] .grid .btn {
    border-color: rgba(148, 163, 184, .22);
}

[data-bs-theme="dark"] .form-check-input:checked {
    background-color: #0ea5e9;
    border-color: #0ea5e9;
}

[data-bs-theme="dark"] .form-check-input {
    background-color: rgba(148, 163, 184, .26);
    border-color: rgba(148, 163, 184, .28);
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #ff6b6b;
    display: block;
    margin-top: .35rem;
    padding-left: .5rem;
    font-size: .85rem;
}

/* =========================================================
   9) Loading genérico
   ========================================================= */

.fleet-loading {
    min-height: calc(100dvh - 3.5rem);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.fleet-loading-content {
    transform: translateY(-12vh);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .9rem;
    color: var(--bs-body-color);
}

.fleet-loading-spinner {
    width: 2.3rem;
    height: 2.3rem;
    border-width: .22rem;
    color: var(--bs-primary);
}

.fleet-loading-message {
    font-size: .9rem;
    font-weight: 650;
    color: var(--bs-body-color);
    opacity: .85;
}

/* =========================================================
   10) Map markers / Leaflet
   ========================================================= */

.fleet-marker-online,
.fleet-marker-offline,
.fleet-marker-never {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .45);
}

.fleet-marker-online { background: #22c55e; }
.fleet-marker-offline { background: #ef4444; }
.fleet-marker-never { background: #6b7280; }

.fleet-marker-online i,
.fleet-marker-offline i,
.fleet-marker-never i {
    color: white;
    font-size: 22px;
}

.fleet-marker-highlight {
    animation: fleet-marker-pulse .7s ease-in-out 3;
}

@keyframes fleet-marker-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* =========================================================
   11) Consola / iconos / error boundary
   ========================================================= */

.fleet-console {
    background-color: #0d1117;
    color: #c9d1d9;
    font-family: Consolas, Monaco, monospace;
    font-size: .75rem;
    line-height: 1.4;
    padding: .75rem;
    height: 90px;
    overflow-y: auto;
    border-radius: 0 0 .5rem .5rem;
}

.console-received { color: #f59e0b; }
.console-completed { color: #22c55e; }
.console-error { color: #ef4444; }
.console-sent { color: #60a5fa; }

[data-bs-theme="dark"] .bi-eye { color: #22d3ee; }

[data-bs-theme="dark"] .bi-pencil,
[data-bs-theme="dark"] .bi-pencil-square {
    color: #facc15;
}

[data-bs-theme="dark"] .bi-trash,
[data-bs-theme="dark"] .bi-trash3 {
    color: #ef4444;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOngbGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgb3ZlcmZsb3c9ImhpZGRlbiI+PGRlZnM+PGNsaXBQYXRoIGlkPSJjbGlwMCI+PHJlY3QgeD0iMjM1IiB5PSI1MSIgd2lkdGg9IjU2IiBoZWlnaHQ9IjQ5Ii8+PC9jbGlwUGF0aD48L2RlZnM+PGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwKSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTIzNSAtNTEpIj48cGF0aCBkPSJNMjYzLjUwNiA1MUMyNjQuNzE3IDUxIDI2NS44MTMgNTEuNDgzNyAyNjYuNjA2IDUyLjI2NThMMjY3LjA1MiA1Mi43OTg3IDI2Ny41MzkgNTMuNjI4MyAyOTAuMTg1IDkyLjE4MzEgMjkwLjU0NSA5Mi43OTUgMjkwLjY1NiA5Mi45OTZDMjkwLjg3NyA5My41MTMgMjkxIDk0LjA4MTUgMjkxIDk0LjY3ODIgMjkxIDk3LjA2NTEgMjg5LjAzOCA5OSAyODYuNjE3IDk5TDI0MC4zODM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