/* NAVBAR */
#nav-logo {
    width: 280px;
    height: 55px
}

/* HOME */
input[type="checkbox"], span.material-icons, span.bi {
    cursor: pointer;
}

span.bi {
    font-size: 1.5rem;
}

input[name="fechaDespacho"]::-webkit-calendar-picker-indicator {
    background: transparent;
    bottom: 0;
    color: transparent;
    height: auto;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    width: auto;
}

body {
    background-image: url('https://i.imgur.com/uCGeCvN.png');
}

.ui-autocomplete.ui-widget {
    font-family: 'Gill Sans', 'Gill Sans MT', 'Calibri', 'Trebuchet MS', sans-serif;
    position: fixed;
}

.errorlist li {
    list-style-type: none;
    text-align: center;
}

.asteriskField {
    color: red;
}

.page-item {
    cursor: pointer;
}

.select-readonly {
    pointer-events: none;
    background-color: #e9ecef;
    color: #495057;
}

.loading-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
}

.loading-btn:disabled {
    cursor: not-allowed;
    position: relative;
}

.loading-btn:disabled span {
    visibility: hidden;
}

.loading-btn:disabled::after {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: black;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: spin 0.8s linear infinite;
}

.loading-submit-btn:disabled {
    cursor: not-allowed;
    position: relative;
    color: transparent !important;
}

.loading-submit-btn:disabled::after {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@media (max-width: 600px) {
    span.bi {
        font-size: 2rem;
    }

    table {
        width: 100%;
        table-layout: fixed;
    }

    th, td {
        word-wrap: break-word;
        white-space: normal;
    }
}

#div_id_date {
    display: flex;
    align-items: center;
}

.info-tag {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    background: #f1f2f6;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #dcdde1;
}

.info-tag .dot {
    height: 8px;
    width: 8px;
    background-color: #2ed573;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse 2s infinite;
}

.info-tag span {
    font-size: 13px;
    color: #2f3542;
    font-family: 'Inter', sans-serif;
}

/* Unit more info modal */
.unit-info-header {
    background-color: #343a40;
    color: #fff;
}

.unit-info-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.15rem 0.75rem;
    font-size: 0.875rem;
}

.unit-info-dl dt {
    font-weight: 600;
    color: #6c757d;
    white-space: nowrap;
}

.unit-info-dl dd {
    margin: 0;
    color: #212529;
}

/* Timeline */
.unit-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 2px solid #dee2e6;
}

.unit-timeline__item {
    position: relative;
    padding: 0 0 1.25rem 2.25rem;
}

.unit-timeline__dot {
    position: absolute;
    left: -16px;
    top: 0.1rem;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #6c757d;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    box-shadow: 0 0 0 3px #fff;
}

.unit-timeline__state {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    color: #212529;
}

.unit-timeline__meta {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.15rem;
}

/* Filter panel */
.filter-panel {
    margin-bottom: 1rem;
}

.filter-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #495057;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    margin-bottom: 0.5rem;
}

.filter-toggle-btn:hover {
    background: #e9ecef;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.filter-chevron {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.filter-toggle-btn[aria-expanded="true"] .filter-chevron {
    transform: rotate(180deg);
}

/* "Más filtros" toggle */
.more-filters-bar {
    display: flex;
    margin: .25rem 0 .5rem;
}

.more-filters-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .75rem;
    font-size: .875rem;
    font-weight: 500;
    color: #495057;
    background: transparent;
    border: 1px solid transparent;
    border-radius: .5rem;
    cursor: pointer;
    transition: background .15s ease-in-out, color .15s ease-in-out;
}

.more-filters-btn:hover {
    color: var(--bs-primary);
    background: #f1f3f5;
}

.more-filters-count {
    min-width: 1.25rem;
    padding: 0 .35rem;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.25rem;
    color: #fff;
    text-align: center;
    background: var(--bs-primary);
    border-radius: 999px;
}

.more-filters-chevron {
    font-size: .75rem;
    transition: transform .2s ease;
}

.more-filters-btn[aria-expanded="true"] .more-filters-chevron {
    transform: rotate(180deg);
}

/* Date range + quick presets */
.date-range {
    display: flex;
    flex-wrap: nowrap;
    gap: .5rem;
}

