/* ============================================================
   maintenance.css — Módulo de Mantenimiento (Sistemas Ovopacific)
   V3.0 - Rediseño Premium y Organización de Vistas
   ============================================================ */

/* ── Animaciones de Vista ────────────────────────────────── */
.view-section {
    display: none;
    flex-direction: column;
    gap: 24px;
    padding: 24px 32px;
    animation: slideUp 0.3s ease-out;
}

.view-section.active {
    display: flex;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.anim-refresh {
    animation: fadeInScale 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInScale {
    from { opacity: 0.5; transform: scale(0.99); filter: blur(2px); }
    to { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* ── Filtro de Visualizador (Supervisor) ── */
.visualizer-filter-bar {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 12px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeIn 0.4s ease;
}

.visualizer-filter-bar label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #6366f1;
    margin: 0;
}

.visualizer-filter-bar select {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    color: #1f2937;
    outline: none;
    cursor: pointer;
    min-width: 200px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Spinner Checklist */
.checklist-spinner {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(16, 185, 129, 0.1);
    border-top-color: #10b981;
    border-radius: 50%;
    animation: checklist-spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes checklist-spin {
    to { transform: rotate(360deg); }
}

/* ── Formularios Premium ─────────────────────────────────── */
.mant-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    align-items: flex-end;
}

.mant-form .form-group.full-width {
    grid-column: 1 / -1;
}

.form-actions {
    margin-top: 10px;
}

/* ── Pills de Meses (Selector Actividades) ────────────────── */
.meses-pills-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.mes-pill-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 99px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mes-pill-label:hover {
    background: #f8fafc;
    border-color: var(--accent);
    color: var(--accent);
}

.mes-pill-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.mes-pill-label:has(input:checked) {
    background: rgba(91, 94, 244, 0.1);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

/* ── Cabeceras de Tabla (Meses/Días) ─────────────────────── */
.meses-header-labels, .dias-header-labels {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.meses-header-labels span, .dias-header-labels span {
    width: 32px;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* ── Bloques de Categoría en Tablas ──────────────────────── */
.mant-categoria-block {
    margin-bottom: 0;
    border-bottom: 1px solid #f1f5f9;
}

.mant-categoria-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
}

.mant-cat-icon {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.85rem;
}

.mant-cat-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #1e293b;
    flex: 1;
}

.mant-tarea-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    transition: background 0.15s ease;
}

.mant-tarea-row:hover {
    background: #f8fbff;
}

.mant-tarea-nombre {
    flex: 0 0 280px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mant-meses-row {
    display: flex;
    gap: 4px;
    flex: 1;
    justify-content: flex-end;
}

/* ── Puntos de Estado (Meses/Semanas) ─────────────────────── */
.mes-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.mes-dot.inactivo { background: #f1f5f9; color: #cbd5e1; }
.mes-dot.pendiente { 
    background: #fff1f2; color: #e11d48; border-color: #fecdd3; cursor: pointer; 
}
.mes-dot.completado { 
    background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; cursor: pointer; 
}

.mes-dot.completado.has-date {
    width: auto; padding: 0 8px; border-radius: 6px; font-size: 0.65rem;
}

.mes-dot:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Panel sin padding para tablas */
.panel-no-padding .panel-body { padding: 0 !important; overflow: visible; }
.panel-no-padding .table-wrap, 
.panel-no-padding .preventivo-scroll-wrap { border: none; border-radius: 0; }

/* Scrollbar Personalizado para Matrices (Muy visible) */
#prev-matrix-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
}
#prev-matrix-wrap::-webkit-scrollbar {
    height: 12px;
}
#prev-matrix-wrap::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}
#prev-matrix-wrap::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 10px;
    border: 3px solid #f1f5f9;
}
#prev-matrix-wrap::-webkit-scrollbar-thumb:hover {
    background: #4f46e5;
}

/* Estabilización de contenedores para evitar cortes */
.view-section {
    max-width: 100%;
}
.panel {
    max-width: 100%;
    margin-bottom: 24px;
}
.panel-body {
    max-width: 100%;
    overflow-x: auto;
}

/* ── Bitácora Premium Grid ──────────────────────────────── */
.bitacora-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.bitacora-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.bitacora-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.bitacora-img {
    width: 100%; height: 200px;
    object-fit: cover;
    cursor: zoom-in;
}

.bitacora-content { padding: 20px; }
.bitacora-date { 
    color: var(--accent); font-weight: 700; font-size: 0.8rem; margin-bottom: 8px;
    display: flex; align-items: center; gap: 8px;
}

/* ── Mantenimiento Preventivo (Hero & Detail) ──────────────── */
.prev-hero {
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #d946ef);
    padding: 32px;
    border-radius: 20px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.3);
}

.prev-hero h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
.prev-hero p { opacity: 0.85; font-size: 0.9rem; }

.prev-mes-selector-hero select {
    padding: 12px 20px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-weight: 700;
    backdrop-filter: blur(8px);
    outline: none;
    cursor: pointer;
}

/* Detail Panel */
.prev-detail-panel {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #6366f1;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.1);
    animation: slideFadeIn 0.4s ease-out;
}

@keyframes slideFadeIn {
    from { opacity: 0; filter: blur(4px); transform: scale(0.98); }
    to { opacity: 1; filter: blur(0); transform: scale(1); }
}

.prev-detail-header {
    background: #6366f1;
    color: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
}

.preventivo-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.preventivo-table th {
    background: #f8fafc;
    padding: 16px 24px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    letter-spacing: 0.05em;
}

.preventivo-table td {
    padding: 18px 24px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #334155;
    font-size: 0.9rem;
    background: #fff;
    transition: background 0.2s ease;
}

.preventivo-table tr:hover td {
    background: #f8fafc;
}

/* ── Formularios V3 ── */
.mant-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    background: #f8fafc;
    padding: 24px;
    border-radius: 12px;
    border: 1px dashed #cbd5e1;
    margin-bottom: 20px;
}
.mant-form .form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
    display: inline-block;
}
.mant-form input, .mant-form select, .mant-form textarea {
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.field-half {
    flex: 1;
    min-width: 250px;
}

/* Panel sin padding para tablas */
.panel-no-padding .panel-body {
    padding: 0;
}

/* ── Bitácora V3 ── */
.bitacora-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
    border: 1px solid #f1f5f9;
    transition: transform 0.3s, box-shadow 0.3s;
}
.bitacora-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 25px rgba(0,0,0,0.08);
}

