/* =============================================
   Cambrils t-BUS — Full d'estils principal
   Paleta corporativa Aparcam Cambrils + targeta t-BUS
   ============================================= */

/* ── Paleta ───────────────────────────────────────────────────────
   Els valors no són inventats: surten de les tres fonts de la marca.

   · Logotip Aparcam Cambrils (public/images/logo_aparcam.png)
       blau del logotip  #005890   ·   cian dels rombes  #0098D0
   · Web de l'Ajuntament de Cambrils, on redirigeix aparcam.cat
       --ajcb-brand-primary #335AA6 · --ajcb-brand-light #1D5892
       --ajcb-brand-dark    #2B2E4A · --ajcb-brand-warning #FEB139
       --ajcb-gray-lighter  #EAEEF6 · tipografia Rubik
   · Targeta t-BUS (public/images/targeta_tbus.png)
       blau  #204888   ·   ambre  #F8B038

   El cian i l'ambre són el que fa que això es llegeixi com a Aparcam
   i no com un plafó blau qualsevol: han de sortir a la vista, no
   amagats en un detall.
   ───────────────────────────────────────────────────────────────── */
:root {
    /* Blau del logotip Aparcam — menú, capçaleres i accions */
    --bus-blue:       #005890;
    --bus-blue-dark:  #00406B;
    --bus-blue-light: #1D5892;
    --bus-blue-pale:  #E4F1F9;

    /* Blau de l'Ajuntament de Cambrils — enllaços i estats seleccionats */
    --bus-ajcb:       #335AA6;
    --bus-ajcb-soft:  #748DC0;
    --bus-ajcb-dark:  #2B2E4A;

    /* Cian dels rombes del logotip — la signatura visual d'Aparcam */
    --bus-cyan:       #0098D0;
    --bus-cyan-dark:  #007BAB;
    --bus-cyan-pale:  #E0F4FC;

    /* Ambre de la targeta t-BUS i de l'Ajuntament — accent */
    --bus-amber:       #F8B038;
    --bus-amber-dark:  #D18D15;
    --bus-amber-pale:  #FFF6E5;

    /* Blau de la targeta t-BUS */
    --bus-tbus:       #204888;

    /* Compatibilitat: abans l'accent es deia «orange» */
    --bus-orange:      var(--bus-amber);
    --bus-orange-dark: var(--bus-amber-dark);
    --bus-orange-pale: var(--bus-amber-pale);

    --bg:            #EAEEF6;
    --vora:          #DCE4F2;
    --vora-suau:     #EEF2F9;
    --text:          #2B2E4A;
    --text-suau:     #6B7A8D;
    --text-tenue:    #94A3B8;

    --sidebar-width: 240px;
    --card-radius:   12px;
    --shadow:        0 2px 8px rgba(0, 64, 107, 0.10);
    --shadow-hover:  0 4px 16px rgba(0, 64, 107, 0.18);
}

/* ── Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--bg);
    /* Rubik és la tipografia de la web de l'Ajuntament de Cambrils. */
    font-family: 'Rubik', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--bus-ajcb-dark);
    margin: 0;
    padding: 0;
}

a { color: var(--bus-ajcb); }
a:hover { color: var(--bus-blue-dark); }

/* El focus del teclat porta el cian del logotip a tota l'aplicació. */
.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus-visible,
a:focus-visible {
    border-color: var(--bus-cyan);
    box-shadow: 0 0 0 0.2rem rgba(0, 152, 208, 0.25);
    outline: none;
}
.form-check-input:checked {
    background-color: var(--bus-cyan);
    border-color: var(--bus-cyan);
}

/* ── Layout wrapper ─────────────────────────────────────────────── */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.bus-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid var(--vora);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease, transform 0.25s ease;
    scrollbar-width: thin;
    scrollbar-color: #D7E0EE transparent;
}

.bus-sidebar::-webkit-scrollbar { width: 4px; }
.bus-sidebar::-webkit-scrollbar-thumb { background: #D7E0EE; border-radius: 2px; }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--vora-suau);
    flex-shrink: 0;
    text-decoration: none;
}

/* Nav area */
.sidebar-nav {
    flex: 1;
    padding: 10px 0 6px;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #94A3B8;
    padding: 14px 16px 5px;
}

/* Nav link */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: #4A5A6E;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    cursor: pointer;
    position: relative;
}

