/* ========================================================================== */
/* ERRORES CALIDAD PAGE - Reporte de Errores de Calidad                     */
/* ========================================================================== */

.main-content:has(.errores-page) {
    padding: 0 !important;
}

.errores-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 95px);
    width: 100%;
    padding: 0;
    overflow: hidden;
    background: var(--bg-primary);
}

.errores-page .camara-panel {
    margin: 0;
    padding: 0.75rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.errores-page .camara-header {
    margin: 0 0 0.5rem 0;
    padding: 0.25rem 0.5rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    position: relative;
}

.errores-page .camara-header .calendar-year-selector-main {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.errores-page .camara-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.5rem;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

.errores-page .camara-body > * {
    width: 100%;
    box-sizing: border-box;
}

/* ========================================================================== */
/* LOADING STATE                                                              */
/* ========================================================================== */

.errores-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ========================================================================== */
/* CICLO BAR                                                                  */
/* ========================================================================== */

.errores-ciclo-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.ciclo-bar-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-secondary);
}

.ciclo-bar-left svg {
    color: #00b4ff;
    flex-shrink: 0;
}

.ciclo-bar-label {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.ciclo-bar-sep {
    color: var(--border-color);
}

.ciclo-bar-dates {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ciclo-bar-right {
    flex-shrink: 0;
}

.ciclo-bar-total {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
}

.ciclo-bar-total.has-errors {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.ciclo-bar-total.no-errors {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

/* ========================================================================== */
/* EMPTY STATE                                                                */
/* ========================================================================== */

.errores-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    width: 100%;
    flex: 1 0 auto;
    min-height: calc(100% - 120px);
    box-sizing: border-box;
}

.errores-empty-state .empty-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(240, 116, 0, 0.08), rgba(0, 180, 255, 0.08));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.errores-empty-state .empty-icon svg {
    color: var(--text-secondary);
    opacity: 0.6;
}

.errores-empty-state h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.errores-empty-state p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0;
    max-width: 400px;
}

/* ========================================================================== */
/* SUMMARY CARDS                                                              */
/* ========================================================================== */

.errores-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    flex-shrink: 0;
}

.err-summary-card {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.9rem 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.err-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.err-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.err-icon-total {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.err-icon-campos {
    background: rgba(240, 116, 0, 0.12);
    color: #F07400;
}

.err-icon-usuarios {
    background: rgba(0, 180, 255, 0.12);
    color: #00b4ff;
}

.err-icon-rutas {
    background: rgba(168, 85, 247, 0.12);
    color: #a855f7;
}

.err-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.err-card-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
}

.err-card-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

/* ========================================================================== */
/* CHARTS ROW                                                                 */
/* ========================================================================== */

.errores-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
    flex-shrink: 0;
}

.err-chart-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.err-panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.err-panel-header svg {
    color: #00b4ff;
    flex-shrink: 0;
}

.err-bar-chart {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.err-bar-row {
    display: grid;
    grid-template-columns: 140px 1fr 40px;
    align-items: center;
    gap: 0.6rem;
}

.err-bar-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    min-width: 0;
}