/* ── Estados Dinámicos en Celdas ── */
.cell-week {
    transition: all 0.2s ease;
    text-align: center;
    color: transparent; /* Ocultamos el ícono si no queremos texto */
    position: relative;
    border: 1px solid #f1f5f9;
}

.cell-week:hover {
    background: rgba(99, 102, 241, 0.05);
    transform: scale(0.95);
}

.cell-week.res-realizado {
    background-color: #22c55e !important;
    color: #fff !important;
}

.cell-week.res-fallo {
    background-color: #ef4444 !important;
    color: #fff !important;
}

.cell-week.res-medio {
    background-color: #eab308 !important;
    color: #fff !important;
}

/* Sidebar Specific Polish */
#nav-links-tareas li.active {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .view-section { padding: 16px; }
    .prev-hero { flex-direction: column; text-align: center; gap: 20px; }
    .mant-tarea-nombre { flex: 1; }
    .mant-meses-row { display: none; } /* Hide on mobile if too crowded */
}

/* ── Premium Tareas UX ─────────────────────────────────── */
.mant-semanal-board {
    background: #fff;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03);
    border: 1px solid rgba(226, 232, 240, 0.8);
}
.mant-semanal-board-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.mant-semanal-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.mant-sem-card {
    background: #f8fafc;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}
.mant-sem-card:hover {
    background: #fff;
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-4px);
    box-shadow: 0 12px 20px rgba(99, 102, 241, 0.1);
}
.mant-sem-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.mant-sem-title {
    font-weight: 700;
    color: #0f172a;
    font-size: 0.95rem;
    line-height: 1.3;
}
.btn-sem-del {
    opacity: 0;
    transition: opacity 0.2s;
    background: transparent;
    color: #ef4444;
}
.mant-sem-card:hover .btn-sem-del {
    opacity: 1;
}
.mant-sem-info {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mant-sem-days {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}
.sem-dot {
    width: 38px;
    height: 38px;
    border-radius: 12px;
}
.sem-dot.completado i {
    font-size: 1.2rem;
}
/* Progress Bars */
.mant-cat-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mant-progress-bar {
    width: 100px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
}
.mant-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 99px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.mant-progress-pct {
    font-size: 0.8rem;
    font-weight: 800;
    color: #6366f1;
}
/* Pop Animation */
.anim-pop {
    animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes pop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ── Estilos para Reportes Diarios (Modal) ──────────────── */
#modal-logs-diarios .modal-content {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

#modal-logs-diarios .modal-header {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    padding: 20px 24px;
    border-bottom: none;
}

#form-log-diario {
    background: #f8fafc;
    border: 1px dashed #6366f1;
}