.sidebar-link i:first-child {
    font-size: 15px;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.sidebar-link i:first-child { color: #94A3B8; }

/* Sobre blanc, el cian dels rombes del logotip marca on ets. */
.sidebar-link:hover {
    color: var(--bus-blue);
    background: var(--bus-cyan-pale);
    border-left-color: rgba(0, 152, 208, 0.45);
    text-decoration: none;
}

.sidebar-link:hover i:first-child { color: var(--bus-cyan); }

.sidebar-link.active {
    color: var(--bus-blue);
    background: var(--bus-cyan-pale);
    border-left-color: var(--bus-cyan);
    font-weight: 600;
}

.sidebar-link.active i:first-child { color: var(--bus-cyan); }

/* Collapse toggle chevron */
.sidebar-chevron {
    font-size: 11px;
    transition: transform 0.2s;
    color: #94A3B8;
    margin-left: auto;
}

.sidebar-chevron.rotated { transform: rotate(-180deg); }

/* Submenu */
.sidebar-submenu {
    padding: 2px 0 4px;
    background: #F7FAFD;
}

.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px 7px 42px;
    color: #6B7A8D;
    text-decoration: none;
    font-size: 12.5px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-sublink:hover {
    color: var(--bus-blue);
    background: var(--bus-cyan-pale);
    border-left-color: rgba(0, 152, 208, 0.35);
    text-decoration: none;
}

.sidebar-sublink.active {
    color: var(--bus-blue);
    border-left-color: var(--bus-cyan);
    font-weight: 600;
}

/* Error badge in sidebar */
.sidebar-badge {
    background: #dc3545;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 20px;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
    margin-left: auto;
    line-height: 16px;
}

/* User section */
.sidebar-user {
    flex-shrink: 0;
    border-top: 1px solid var(--vora-suau);
    padding: 12px 14px;
    background: #FBFCFE;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    background: var(--bus-cyan-pale);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bus-blue);
    font-size: 15px;
    flex-shrink: 0;
}

.sidebar-user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--bus-ajcb-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 10px;
    color: #94A3B8;
    text-transform: capitalize;
    letter-spacing: 0.5px;
}

.sidebar-user-actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-user-link {
    display: block;
    color: #6B7A8D;
    font-size: 12px;
    text-decoration: none;
    padding: 4px 6px;
    border-radius: 5px;
    transition: all 0.15s;
    background: none;
    border: none;
    cursor: pointer;
}

.sidebar-user-link:hover {
    color: var(--bus-blue);
    background: var(--bus-cyan-pale);
}

/* ── Commutador d'idioma ────────────────────────────────────────── */
.bus-idioma {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}

.bus-bandera {
    width: 19px;
    height: auto;
    flex-shrink: 0;
    border-radius: 2px;
    /* Les dues banderes tenen blanc o groc a les vores: sense un filet
       es perdrien sobre el fons clar. */
    box-shadow: 0 0 0 1px rgba(0, 64, 107, 0.22);
    display: block;
}

/* Les banderes es reconeixen pel color: dessaturar-les fa que semblin
   espatllades. L'idioma inactiu s'apaga amb opacitat, i prou; qui marca
   l'actiu és la pastilla de fons i la negreta. */
.bus-idioma:not(.active) .bus-bandera { opacity: 0.55; }
.bus-idioma:hover .bus-bandera { opacity: 1; }

.sidebar-user-link.bus-idioma.active {
    color: var(--bus-blue);
    background: var(--bus-cyan-pale);
    font-weight: 700;
}

/* Al peu de la pantalla d'entrada les banderes van una mica més petites. */
.auth-card-footer .bus-idioma { margin: 0 2px; }
.auth-card-footer .bus-bandera { width: 16px; }
.auth-card-footer .bus-idioma.active { font-weight: 700; }

/* ── Main content ───────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    transition: margin-left 0.25s ease;
}

/* ── Sidebar colapsado (desktop) ────────────────────────────────── */
.bus-sidebar.collapsed {
    width: 56px;
    min-width: 56px;
    overflow: visible;
}
.bus-sidebar.collapsed .sidebar-nav {
    overflow: visible;
}
.main-content.sidebar-collapsed {
    margin-left: 56px;
}
.bus-sidebar.collapsed .sidebar-section-label { display: none; }
.bus-sidebar.collapsed .sidebar-link span,
.bus-sidebar.collapsed .sidebar-link .sidebar-chevron,
.bus-sidebar.collapsed .sidebar-badge { display: none !important; }
.bus-sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 10px 0;
    border-radius: 0;
}
.bus-sidebar.collapsed .sidebar-link i:first-child { margin: 0; font-size: 18px; }
.bus-sidebar.collapsed .sidebar-user { display: none; }
.bus-sidebar.collapsed .sidebar-brand-text { display: none; }
.bus-sidebar.collapsed .sidebar-brand { justify-content: center; padding: 14px 0; }