.date-range > .form-floating {
    flex: 1 1 0;
    min-width: 0;
}

.date-range .form-control {
    min-width: 0;
}

.date-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
}

.date-preset {
    padding: .3rem .8rem;
    font-size: .8125rem;
    color: #495057;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s ease-in-out, border-color .15s ease-in-out, color .15s ease-in-out;
}

.date-preset:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.date-preset.is-active {
    color: #fff;
    background: var(--bs-primary);
    border-color: var(--bs-primary);
}

.date-preset--clear {
    margin-left: .5rem;
    color: #6c757d;
    background: transparent;
    border-style: dashed;
}

/* Presets sit under the date range they belong to once the row is wide. */
@media (min-width: 1200px) {
    .date-presets {
        justify-content: flex-end;
    }
}

/* Table loading overlay */
#table-loading {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.65);
    justify-content: center;
    align-items: center;
    z-index: 10;
    pointer-events: none;
}

#table-loading.htmx-request {
    display: flex;
}

.bouncing-dots {
    display: flex;
    gap: 8px;
}

.bouncing-dots span {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--bs-primary);
    border-radius: 50%;
    animation: dot-bounce 0.5s ease-in-out infinite alternate;
}

.bouncing-dots span:nth-child(2) { animation-delay: 0.15s; }
.bouncing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot-bounce {
    from { transform: translateY(0); opacity: 0.6; }
    to   { transform: translateY(-12px); opacity: 1; }
}

/* Table swaps (pagination, sorting, filtering) animate through the View
   Transitions API. Browsers without support just swap instantly. */
.table-container {
    view-transition-name: table-content;
}

::view-transition-group(table-content) {
    animation-duration: 260ms;
}

/* Snapshots keep their natural height so a page with fewer rows does not
   squash the outgoing one while the group resizes. */
::view-transition-old(table-content),
::view-transition-new(table-content) {
    height: auto;
    width: 100%;
}

::view-transition-old(table-content) {
    animation: table-swap-out 140ms cubic-bezier(0.4, 0, 1, 1) both;
}

::view-transition-new(table-content) {
    animation: table-swap-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes table-swap-out {
    to {
        opacity: 0;
        transform: translateY(-6px) scale(0.995);
    }
}

@keyframes table-swap-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.995);
    }
}

/* The rest of the page is only repainted, not animated. */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 140ms;
}

@media (prefers-reduced-motion: reduce) {
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
        animation: none !important;
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
    100% {
        opacity: 1;
    }
}

/* Form sections */
.form-section {
    margin-bottom: 2rem;
}

.form-section > legend {
    float: none;
    width: auto;
    font-size: 1.15rem;
    font-weight: 600;
    color: #495057;
    padding-bottom: .5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid #dee2e6;
}

.payment-file-dots {
    display: inline-block;
    margin-left: .15rem;
}

.payment-file-dots span {
    opacity: .2;
    animation: payment-file-dot 1.2s infinite ease-in-out;
}

.payment-file-dots span:nth-child(2) {
    animation-delay: .2s;
}

.payment-file-dots span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes payment-file-dot {
    0%, 70%, 100% {
        opacity: .2;
    }
    35% {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .payment-file-dots span {
        animation: none;
        opacity: .6;
    }
}

.capture-wait-bar {
    height: 6px;
    background-color: rgba(255, 255, 255, .45);
    border-radius: 3px;
    overflow: hidden;
}

.capture-wait-bar > div {
    height: 100%;
    width: 0;
    background-color: currentColor;
    border-radius: inherit;
    animation-name: capture-wait-fill;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

@keyframes capture-wait-fill {
    to {
        width: 100%;
    }
}

.battery-recheck {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    --bs-btn-bg: var(--bs-white);
    box-shadow: 0 1px 3px rgba(var(--bs-danger-rgb), 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.battery-recheck .bi {
    display: inline-block;
    line-height: 1;
}

.battery-recheck:hover,
.battery-recheck:focus-visible {
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(var(--bs-danger-rgb), 0.45);
}

.battery-recheck.htmx-request .bi {
    animation: battery-recheck-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .capture-wait-bar > div {
        animation: none;
    }

    .battery-recheck,
    .battery-recheck.htmx-request .bi {
        transition: none;
        animation: none;
    }
}