#form-log-diario .form-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
}

#form-log-diario input {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
}

#tbody-logs-diarios tr:nth-child(4n+1) {
    background: #fff;
}

#tbody-logs-diarios tr:nth-child(4n+3) {
    background: #f8fafc;
}

#tbody-logs-diarios td {
    padding: 12px 16px;
    font-size: 0.85rem;
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: #94a3b8;
    font-style: italic;
}

/* ── Checklist Semanal (Específico) ── */
.checklist-table th {
    background: #f1f5f9;
    color: #475569;
}

.checklist-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.checklist-dot:hover {
    transform: scale(1.15);
    filter: brightness(0.9);
}

.area-header-row td {
    border-bottom: 2px solid #fde68a !important;
}

.checklist-table tr:hover td {
    background: #f8fafc;
}

/* ── ESTILOS DEL CHECKLIST V2.0 ── */

.checklist-week-banner {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.badge-cerrada {
    background: rgba(245, 158, 11, 0.1) !important;
    color: #d97706 !important;
}

.row-cerrada td {
    background: #f8fafc !important;
    opacity: 0.9;
}

.area-header-row td {
    background-color: #fefce8 !important; /* Fondo beige */
    padding: 12px 24px !important;
    border-bottom: 2px solid #fde047 !important;
}

.area-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: #fff;
    margin-right: 10px;
    font-size: 0.8rem;
}

.inline-progress-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 300px;
}

.inline-progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(0,0,0,0.1);
    border-radius: 99px;
    overflow: hidden;
}

.inline-progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.5s ease;
}

.inline-progress-pct {
    font-weight: 800;
    font-size: 0.85rem;
    min-width: 40px;
}

.mini-progress-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.mini-progress-bar {
    width: 80px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.checklist-dot.dot-active {
    background-color: #10b981 !important;
    color: #fff !important;
    border-color: #10b981 !important;
    transform: scale(1.1);
}

.checklist-dot.dot-empty {
    background-color: #f1f5f9;
    color: transparent;
}

.checklist-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e2e8f0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
}

.checklist-dot:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border-color: #cbd5e1;
}

.tarea-nombre-cell {
    padding-left: 24px !important;
}

.tarea-nombre {
    font-weight: 600;
    color: #334155;
    font-size: 0.9rem;
}

.periodicity-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.periodicity-badge.periody {
    background: rgba(14, 165, 233, 0.1);
    color: #0ea5e9;
}

.periodicity-badge.periodsem {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.resumen-global-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    border: 1px dashed #cbd5e1;
    display: flex;
    align-items: center;
    gap: 32px;
    position: relative;
    overflow: hidden;
}

.resumen-global-left {
    flex-shrink: 0;
}

.resumen-global-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(closest-side, white 79%, transparent 80% 100%),
                conic-gradient(var(--color) var(--pct), #e2e8f0 0);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.resumen-pct-num {
    font-size: 1.8rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1;
}

.resumen-pct-label {
    font-size: 0.7rem;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 700;
    margin-top: 4px;
}

.resumen-global-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.resumen-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    color: #475569;
}

.resumen-global-barra-wrap {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 6px;
    background: #f1f5f9;
}

.resumen-global-fill {
    height: 100%;
}
