/**
 * Sistema de Mantenimiento - Estilos Mantenimientos
 * MACROGRAM Ecuador
 */

/* ============================================
   VARIABLES
   ============================================ */
:root {
    --mant-primary: #1a3a5c;
    --mant-secondary: #f57c00;
    --mant-success: #2e7d32;
    --mant-warning: #ed6c02;
    --mant-danger: #d32f2f;
    --mant-info: #0288d1;
    --mant-gray: #64748b;
    --mant-light: #f8fafc;
    --mant-border: #e2e8f0;
    --mant-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --mant-shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --mant-radius: 8px;
    --mant-radius-sm: 4px;
}

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
.mantenimientos-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ============================================
   ESTADÍSTICAS
   ============================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

@media (max-width: 992px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .stats-row {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fff;
    padding: 1rem 1.25rem;
    border-radius: var(--mant-radius);
    box-shadow: var(--mant-shadow);
    border: 1px solid var(--mant-border);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.bg-primary-light {
    background: rgba(26, 58, 92, 0.1);
    color: var(--mant-primary);
}

.stat-icon.bg-success-light {
    background: rgba(46, 125, 50, 0.1);
    color: var(--mant-success);
}

.stat-icon.bg-warning-light {
    background: rgba(237, 108, 2, 0.1);
    color: var(--mant-warning);
}

.stat-icon.bg-info-light {
    background: rgba(2, 136, 209, 0.1);
    color: var(--mant-info);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--mant-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--mant-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   FILTROS
   ============================================ */
.filtros-card {
    background: #fff;
    padding: 1rem 1.25rem;
    border-radius: var(--mant-radius);
    box-shadow: var(--mant-shadow);
    border: 1px solid var(--mant-border);
}

.filtros-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}

.filtro-grupo {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 140px;
}

.filtro-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--mant-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filtro-acciones {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

/* ============================================
   TABLA DE MANTENIMIENTOS
   ============================================ */
.tabla-card {
    background: #fff;
    border-radius: var(--mant-radius);
    box-shadow: var(--mant-shadow);
    border: 1px solid var(--mant-border);
    overflow: hidden;
}

.tabla-responsive {
    overflow-x: auto;
}

.tabla-mantenimientos {
    width: 100%;
    border-collapse: collapse;
}

.tabla-mantenimientos thead {
    background: var(--mant-light);
    border-bottom: 2px solid var(--mant-border);
}

.tabla-mantenimientos th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--mant-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.tabla-mantenimientos td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--mant-border);
    vertical-align: middle;
}

.tabla-mantenimientos tbody tr:hover {
    background: rgba(26, 58, 92, 0.02);
}

.tabla-mantenimientos tbody tr:last-child td {
    border-bottom: none;
}

.mant-id {
    font-weight: 600;
    color: var(--mant-primary);
    font-family: monospace;
    font-size: 0.875rem;
}

.mant-peaje {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.peaje-nombre {
    font-weight: 600;
    color: var(--mant-primary);
}

.peaje-concesion {
    font-size: 0.75rem;
    color: var(--mant-gray);
}

.mant-fechas {
    font-size: 0.85rem;
    color: #334155;
    white-space: nowrap;
}

.mant-tecnico {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tecnico-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--mant-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
}

.tecnico-nombre {
    font-size: 0.85rem;
}

.estado-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--estado-color) 15%, white);
    color: var(--estado-color);
    border: 1px solid color-mix(in srgb, var(--estado-color) 30%, transparent);
}

.progreso-mini {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progreso-barra {
    width: 60px;
    height: 6px;
    background: var(--mant-border);
    border-radius: 3px;
    overflow: hidden;
}

.progreso-fill {
    height: 100%;
    background: var(--mant-secondary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progreso-texto {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--mant-gray);
    min-width: 32px;
}

.tabla-footer {
    padding: 1rem;
    border-top: 1px solid var(--mant-border);
    display: flex;
    justify-content: center;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--mant-gray);
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 0.5rem;
    display: block;
}

/* ============================================
   DETALLE DE MANTENIMIENTO
   ============================================ */
.mant-detalle-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.mant-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: #fff;
    padding: 1.5rem;
    border-radius: var(--mant-radius);
    box-shadow: var(--mant-shadow);
    border: 1px solid var(--mant-border);
    gap: 1rem;
    flex-wrap: wrap;
}

.mant-header-info {
    flex: 1;
}

.mant-titulo h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--mant-primary);
    display: flex;
    align-items: center;
}

.mant-concesion {
    display: block;
    font-size: 0.875rem;
    color: var(--mant-gray);
    margin-top: 0.25rem;
    padding-left: 2rem;
}

.mant-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    padding-left: 2rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.85rem;
    color: var(--mant-gray);
}

.meta-item i {
    color: var(--mant-secondary);
}

.estado-badge-lg {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--estado-color) 15%, white);
    color: var(--estado-color);
    border: 1px solid color-mix(in srgb, var(--estado-color) 30%, transparent);
}

