/* --- Estilos Específicos del Dashboard --- */

.bg-gray {
    background-color: #F1F5F9;
}

.dashboard-page {
    padding: 3rem 1.5rem 6rem;
}

/* Header del Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dashboard-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.text-muted {
    color: var(--color-text-muted);
}

/* Grid de KPIs (Contadores) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    /* Forzar siempre una fila con 5 columnas */
    gap: 1rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1rem 0.75rem;
    /* Ajustar el margen para que quepan todos */
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: transform 0.3s, box-shadow 0.3s;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.icon-blue {
    background: #E0F2FE;
    color: #0284C7;
}

.icon-orange {
    background: #FFEDD5;
    color: #EA580C;
}

.icon-green {
    background: #DCFCE7;
    color: #16A34A;
}

.icon-purple {
    background: #F3E8FF;
    color: #9333EA;
}

.kpi-info {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--color-text-main);
}

.kpi-value small {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 500;
    line-height: 1.2;
}

/* Layout Principal (Formulario + Tabla) */
.dashboard-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 2rem;
    align-items: start;
}

.dashboard-layout.full-width {
    display: block;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-scrollable {
    overflow-y: auto;
    padding-bottom: 2rem;
}

/* Paneles base */
.panel-form,
.panel-table {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.panel-head {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.panel-head h2 {
    font-size: 1.5rem;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

/* --- Formulario de Incidencias --- */
.incidencia-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-group.half {
    flex: 1;
}

label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-text-main);
}

.required {
    color: #EF4444;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="tel"],
input[type="email"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 1rem;
    border: 1px solid #CBD5E1;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    background-color: #F8FAFC;
    color: var(--color-text-main);
    transition: all 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary-soft);
    box-shadow: 0 0 0 3px var(--color-primary-light);
    background-color: white;
}

/* Input con icono interno (ej. Dirección) */
.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    left: 1rem;
    color: var(--color-text-muted);
    font-size: 1.25rem;
}

.input-with-icon input {
    padding-left: 2.75rem;
}

.input-readonly {
    background-color: #E2E8F0 !important;
    color: #64748B !important;
    cursor: not-allowed;
}

/* Zona de Upload de Archivos */
.upload-area {
    border: 2px dashed #CBD5E1;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    background: #F8FAFC;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-area:hover {
    border-color: var(--color-primary-soft);
    background: var(--color-primary-light);
}

.upload-area i {
    font-size: 2rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    display: block;
}

.upload-area span {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Campos de Admin (Resolución) */
.admin-fields {
    background: #F1F5F9;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid #E2E8F0;
    margin-bottom: 1.25rem;
}

.admin-title {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Checkboxes personalizados */
.checkbox-group {
    margin: 1.5rem 0;
}

.checkbox-container {
    display: flex;
    align-items: flex-start;
    position: relative;
    cursor: pointer;
    font-size: 0.95rem;
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    left: 0;
    top: 2px;
    height: 20px;
    width: 20px;
    z-index: 10;
}

.checkmark {
    display: block;
    position: relative;
    top: 2px;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: white;
    border: 2px solid #CBD5E1;
    border-radius: 4px;
    margin-right: 0.75rem;
    flex-shrink: 0;
    transition: all 0.2s;
}

.checkbox-container:hover input~.checkmark {
    border-color: var(--color-primary-soft);
}

.checkbox-container input:checked~.checkmark {
    background-color: #EF4444;
    /* Rojo para seguridad */
    border-color: #EF4444;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-container input:checked~.checkmark:after {
    display: block;
}

/* Campos de Contacto Privado */
.contact-fields {
    background: #F8FAFC;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary-soft);
    margin-bottom: 1.5rem;
}

.contact-title {
    font-size: 1rem;
    color: var(--color-primary-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.contact-note {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 1.25rem;
    line-height: 1.4;
}

.contact-note strong {
    color: var(--color-text-main);
}

.mt-2 {
    margin-top: 1rem;
}

/* --- Tabla de Incidencias --- */
.table-actions {
    display: flex;
    gap: 0.5rem;
}

.search-mini {
    position: relative;
    display: flex;
    align-items: center;
}

.search-mini i {
    position: absolute;
    left: 0.75rem;
    color: var(--color-text-muted);
}

.search-mini input {
    padding-left: 2.25rem;
    width: 200px;
    border-radius: var(--radius-full);
}

.btn-icon {
    background: #F1F5F9;
    border: 1px solid #CBD5E1;
    color: var(--color-text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #E2E8F0;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.data-table th,
.data-table td {
    padding: 0.75rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    background-color: #F8FAFC;
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: normal;
    line-height: 1.2;
}

.data-table tbody tr {
    transition: background-color 0.2s;
}

.data-table tbody tr:hover {
    background-color: #F8FAFC;
}

/* Componentes de la Celda */
.id-badge {
    font-family: monospace;
    color: var(--color-text-muted);
    font-weight: 500;
}

.desc-cell {
    width: auto;
    min-width: 250px;
}

.desc-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.desc-content strong {
    color: var(--color-text-main);
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
}

.text-sm {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tag-sm {
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    margin-bottom: 0;
}

.tag-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.text-danger {
    color: #EF4444;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.status-received {
    background: #E0F2FE;
    color: #0284C7;
}

.status-progress {
    background: #FEF3C7;
    color: #D97706;
}

.status-solved {
    background: #DCFCE7;
    color: #16A34A;
}

.status-unsolved {
    background: #FEE2E2;
    color: #DC2626;
}

.btn-action {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-action:hover {
    color: var(--color-primary);
    background: #E0F2FE;
}

/* Paginación */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: white;
}

.page-controls {
    display: flex;
    gap: 0.25rem;
}

.btn-page {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    background: white;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-page:not(:disabled):hover {
    background: #F1F5F9;
}

.btn-page.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.d-md-none {
    display: none;
}

.btn-close-panel {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color 0.2s;
}

.btn-close-panel:hover {
    color: var(--color-text-main);
}

/* --- Responsive Dashboard --- */
@media (max-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    .d-md-none {
        display: block;
    }
}

@media (max-width: 600px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-header h1 {
        font-size: 2rem;
    }

    .dashboard-header>div:last-child {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .dashboard-header .btn {
        width: 100%;
        justify-content: center;
    }

    .search-mini input {
        width: 100%;
    }

    .table-actions {
        width: 100%;
        margin-top: 1rem;
    }

    .search-mini {
        width: 100%;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* El último KPI (Tiempo medio) ocupa las 2 columnas en mobile */
    .kpi-grid .kpi-card:last-child {
        grid-column: span 2;
    }
}