/* ── Tooltip al hacer hover en sidebar colapsado ────────────────── */
.bus-sidebar.collapsed .sidebar-link[data-label] {
    position: relative;
}

.bus-sidebar.collapsed .sidebar-link[data-label]::after {
    content: attr(data-label);
    position: absolute;
    left: 58px;
    top: 50%;
    transform: translateY(-50%) translateX(-6px);
    background: var(--bus-blue-dark);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 7px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.28);
}

.bus-sidebar.collapsed .sidebar-link[data-label]::before {
    content: '';
    position: absolute;
    left: 52px;
    top: 50%;
    transform: translateY(-50%) translateX(-6px);
    border: 5px solid transparent;
    border-right-color: var(--bus-blue-dark);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
    z-index: 9999;
}

.bus-sidebar.collapsed .sidebar-link[data-label]:hover::after,
.bus-sidebar.collapsed .sidebar-link[data-label]:hover::before {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Botón colapsar sidebar */
.sidebar-collapse-btn {
    background: none;
    border: none;
    color: #94A3B8;
    padding: 4px 6px;
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
    margin-left: auto;
}
.sidebar-collapse-btn:hover {
    color: var(--bus-blue);
    background: var(--bus-cyan-pale);
}
.bus-sidebar.collapsed .sidebar-collapse-btn {
    margin: 0 auto;
    font-size: 20px;
    padding: 6px;
}

/* ── Mobile topbar ──────────────────────────────────────────────── */
.mobile-topbar {
    background: #fff;
    border-bottom: 1px solid var(--vora);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0, 64, 107, 0.06);
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--bus-blue);
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.mobile-topbar-title {
    color: var(--bus-blue);
    font-weight: 700;
    font-size: 15px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1029;
}

.sidebar-overlay.active { display: block; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 991px) {
    .bus-sidebar {
        transform: translateX(-100%);
    }
    .bus-sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

/* ── Page header ────────────────────────────────────────────────── */
/* Capçalera clara, com la pantalla d'entrada: el color el posa el filet
   cian → ambre, no un fons blau. */
.bus-page-header {
    background: #fff;
    color: var(--text);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 4px rgba(0, 64, 107, 0.06);
    border-bottom: 3px solid transparent;
    border-image: linear-gradient(90deg, var(--bus-cyan) 0%, var(--bus-cyan) 55%, var(--bus-amber) 55%, var(--bus-amber) 100%) 1;
}

.bus-page-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--bus-blue);
    display: flex;
    align-items: center;
    gap: 10px;
}

.bus-page-header h1 i { color: var(--bus-cyan); }

.bus-page-header .breadcrumb {
    margin: 0;
    padding: 0;
    background: none;
    font-size: 12px;
}

.bus-page-header .breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-tenue);
}

.bus-page-header .breadcrumb a {
    color: var(--bus-ajcb);
    text-decoration: none;
}

.bus-page-header .breadcrumb a:hover { text-decoration: underline; }

.bus-page-header .breadcrumb-item.active {
    color: var(--text-suau);
}