/* ============================================
   PROGRESO GENERAL
   ============================================ */
.progreso-general-card {
    background: #fff;
    border-radius: var(--mant-radius);
    box-shadow: var(--mant-shadow);
    border: 1px solid var(--mant-border);
    overflow: hidden;
}

.progreso-header {
    padding: 1rem 1.25rem;
    background: var(--mant-light);
    border-bottom: 1px solid var(--mant-border);
}

.progreso-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--mant-primary);
}

.progreso-body {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    gap: 2rem;
    flex-wrap: wrap;
}

.progreso-circular {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.circular-chart {
    display: block;
    width: 100%;
    height: 100%;
}

.circle-bg {
    fill: none;
    stroke: var(--mant-border);
    stroke-width: 3;
}

.circle {
    fill: none;
    stroke: var(--mant-secondary);
    stroke-width: 3;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    transition: stroke-dasharray 0.5s ease;
}

.percentage {
    fill: var(--mant-primary);
    font-family: inherit;
    font-size: 0.5em;
    font-weight: 700;
    text-anchor: middle;
}

.progreso-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    flex: 1;
    justify-content: center;
}

.progreso-stats .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.progreso-stats .stat-numero {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--mant-primary);
}

.progreso-stats .stat-label {
    font-size: 0.7rem;
    color: var(--mant-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   TABS DE CONTENIDO
   ============================================ */
.mant-tabs-container {
    background: #fff;
    border-radius: var(--mant-radius);
    box-shadow: var(--mant-shadow);
    border: 1px solid var(--mant-border);
    overflow: hidden;
}

.mant-tabs {
    border-bottom: 1px solid var(--mant-border);
    background: var(--mant-light);
    padding: 0 1rem;
}

.mant-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    padding: 1rem 1.25rem;
    color: var(--mant-gray);
    font-weight: 500;
    transition: all 0.2s;
}

.mant-tabs .nav-link:hover {
    color: var(--mant-primary);
    background: transparent;
}

.mant-tabs .nav-link.active {
    color: var(--mant-secondary);
    background: transparent;
    border-bottom-color: var(--mant-secondary);
}

.mant-tabs .badge {
    font-size: 0.65rem;
}

.mant-tab-content {
    padding: 1.25rem;
    min-height: 300px;
}

/* ============================================
   VÍAS Y EQUIPOS
   ============================================ */
.vias-info-card {
    background: var(--mant-light);
    border: 1px solid var(--mant-border);
    border-radius: var(--mant-radius-sm);
    padding: 0.75rem 1rem;
}

.vias-info-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--mant-gray);
}

.vias-info-header i {
    color: var(--mant-secondary);
}

.vias-pendientes-card {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: var(--mant-radius-sm);
    padding: 0.75rem 1rem;
}

.vias-pendientes-header {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: #92400e;
    margin-bottom: 0.5rem;
}

.vias-pendientes-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.vias-pendientes-body .badge {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.4rem 0.6rem;
}

.via-card {
    border: 1px solid var(--mant-border);
    border-radius: var(--mant-radius);
    margin-bottom: 1rem;
    overflow: hidden;
}

.via-card:last-child {
    margin-bottom: 0;
}

.via-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--mant-light);
    cursor: pointer;
    transition: background 0.2s;
    gap: 1rem;
}

.via-header:hover {
    background: #f1f5f9;
}

.via-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.via-icon {
    color: var(--mant-secondary);
    font-size: 1.25rem;
}

.via-nombre {
    display: flex;
    flex-direction: column;
}

.via-nombre strong {
    color: var(--mant-primary);
}

.via-nombre small {
    color: var(--mant-gray);
    font-size: 0.75rem;
}

.via-progreso {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progreso-barra-via {
    width: 100px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.collapse-icon {
    color: var(--mant-gray);
    transition: transform 0.3s;
}

.collapse-icon.rotated {
    transform: rotate(180deg);
}

.via-body {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #fff;
}

/* ============================================
   EQUIPOS
   ============================================ */
.equipo-card {
    border: 1px solid var(--mant-border);
    border-radius: var(--mant-radius-sm);
    overflow: hidden;
    border-left: 4px solid var(--mant-gray);
    margin-bottom: 0.75rem;
}

.equipo-card:last-child {
    margin-bottom: 0;
}

.equipo-card.estado-completado {
    border-left-color: var(--mant-success);
}

.equipo-card.estado-con_observaciones {
    border-left-color: var(--mant-warning);
}

.equipo-card.estado-en_progreso {
    border-left-color: var(--mant-info);
}

.equipo-card.estado-pendiente {
    border-left-color: var(--mant-gray);
}

.equipo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #fafbfc;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.equipo-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.equipo-tipo {
    font-weight: 600;
    color: var(--mant-primary);
    font-size: 0.9rem;
}

.equipo-tipo i {
    margin-right: 0.375rem;
    color: var(--mant-secondary);
}

.equipo-detalle {
    font-size: 0.8rem;
    color: var(--mant-gray);
}

.equipo-serie {
    font-size: 0.75rem;
    color: var(--mant-gray);
    font-family: monospace;
}

.equipo-estado {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.equipo-progreso {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--mant-gray);
    background: #e2e8f0;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.equipo-checklist {
    border-top: 1px solid var(--mant-border);
}

.tabla-checklist {
    width: 100%;
    font-size: 0.85rem;
}

.tabla-checklist th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    background: #fafbfc;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--mant-gray);
    text-transform: uppercase;
    border-bottom: 1px solid var(--mant-border);
}

