/* ─── Seguimiento de Ordenes de Trabajo ─── */

.ot-suggest-wrap {
    position: relative;
    width: 100%;
}

.ot-suggest-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    max-height: 200px;
    overflow-y: auto;
    margin-top: 2px;
}

.ot-suggest-dropdown.active {
    display: block;
}

.ot-suggest-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.82rem;
    color: #1e293b;
    transition: background 0.1s;
}

.ot-suggest-item:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.ot-suggest-item small {
    color: #94a3b8;
    font-size: 0.72rem;
    margin-left: 4px;
}

body[data-theme="dark"] .ot-suggest-dropdown {
    background: #1e293b;
    border-color: #475569;
}

body[data-theme="dark"] .ot-suggest-item {
    color: #e2e8f0;
}

body[data-theme="dark"] .ot-suggest-item:hover {
    background: #334155;
    color: #93c5fd;
}

body[data-theme="dark"] .ot-suggest-item small {
    color: #64748b;
}

.order-tracking-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.order-tracking-header-info {
    flex: 1;
    min-width: 280px;
}

.order-tracking-header-info h2 {
    margin: 0 0 6px 0;
    font-size: 1.35rem;
    font-weight: 800;
    color: #1e293b;
}

.order-tracking-header-info p {
    margin: 0;
    font-size: 0.85rem;
    color: #64748b;
}

.order-tracking-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.order-tracking-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.order-tracking-summary-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.order-tracking-summary-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.order-tracking-summary-card strong {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.1;
}

.order-tracking-summary-card span {
    display: block;
    margin-top: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.order-tracking-summary-card.alert strong {
    color: #ea580c;
}

.order-tracking-summary-card.alert span {
    color: #ea580c;
}

.order-tracking-filters {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.order-tracking-filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
}

.order-tracking-filters-row label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

.order-tracking-filters-row label input,
.order-tracking-filters-row label select {
    padding: 8px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.85rem;
    color: #1e293b;
    background: #f8fafc;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
    box-sizing: border-box;
}

.order-tracking-filters-row label input:focus,
.order-tracking-filters-row label select:focus {
    border-color: #3b82f6;
    background: #ffffff;
}

.order-tracking-filters-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}

.order-tracking-filters-checks label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}

.order-tracking-filters-checks input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #3b82f6;
    cursor: pointer;
}