/* ── Stat Cards ─────────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.stat-accent { height: 4px; width: 100%; }
.stat-accent.blue   { background: var(--bus-blue); }
.stat-accent.orange { background: var(--bus-orange); }
.stat-accent.green  { background: #28a745; }
.stat-accent.red    { background: #dc3545; }
.stat-accent.purple { background: #5A4B8A; }
.stat-accent.teal   { background: #20c997; }

.stat-card-body {
    padding: 18px 20px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.blue   { background: var(--bus-blue-pale); color: var(--bus-blue); }
.stat-icon.orange { background: var(--bus-orange-pale); color: var(--bus-orange-dark); }
.stat-icon.green  { background: #d4edda; color: #28a745; }
.stat-icon.red    { background: #f8d7da; color: #dc3545; }
.stat-icon.purple { background: #ede9f5; color: #5A4B8A; }
.stat-icon.teal   { background: #d2f4ea; color: #20c997; }

.stat-info  { flex: 1; min-width: 0; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--bus-blue-dark); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: #6c757d; }
.stat-sub   { font-size: 12px; color: #6c757d; margin-top: 2px; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
    border: none !important;
    border-radius: var(--card-radius) !important;
    box-shadow: var(--shadow) !important;
}

.card-header {
    border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 14px 20px;
}

.bus-card-header {
    background: #fff;
    border-bottom: 3px solid var(--bus-orange);
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.bus-card-header h5,
.bus-card-header h6 {
    color: var(--bus-blue);
    font-weight: 700;
    margin: 0;
    font-size: 15px;
}

.header-icon {
    width: 32px;
    height: 32px;
    background: var(--bus-blue-pale);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bus-blue);
    font-size: 16px;
    flex-shrink: 0;
}

.card-body { padding: 20px; }

/* ── Tables ─────────────────────────────────────────────────────── */
.table-responsive {
    border-radius: 0 0 var(--card-radius) var(--card-radius);
}

.bus-table { margin-bottom: 0; font-size: 13px; }

.bus-table thead th {
    background: var(--bus-blue) !important;
    color: #fff !important;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    padding: 12px 14px;
    white-space: nowrap;
}

.bus-table tbody tr {
    transition: background 0.12s;
    border-bottom: 1px solid #f0f3f8;
}

.bus-table tbody tr:hover { background: var(--bus-blue-pale) !important; }

.bus-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
    border-color: #f0f3f8;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.bus-table tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-bus {
    background: var(--bus-orange);
    color: var(--bus-blue-dark);
    border: none;
    font-weight: 600;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 13px;
    transition: all 0.18s;
    box-shadow: 0 2px 6px rgba(246,168,0,0.25);
}

.btn-bus:hover, .btn-bus:focus {
    background: var(--bus-orange-dark);
    color: var(--bus-blue-dark);
    box-shadow: 0 4px 10px rgba(246,168,0,0.35);
    transform: translateY(-1px);
}

.btn-bus:active { transform: translateY(0); box-shadow: none; }

.btn-bus-outline {
    background: transparent;
    color: var(--bus-blue);
    border: 2px solid var(--bus-blue);
    font-weight: 600;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 13px;
    transition: all 0.18s;
}

.btn-bus-outline:hover, .btn-bus-outline:focus {
    background: var(--bus-blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(27,72,128,0.2);
}

.btn-sm.btn-bus        { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-sm.btn-bus-outline{ padding: 3px 9px; font-size: 12px; border-radius: 6px; }

/* Override btn-dark to use bus-blue */
.btn-dark {
    background-color: var(--bus-blue) !important;
    border-color: var(--bus-blue) !important;
    color: #fff !important;
}

.btn-dark:hover {
    background-color: var(--bus-blue-dark) !important;
    border-color: var(--bus-blue-dark) !important;
}

/* ── Filter form ────────────────────────────────────────────────── */
.filter-form {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.filter-form label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--bus-blue);
    margin-bottom: 4px;
}

.filter-form .form-control,
.filter-form .form-select {
    border-radius: 7px;
    border-color: #d0d7e2;
    font-size: 13px;
    color: #1a2a3a;
    padding: 7px 12px;
}

/* ── Forms ──────────────────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: 7px !important;
    border-color: #d0d7e2 !important;
    font-size: 13px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--bus-blue-light) !important;
    box-shadow: 0 0 0 3px rgba(37,96,164,0.12) !important;
}

.form-label {
    font-weight: 600;
    font-size: 13px;
    color: #2a3f5f;
    margin-bottom: 5px;
}

/* ── Select2 ────────────────────────────────────────────────────── */
.select2-container--bootstrap-5 .select2-selection,
.select2-container--default .select2-selection--single {
    border-color: #d0d7e2 !important;
    border-radius: 7px !important;
}

.select2-container--default .select2-selection--single:focus,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--bus-blue-light) !important;
    box-shadow: 0 0 0 3px rgba(37,96,164,0.12) !important;
}

.select2-container--default .select2-results__option--highlighted {
    background-color: var(--bus-blue) !important;
}