.tabla-checklist td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--mant-border);
}

.tabla-checklist tr:last-child td {
    border-bottom: none;
}

.estado-equipo-badge {
    display: inline-flex;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--color) 15%, white);
    color: var(--color);
}

.observacion-texto {
    font-style: italic;
    color: #64748b;
}

.empty-equipos {
    text-align: center;
    padding: 2rem;
    color: var(--mant-gray);
}

.empty-equipos i {
    font-size: 2rem;
    opacity: 0.3;
    display: block;
    margin-bottom: 0.5rem;
}

/* ============================================
   TIMELINE HISTORIAL
   ============================================ */
.historial-timeline {
    position: relative;
    padding-left: 2rem;
}

.historial-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--mant-border);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -2rem;
    top: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--mant-gray);
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px var(--mant-border);
}

.timeline-content {
    background: var(--mant-light);
    padding: 1rem;
    border-radius: var(--mant-radius-sm);
    border: 1px solid var(--mant-border);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.timeline-estado {
    font-weight: 600;
    color: var(--mant-primary);
}

.timeline-fecha {
    font-size: 0.8rem;
    color: var(--mant-gray);
}

.timeline-body p {
    margin: 0.25rem 0;
    font-size: 0.85rem;
    color: var(--mant-gray);
}

.timeline-usuario i,
.timeline-gps i {
    margin-right: 0.375rem;
}

.timeline-gps a {
    color: var(--mant-info);
    text-decoration: none;
}

.timeline-gps a:hover {
    text-decoration: underline;
}

.timeline-obs {
    font-style: italic;
    padding: 0.5rem;
    background: #fff;
    border-radius: 4px;
    margin-top: 0.5rem !important;
}

/* ============================================
   EVIDENCIAS
   ============================================ */
.evidencias-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.evidencia-card {
    border: 1px solid var(--mant-border);
    border-radius: var(--mant-radius-sm);
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.2s;
}

.evidencia-card:hover {
    box-shadow: var(--mant-shadow-md);
}

.evidencia-preview {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mant-light);
    overflow: hidden;
}

.evidencia-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.evidencia-preview.evidencia-file {
    background: linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 100%);
}

.evidencia-preview.evidencia-file i {
    font-size: 2.5rem;
    color: var(--mant-gray);
}

.evidencia-info {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.evidencia-nombre {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--mant-primary);
}

.evidencia-desc {
    font-size: 0.75rem;
    color: var(--mant-gray);
}

.evidencia-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--mant-gray);
    margin-top: 0.25rem;
}

/* ============================================
   APROBACIÓN
   ============================================ */
.aprobacion-card {
    border-radius: var(--mant-radius);
    overflow: hidden;
    border: 1px solid var(--mant-border);
    max-width: 500px;
}

.aprobacion-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.aprobacion-header.aprobado {
    background: rgba(46, 125, 50, 0.1);
    color: var(--mant-success);
}

.aprobacion-header.rechazado {
    background: rgba(211, 47, 47, 0.1);
    color: var(--mant-danger);
}

.aprobacion-header i {
    font-size: 1.5rem;
}

.aprobacion-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.aprobacion-detalle {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.aprobacion-detalle label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--mant-gray);
    text-transform: uppercase;
}

.aprobacion-detalle span {
    color: var(--mant-primary);
}

.aprobacion-detalle.rechazo span {
    color: var(--mant-danger);
    background: rgba(211, 47, 47, 0.05);
    padding: 0.5rem;
    border-radius: 4px;
    border-left: 3px solid var(--mant-danger);
}

/* ============================================
   FOOTER
   ============================================ */
.mant-footer {
    display: flex;
    justify-content: flex-start;
    padding-top: 0.5rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .mant-header {
        flex-direction: column;
    }

    .mant-meta {
        padding-left: 0;
    }

    .mant-concesion {
        padding-left: 0;
    }

    .progreso-body {
        flex-direction: column;
        text-align: center;
    }

    .progreso-barra-via {
        width: 60px;
    }

    .equipo-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tabla-checklist {
        font-size: 0.75rem;
    }

    .tabla-checklist th,
    .tabla-checklist td {
        padding: 0.375rem 0.5rem;
    }
}