.order-tracking-filters-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.order-tracking-table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.order-tracking-table {
    width: 100%;
    min-width: 1100px;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.order-tracking-table thead {
    background: linear-gradient(180deg, #f7faff, #eef4fc);
    position: sticky;
    top: 0;
    z-index: 1;
}

.order-tracking-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.order-tracking-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.12s;
}

.order-tracking-table tbody tr:hover {
    background: #f8fafc;
}

.order-tracking-table tbody td {
    padding: 10px 12px;
    vertical-align: middle;
    color: #334155;
}

.order-tracking-table .ot-placa {
    font-weight: 800;
    color: #1e293b;
    font-size: 0.9rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    text-align: left;
}

.order-tracking-table .ot-placa:hover {
    color: #3b82f6;
}

.order-tracking-table .ot-visitas {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.order-tracking-table .ot-visitas.ot-recurrente {
    background: #dbeafe;
    color: #1d4ed8;
}

.order-tracking-table .ot-visitas.ot-una {
    background: #f1f5f9;
    color: #64748b;
}

.order-tracking-table .ot-motivo {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-tracking-table .ot-sin-motivo {
    color: #ea580c;
    font-style: italic;
}

.order-tracking-table .ot-anulada {
    opacity: 0.55;
}

.order-tracking-table .ot-anulada td {
    text-decoration: line-through;
}

.order-tracking-table .ot-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.order-tracking-table .ot-actions button {
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
}

.order-tracking-table .ot-actions button:hover {
    background: #e2e8f0;
}

.order-tracking-empty {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.order-tracking-empty i {
    font-size: 2rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.order-tracking-loading {
    text-align: center;
    padding: 30px;
    color: #64748b;
}

.order-tracking-loading i {
    font-size: 1.5rem;
    animation: fa-spin 1s infinite linear;
}

/* Panel de detalle lateral */
.order-tracking-detail {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    max-width: 92vw;
    height: 100vh;
    background: #ffffff;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.15);
    z-index: 10050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ot-slide-in 0.2s ease;
}

.order-tracking-detail-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10049;
    background: rgba(15, 23, 42, 0.45);
}

.order-tracking-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    gap: 10px;
    flex-wrap: wrap;
    color: #64748b;
    font-size: 0.8rem;
}

.order-tracking-pagination label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.order-tracking-pagination select {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 4px 6px;
    background: #fff;
    color: inherit;
}

.order-tracking-pagination-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.order-tracking-pagination-actions .active {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

@keyframes ot-slide-in {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

.order-tracking-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #ffffff;
    flex-shrink: 0;
}

.order-tracking-detail-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
}

.order-tracking-detail-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.order-tracking-detail-close:hover {
    background: rgba(239, 68, 68, 0.3);
}

.order-tracking-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.ot-detail-section {
    margin-bottom: 18px;
}

.ot-detail-section h4 {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin: 0 0 8px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
}

.ot-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ot-detail-grid div {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 10px;
}

.ot-detail-grid dt {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 2px;
}

.ot-detail-grid dd {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e293b;
}

.ot-detail-motivo {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.85rem;
    color: #1e40af;
    font-weight: 600;
    line-height: 1.4;
}

.ot-detail-timeline {
    position: relative;
    padding-left: 18px;
}

.ot-detail-timeline::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: #e2e8f0;
}

.ot-detail-timeline-item {
    position: relative;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.ot-detail-timeline-item::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 2px #3b82f6;
}

.ot-detail-timeline-item.ot-anulada-item::before {
    background: #94a3b8;
    box-shadow: 0 0 0 2px #94a3b8;
}

.ot-detail-timeline-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.ot-detail-timeline-date {
    font-size: 0.72rem;
    color: #94a3b8;
    font-weight: 600;
}

.ot-detail-timeline-motivo {
    font-size: 0.82rem;
    color: #1e293b;
    font-weight: 600;
    margin: 2px 0;
}

.ot-detail-timeline-servicio {
    font-size: 0.75rem;
    color: #64748b;
}

.ot-detail-timeline-tech {
    font-size: 0.72rem;
    color: #64748b;
}

.ot-detail-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

/* Sub-navegacion dentro de Documentos */
.order-tracking-subnav {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0;
}

.order-tracking-subnav-btn {
    padding: 8px 16px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #64748b;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.15s;
}

.order-tracking-subnav-btn:hover {
    color: #1e293b;
}

.order-tracking-subnav-btn.active {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
}

/* Responsive: mobile cards */
@media (max-width: 768px) {
    .order-tracking-table-wrap {
        display: none;
    }

    .order-tracking-cards {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .ot-card {
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        padding: 14px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    }

    .ot-card-head {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 8px;
    }

    .ot-card-placa {
        font-size: 1.1rem;
        font-weight: 800;
        color: #1e293b;
    }

    .ot-card-visitas {
        display: inline-flex;
        align-items: center;
        padding: 2px 10px;
        border-radius: 12px;
        font-size: 0.72rem;
        font-weight: 700;
        background: #dbeafe;
        color: #1d4ed8;
    }

    .ot-card-motivo {
        font-size: 0.82rem;
        color: #475569;
        margin-bottom: 6px;
        line-height: 1.3;
    }

    .ot-card-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
        font-size: 0.75rem;
        color: #64748b;
        margin-bottom: 8px;
    }

    .ot-card-actions {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
    }

    .order-tracking-detail {
        width: 100vw;
        max-width: 100vw;
    }
}

/* Dark theme support */
body[data-theme="dark"] .order-tracking-header-info h2 {
    color: #f1f5f9;
}

body[data-theme="dark"] .order-tracking-header-info p {
    color: #94a3b8;
}

body[data-theme="dark"] .order-tracking-summary-card,
body[data-theme="dark"] .order-tracking-filters,
body[data-theme="dark"] .order-tracking-table-wrap,
body[data-theme="dark"] .ot-card {
    background: #1e293b;
    border-color: #334155;
}

body[data-theme="dark"] .order-tracking-summary-card strong {
    color: #f1f5f9;
}

body[data-theme="dark"] .order-tracking-filters-row label {
    color: #94a3b8;
}

body[data-theme="dark"] .order-tracking-filters-row label input,
body[data-theme="dark"] .order-tracking-filters-row label select {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

body[data-theme="dark"] .order-tracking-table thead {
    background: linear-gradient(180deg, #1e293b, #0f172a);
}

body[data-theme="dark"] .order-tracking-table thead th {
    color: #94a3b8;
    border-bottom-color: #334155;
}

body[data-theme="dark"] .order-tracking-table tbody tr {
    border-bottom-color: #334155;
}

body[data-theme="dark"] .order-tracking-table tbody tr:hover {
    background: #334155;
}

body[data-theme="dark"] .order-tracking-table tbody td {
    color: #cbd5e1;
}

body[data-theme="dark"] .order-tracking-table .ot-placa {
    color: #f1f5f9;
}

body[data-theme="dark"] .ot-detail-grid div {
    background: #0f172a;
    border-color: #334155;
}

body[data-theme="dark"] .ot-detail-grid dd {
    color: #f1f5f9;
}

body[data-theme="dark"] .ot-detail-motivo {
    background: #1e3a5f;
    border-color: #1d4ed8;
    color: #93c5fd;
}

body[data-theme="dark"] .order-tracking-subnav {
    border-bottom-color: #334155;
}

body[data-theme="dark"] .order-tracking-subnav-btn {
    color: #94a3b8;
}

body[data-theme="dark"] .order-tracking-subnav-btn.active {
    color: #93c5fd;
    border-bottom-color: #3b82f6;
}

body[data-theme="dark"] .order-tracking-detail {
    background: #1e293b;
}

body[data-theme="dark"] .order-tracking-pagination select {
    background: #0f172a;
    border-color: #334155;
    color: #cbd5e1;
}

body[data-theme="dark"] .order-tracking-detail-body {
    color: #cbd5e1;
}

body[data-theme="dark"] .ot-detail-timeline-item {
    border-bottom-color: #334155;
}

body[data-theme="dark"] .ot-detail-timeline-tech {
    color: #94a3b8;
}

body[data-theme="dark"] .ot-detail-timeline-motivo {
    color: #e2e8f0;
}

body[data-theme="dark"] .ot-detail-timeline-servicio {
    color: #94a3b8;
}

body[data-theme="dark"] .ot-card {
    background: #1e293b;
    border-color: #334155;
}

body[data-theme="dark"] .ot-card-head,
body[data-theme="dark"] .ot-card-placa {
    color: #f1f5f9;
}

body[data-theme="dark"] .ot-card-motivo {
    color: #cbd5e1;
}

body[data-theme="dark"] .ot-card-meta {
    color: #94a3b8;
}

body[data-theme="dark"] .ot-card-visitas {
    background: #1e3a5f;
    color: #93c5fd;
}

body[data-theme="dark"] .order-tracking-empty,
body[data-theme="dark"] .order-tracking-loading {
    color: #94a3b8;
}

body[data-theme="dark"] .order-tracking-summary-card.alert strong {
    color: #f97316;
}