/* ── Pagination ─────────────────────────────────────────────────── */
.pagination { margin-bottom: 0; }

.pagination .page-item.active .page-link {
    background-color: var(--bus-blue);
    border-color: var(--bus-blue);
    color: #fff;
}

.pagination .page-link {
    color: var(--bus-blue);
    border-radius: 6px;
    margin: 0 2px;
    font-size: 13px;
    border: 1px solid #d0d7e2;
}

.pagination .page-link:hover {
    background: var(--bus-blue-pale);
    border-color: var(--bus-blue-pale);
    color: var(--bus-blue);
}

.pagination .page-link:focus {
    box-shadow: 0 0 0 2px rgba(37,96,164,0.15);
}

.page-item.disabled .page-link {
    color: #adb5bd;
    cursor: not-allowed;
}

/* Hide Laravel pagination text */
nav[role="navigation"] p.text-sm,
nav[role="navigation"] .text-sm,
nav p { display: none !important; }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-header {
    background: var(--bus-blue);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header .btn-close { filter: invert(1); }

.modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* ── Footer ─────────────────────────────────────────────────────── */
.bus-footer {
    background: #fff;
    border-top: 1px solid var(--vora);
    color: var(--text-suau);
    text-align: center;
    padding: 14px 0;
    font-size: 12px;
    margin-top: auto;
}

.bus-footer strong { color: var(--bus-blue); }
.bus-footer a { color: var(--bus-ajcb); text-decoration: none; }
.bus-footer a:hover { text-decoration: underline; }
.bus-footer .bus-footer-sep { color: var(--vora); }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge-ok    { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.badge-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.badge-retry { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* ── Alert banners ──────────────────────────────────────────────── */
.alert-bus-warning {
    background: linear-gradient(90deg, #fff3cd 0%, #FDF1E6 100%);
    border-left: 4px solid var(--bus-orange);
    border-radius: 8px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    color: #856404;
    margin-bottom: 20px;
}

.alert-bus-danger {
    background: linear-gradient(90deg, #f8d7da 0%, #fff5f5 100%);
    border-left: 4px solid #dc3545;
    border-radius: 8px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    color: #721c24;
    margin-bottom: 20px;
}

/* ── Misc utilities ─────────────────────────────────────────────── */
.text-bus-blue   { color: var(--bus-blue) !important; }
.text-bus-orange { color: var(--bus-orange) !important; }
.bg-bus-blue     { background: var(--bus-blue) !important; }
.bg-bus-orange   { background: var(--bus-orange) !important; }
.bg-bus-pale     { background: var(--bus-blue-pale) !important; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.empty-state i {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 12px;
    display: block;
}

/* ── Toastr ─────────────────────────────────────────────────────── */
#toast-container > .toast {
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* ── Spin animation ─────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; display: inline-block; }

/* ── Input groups ───────────────────────────────────────────────── */
.input-group .form-control { min-width: 0; }
.input-group { display: flex; flex-wrap: nowrap; gap: .25rem; }

/* ── Responsive tweaks ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .bus-page-header h1 { font-size: 18px; }
    .stat-value { font-size: 22px; }
    .bus-table { font-size: 12px; }
    .bus-table td, .bus-table th { padding: 8px 10px; }
    .main-content { margin-left: 0; }
    .card-body { padding: .8rem !important; }
}

@media (max-width: 576px) {
    .input-group { flex-wrap: wrap; }
    .input-group .btn { width: 100%; }
    .d-flex.justify-content-end .btn,
    .d-flex.justify-content-between .btn {
        white-space: normal;
        padding: .35rem .5rem;
    }
}

/* ── Auth pages ─────────────────────────────────────────────────── */
/* ── Entrada ──────────────────────────────────────────────────────
   Fons clar i la targeta com a protagonista: destaca per l'ombra i
   pel filet de color, no per contrast contra un fons fosc. Els rombes
   del logotip Aparcam es repeteixen, molt tènues, al fons.
   ───────────────────────────────────────────────────────────────── */
.auth-wrapper {
    position: relative;
    background: #fff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

/* Tel de fons: els rombes del logotip, molt tènues i escampats. */
.auth-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: #FBFDFE;
    /* Reixa de rombes com els del logotip. Molt baixa d'intensitat: ha de
       ser textura, no un dibuix que competeixi amb la targeta. */
    background-image:
        linear-gradient(45deg, rgba(0,152,208,0.045) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(0,152,208,0.045) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(0,152,208,0.045) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(0,152,208,0.045) 75%);
    background-size: 58px 58px;
    background-position: 0 0, 0 29px, 29px -29px, -29px 0;
    pointer-events: none;
}

/* Llum cian difusa darrere la targeta, perquè no suri sobre el blanc. */
.auth-wrapper::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 820px;
    height: 820px;
    margin: -410px 0 0 -410px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,152,208,0.20) 0%, rgba(0,152,208,0.07) 42%, rgba(0,152,208,0) 70%);
    pointer-events: none;
}

.auth-card {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 18px;
    border: 1px solid #DCE4F2;
    box-shadow:
        0 1px 2px rgba(0, 64, 107, 0.05),
        0 12px 28px rgba(0, 64, 107, 0.11),
        0 32px 64px rgba(0, 64, 107, 0.10);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

/* Filet superior cian → ambre, la signatura Aparcam + t-BUS. */
.auth-card::before {
    content: '';
    display: block;
    height: 5px;
    background: linear-gradient(90deg,
        var(--bus-cyan) 0%, var(--bus-cyan) 55%,
        var(--bus-amber) 55%, var(--bus-amber) 100%);
}

.auth-header {
    background: #fff;
    padding: 30px 36px 6px;
    text-align: center;
}

.auth-header-title {
    color: var(--bus-blue);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0 0 4px;
}

.auth-header-sub {
    color: var(--bus-blue);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.auth-body {
    padding: 18px 36px 26px;
}

.auth-body .form-label {
    font-size: 12px;
    font-weight: 600;
    color: #5A6B82;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.auth-body .input-group-text {
    background: var(--bus-cyan-pale);
    border-color: #DCE4F2;
    color: var(--bus-blue);
}

.auth-body .form-control {
    border-color: #DCE4F2;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

.auth-card-footer {
    padding: 14px 36px 18px;
    border-top: 1px solid #EEF2F9;
    text-align: center;
    font-size: 11px;
    color: #8A97A8;
    background: #FBFCFE;
}

.auth-card-footer a { color: var(--bus-ajcb); text-decoration: none; }
.auth-card-footer a:hover { text-decoration: underline; }

/* Peu de pàgina, fora de la targeta: els dos escuts. */
.auth-marca {
    position: relative;
    z-index: 1;
    margin-top: 22px;
    text-align: center;
}

/* El PNG de l'Ajuntament porta fons blanc opac i no es pot fondre amb el
   del darrere (el z-index de la targeta aïlla el context de barreja), així
   que se li dona forma de pastilla perquè sembli volgut. */
.auth-marca span {
    display: inline-block;
    padding: 9px 18px;
    background: #fff;
    border: 1px solid #E4EAF4;
    border-radius: 999px;
    box-shadow: 0 1px 3px rgba(0, 64, 107, 0.06);
}

.auth-marca img {
    display: block;
    height: 26px;
    width: auto;
    object-fit: contain;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.auth-marca span:hover img { opacity: 1; }

/* El botó d'entrar va amb el blau del logotip: l'ambre és l'accent de
   la t-BUS dins de l'aplicació, però aquí competia amb el logotip. */
.auth-body .btn-bus,
.auth-body .btn-dark {
    background: var(--bus-blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 88, 144, 0.28);
}

.auth-body .btn-bus:hover,
.auth-body .btn-bus:focus,
.auth-body .btn-dark:hover {
    background: var(--bus-blue-dark);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 88, 144, 0.38);
}

/* ── Compatibilidad badges Bootstrap 4 → Bootstrap 5 ──────────────────────────
   Las DataTables (yajra) y algunos JS pintan badges con clases BS4
   (badge-success, badge-danger, ...), que en BS5 no aplican color de fondo
   (texto blanco sobre blanco = invisible). Se restauran aquí. */
.badge.badge-primary   { background-color: #007bff; color: #fff; }
.badge.badge-secondary { background-color: #6c757d; color: #fff; }
.badge.badge-success   { background-color: #28a745; color: #fff; }
.badge.badge-danger    { background-color: #dc3545; color: #fff; }
.badge.badge-warning   { background-color: #ffc107; color: #212529; }
.badge.badge-info      { background-color: #17a2b8; color: #fff; }
.badge.badge-light     { background-color: #f8f9fa; color: #212529; border: 1px solid #e2e8f0; }
.badge.badge-dark      { background-color: #343a40; color: #fff; }

/* ════════════════════════════════════════════════════════════════════
   Componentes compartidos (KPIs, pills, chips, icono estado, toggle,
   tarjetas) — usados por Cargadores, Transacciones y futuras pantallas
   ════════════════════════════════════════════════════════════════════ */

/* ── KPIs ───────────────────────────────────────────────────────── */
.bus-kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:16px}
@media(max-width:860px){.bus-kpis{grid-template-columns:repeat(2,1fr)}}
@media(max-width:460px){.bus-kpis{grid-template-columns:1fr}}
.bus-kpi{background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:14px 15px;
  box-shadow:0 1px 3px rgba(16,42,80,.08);cursor:pointer;text-align:left;font:inherit;color:#16233a;
  display:flex;align-items:center;gap:12px;transition:transform .12s,box-shadow .12s,border-color .12s}
.bus-kpi:hover{transform:translateY(-2px)}
.bus-kpi.active{border-color:#E8822B;box-shadow:0 0 0 2px #E8822B inset,0 1px 3px rgba(16,42,80,.08)}
.bus-kpi.bus-kpi-static{cursor:default}
.bus-kpi.bus-kpi-static:hover{transform:none}
.bus-kpi .ic{width:40px;height:40px;border-radius:11px;display:grid;place-items:center;font-size:17px;flex:none}
.bus-kpi .v{font-size:25px;font-weight:800;line-height:1;display:block}
.bus-kpi .l{font-size:11px;color:#64748b;text-transform:uppercase;letter-spacing:.04em;margin-top:3px;display:block}
.bus-kpi .ic-blue{background:#E4F1F9;color:#1A6FAD}.bus-kpi .ic-ok{background:#e6f6ec;color:#1f9d4d}
.bus-kpi .ic-danger{background:#fdeaec;color:#d64550}.bus-kpi .ic-idle{background:#eef1f6;color:#6b7a90}
.bus-kpi .ic-charging{background:#e4edf8;color:#1A6FAD}.bus-kpi .ic-orange{background:#fff4df;color:#C96A18}

/* ── Pills de estado ────────────────────────────────────────────── */
.bus-pill{display:inline-flex;align-items:center;gap:6px;border-radius:20px;padding:4px 11px;
  font-size:12px;font-weight:600;white-space:nowrap}
.bus-pill i{font-size:11px}
.bus-pill-ok{background:#e6f6ec;color:#1f9d4d}.bus-pill-charging{background:#e4edf8;color:#1A6FAD}
.bus-pill-warn{background:#fff4df;color:#C96A18}.bus-pill-danger{background:#fdeaec;color:#d64550}
.bus-pill-idle{background:#eef1f6;color:#6b7a90}

/* ── Chips (conectores / etiquetas) ─────────────────────────────── */
.bus-conns{display:flex;gap:6px;flex-wrap:wrap}
.bus-conn{display:inline-flex;align-items:center;gap:5px;font-size:11.5px;font-weight:600;
  border:1px solid #e2e8f0;border-radius:8px;padding:3px 8px;background:#f6f8fc}
.bus-conn i{font-size:10px}
.bus-conn-ok{color:#1f9d4d}.bus-conn-charging{color:#1A6FAD}.bus-conn-warn{color:#C96A18}
.bus-conn-danger{color:#d64550}.bus-conn-idle{color:#6b7a90}

/* Animación "latido" en estados activos */
.bus-live i{animation:busPulse 1.6s ease-in-out infinite}
@keyframes busPulse{0%,100%{opacity:1}50%{opacity:.35}}
@media(prefers-reduced-motion:reduce){.bus-live i{animation:none}}

/* ── Icono de estado coloreado (al inicio de la fila) ───────────── */
.bus-cid{display:inline-flex;align-items:center;gap:10px;font-weight:600}
.bus-cid-ic{font-size:17px;flex:none}
.bus-cid-ok{color:#1f9d4d}.bus-cid-charging{color:#1A6FAD}.bus-cid-warn{color:#C96A18}
.bus-cid-danger{color:#d64550}.bus-cid-idle{color:#6b7a90}

/* ── Toggle Tabla / Tarjetas ────────────────────────────────────── */
.bus-seg{display:inline-flex;background:#f6f8fc;border:1px solid #e2e8f0;border-radius:9px;padding:3px;gap:3px}
.bus-seg button{border:0;background:transparent;color:#64748b;font:inherit;font-size:13px;padding:6px 12px;
  border-radius:7px;cursor:pointer;display:inline-flex;align-items:center;gap:6px}
.bus-seg button.active{background:#005893;color:#fff}


/* ════════════════════════════════════════════════════════════════════
   Cambrils t-BUS — components propis del gestor
   ════════════════════════════════════════════════════════════════════ */

/* ── Distintius de línia (colors dels rètols dels autobusos) ─────── */
.bus-linia {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; padding: 2px 9px; border-radius: 7px;
    font-weight: 800; font-size: 12px; letter-spacing: .03em; color: #fff;
}
.bus-linia-L1 { background: #00A107; }   /* Llevant */
.bus-linia-L2 { background: #DC0000; }   /* Ponent  */
.bus-linia-L3 { background: #1000CF; }
.bus-linia-L4 { background: #6B7A90; }

/* ── Distintius de tipus d'abonament ─────────────────────────────── */
.bus-abonament {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.bus-abonament-tbus    { background: var(--bus-blue-pale);   color: var(--bus-tbus); }
.bus-abonament-tbus65  { background: var(--bus-orange-pale); color: var(--bus-orange-dark); }

/* ── Estat de l'autobús al mapa i als llistats ───────────────────── */
.bus-estat { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.bus-estat-online  { color: #1f9d4d; }
.bus-estat-offline { color: #94a3b8; }
.bus-estat i { font-size: 9px; }
.bus-estat-online i { animation: busPulse 1.8s ease-in-out infinite; }

/* ── Mapa d'autobusos ────────────────────────────────────────────── */
.bus-mapa {
    width: 100%; height: 520px; border-radius: var(--card-radius);
    border: 1px solid #e2e8f0; overflow: hidden; background: #eef2f7;
}
/* Avís sota el mapa quan cap autobús no ha reportat posició. */
.bus-mapa-avis {
    margin-top: 10px; color: #64748b; font-size: 13px; text-align: center;
}
/* El mapa és de Leaflet: baixem els panells per sota dels modals i el menú. */
.bus-mapa .leaflet-pane,
.bus-mapa .leaflet-top,
.bus-mapa .leaflet-bottom { z-index: 2; }
.bus-mapa .leaflet-container { font: inherit; background: #eef2f7; }
.bus-mapa .leaflet-control-attribution { font-size: 10.5px; }

/* ── Fitxa de l'abonat: previsualització de la targeta ───────────── */
.bus-targeta-previ {
    border: 1px solid #e2e8f0; border-radius: 10px; background: #fff;
    padding: 10px; text-align: center;
}
.bus-targeta-previ img { max-width: 100%; height: auto; border-radius: 6px; }
.bus-targeta-previ .bus-targeta-peu {
    margin-top: 8px; font-size: 11.5px; color: #64748b;
}

/* ── Foto de l'abonat dins el formulari ──────────────────────────── */
.bus-foto-marc {
    width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden;
    border: 2px dashed #cbd5e1; background: #f8fafc;
    display: grid; place-items: center;
}
.bus-foto-marc img { width: 100%; height: 100%; object-fit: cover; }
.bus-foto-marc .bus-foto-buida { color: #94a3b8; font-size: 12.5px; text-align: center; padding: 10px; }

/* ── Càmera ─────────────────────────────────────────────────────── */
.bus-camera {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    aspect-ratio: 4 / 3;
    background: #0D1B2A;
    border-radius: 10px;
    overflow: hidden;
}

.bus-camera video,
.bus-camera img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Guia d'enquadrament: marca el retall vertical que va a la targeta. */
.bus-camera-guia {
    position: absolute;
    top: 6%;
    bottom: 6%;
    left: 50%;
    transform: translateX(-50%);
    aspect-ratio: 375 / 530;
    border: 2px dashed rgba(255, 255, 255, 0.75);
    border-radius: 6px;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.28);
    pointer-events: none;
}

.bus-camera-tria { max-width: 260px; }

/* ── Avisos de caducitat ─────────────────────────────────────────── */
.bus-caducat   { color: #d64550; font-weight: 600; }
.bus-caduca-aviat { color: var(--bus-orange-dark); font-weight: 600; }