.err-campo-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.err-campo-count {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.err-bar-track {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.err-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    min-width: 4px;
}

.err-bar-campo {
    background: linear-gradient(90deg, #F07400, #ff9a3c);
}

.err-bar-usuario {
    background: linear-gradient(90deg, #00b4ff, #4dd0ff);
}

.err-bar-pct {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: right;
}

/* ========================================================================== */
/* DETAIL TABLE                                                               */
/* ========================================================================== */

.errores-detail-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.err-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.err-detail-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.err-detail-title svg {
    color: #00b4ff;
    flex-shrink: 0;
}

.err-detail-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Custom Select Dropdowns */
.err-custom-select {
    position: relative;
}

.err-select-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    font-size: 0.72rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
}

.err-select-btn:hover {
    border-color: var(--text-secondary);
}

.err-custom-select.open .err-select-btn {
    border-color: #00b4ff;
}

.err-select-btn svg {
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.err-custom-select.open .err-select-btn svg {
    transform: rotate(180deg);
}

.err-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    padding: 0.25rem;
}

.err-select-option {
    padding: 0.35rem 0.6rem;
    font-size: 0.72rem;
    color: var(--text-primary);
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.err-select-option:hover {
    background: rgba(0, 180, 255, 0.12);
    color: #00b4ff;
}

.err-select-option.selected {
    background: rgba(240, 116, 0, 0.12);
    color: #F07400;
    font-weight: 600;
}

.err-table-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.err-table-scroll {
    overflow: auto;
    flex: 1;
}

.err-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.73rem;
}

.err-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.err-table thead th {
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-size: 0.65rem;
    padding: 0.6rem 0.6rem;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.err-table tbody tr {
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--border-color);
}

.err-table tbody tr:hover {
    background: rgba(0, 180, 255, 0.04);
}

.err-table tbody td {
    padding: 0.5rem 0.6rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.col-id {
    width: 70px;
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.72rem;
}

.col-modulo {
    width: 70px;
}

.col-ruta {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-campo {
    width: 90px;
}

.col-valor {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-usuario {
    width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-fecha {
    width: 90px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Badges */
.err-modulo-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-static {
    background: rgba(240, 116, 0, 0.12);
    color: #F07400;
    border: 1px solid rgba(240, 116, 0, 0.25);
}

.badge-screen {
    background: rgba(0, 180, 255, 0.12);
    color: #00b4ff;
    border: 1px solid rgba(0, 180, 255, 0.25);
}

.err-campo-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(168, 85, 247, 0.10);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.val-original {
    color: #ef4444;
    font-weight: 600;
}

.val-nuevo {
    color: #22c55e;
    font-weight: 600;
}

.err-usuario-error {
    color: #ef4444;
    font-weight: 600;
}

/* Table Footer */
.err-table-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.err-table-footer span {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* ========================================================================== */
/* STACKED BAR CHART (Usuario / Campo)                                        */
/* ========================================================================== */

.err-stacked-chart {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.err-stacked-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.err-stacked-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
}

.err-stacked-bar {
    display: flex;
    height: 14px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-primary);
}

.err-stacked-segment {
    height: 100%;
    transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    min-width: 3px;
    cursor: default;
}

/* Paleta de colores para segmentos */
.seg-color-0 { background: #F07400; }
.seg-color-1 { background: #00b4ff; }
.seg-color-2 { background: #a855f7; }
.seg-color-3 { background: #22c55e; }
.seg-color-4 { background: #ef4444; }
.seg-color-5 { background: #eab308; }
.seg-color-6 { background: #ec4899; }
.seg-color-7 { background: #14b8a6; }
.seg-color-8 { background: #6366f1; }
.seg-color-9 { background: #f97316; }

/* Leyenda */
.err-stacked-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.25rem;
}

.err-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.err-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.seg-bg-0 { background: #F07400; }
.seg-bg-1 { background: #00b4ff; }
.seg-bg-2 { background: #a855f7; }
.seg-bg-3 { background: #22c55e; }
.seg-bg-4 { background: #ef4444; }
.seg-bg-5 { background: #eab308; }
.seg-bg-6 { background: #ec4899; }
.seg-bg-7 { background: #14b8a6; }
.seg-bg-8 { background: #6366f1; }
.seg-bg-9 { background: #f97316; }

/* ========================================================================== */
/* RESPONSIVE                                                                 */
/* ========================================================================== */

@media (max-width: 1200px) {
    .errores-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .errores-charts-row {
        grid-template-columns: 1fr;
    }

    .err-bar-row {
        grid-template-columns: 120px 1fr 35px;
    }
}

@media (max-width: 768px) {
    .errores-summary-grid {
        grid-template-columns: 1fr;
    }

    .errores-ciclo-bar {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

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

    .err-detail-filters {
        width: 100%;
    }

    .err-filter-select {
        flex: 1;
        min-width: 0;
    }

    .err-card-value {
        font-size: 1.1rem;
    }
}
