/* ─────────────────────────────────────────────
 * Módulo Proyectos
 * ───────────────────────────────────────────── */

/* Reutiliza de clientes.css: .hidden, .mod-header, .mod-title,
   .btn, .btn-primary, .btn-ghost, .stats-grid, .stat-card,
   .stat-card--success, .stat-card--muted, .stat-card--ghost,
   .stat-label, .stat-value, .alert, .table-wrapper, .data-table,
   .table-placeholder, .table-error, .cell-acciones,
   .badge, .btn-row, .modal-*, .form-*, .field-error, .form-error */

/* ── Stats grid: 4 columnas en proyectos ── */
.mod-proyectos .stats-grid {
    grid-template-columns: repeat(4, 1fr);
}

/* ── Enlace volver ── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-accent);
    text-decoration: none;
    margin-bottom: 16px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: var(--font-primary);
}

.back-link:hover {
    text-decoration: underline;
}

/* ── Subtítulo de cliente ── */
.mod-subtitle {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 2px;
}

/* ── Barra de filtros (solo modo general) ── */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.filter-select,
.filter-input {
    height: 36px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font-primary);
    color: var(--color-text);
    background: #ffffff;
    outline: none;
    transition: border-color var(--transition-speed),
                box-shadow var(--transition-speed);
}

.filter-select {
    min-width: 160px;
}

.filter-input {
    flex: 1;
    min-width: 200px;
}

.filter-select:focus,
.filter-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(72, 147, 198, 0.15);
}

/* ── Badges de estado ── */
.badge-estado {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-estado[data-estado="borrador"] {
    background-color: #f3f4f6;
    color: #374151;
}

.badge-estado[data-estado="en_levantamiento"] {
    background-color: var(--info-bg);
    color: var(--info-text);
}

.badge-estado[data-estado="en_analisis"] {
    background-color: var(--surface-blue);
    color: var(--primary-dark);
}

.badge-estado[data-estado="en_revision"] {
    background-color: var(--warning-bg);
    color: var(--warning-text);
}

.badge-estado[data-estado="aprobado"] {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.badge-estado[data-estado="completado"] {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.badge-estado[data-estado="cancelado"] {
    background-color: #f3f4f6;
    color: #9ca3af;
}

/* ── Badges de prioridad ── */
.badge-prioridad {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-prioridad[data-prioridad="baja"] {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.badge-prioridad[data-prioridad="media"] {
    background-color: var(--info-bg);
    color: var(--info-text);
}

.badge-prioridad[data-prioridad="alta"] {
    background-color: var(--warning-bg);
    color: var(--warning-text);
}

.badge-prioridad[data-prioridad="critica"] {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

/* ── Secciones del formulario ── */
.form-section {
    margin-top: 20px;
}

.form-section:first-child {
    margin-top: 0;
}

.form-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

/* ── Fila de proyecto cancelado ── */
.row-cancelado td {
    color: #9ca3af;
}

/* ── Select deshabilitado (cliente al editar) ── */
.form-group select:disabled {
    background-color: #f9fafb;
    color: #6b7280;
    cursor: default;
    border-color: #e5e7eb;
}

/* ── Modal de Proyectos: más ancha y con scroll interno ──
   Scoped bajo #modal-proyectos para no afectar la modal de Clientes.
   ────────────────────────────────────────────────────────────────── */

#modal-proyectos .modal-box {
    max-width: min(1120px, calc(100vw - 48px));
    max-height: 88vh;
}

/* El <form> envuelve .modal-body + .modal-footer dentro de .modal-box
   (que ya es flex-column). Sin estos estilos, flex:1 en .modal-body
   no limita el alto y el scroll interno no funciona. */
#modal-proyectos form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#modal-proyectos .modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 28px;
}

#modal-proyectos .modal-footer {
    flex-shrink: 0;
}

/* ── Lista de validaciones en alerta de error ── */
.alert-list {
    margin: 6px 0 0;
    padding-left: 20px;
    list-style: disc;
}

.alert-list li {
    font-size: 0.82rem;
    margin-bottom: 3px;
    line-height: 1.4;
}

/* ── Animación skeleton ── */
@keyframes stat-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .mod-proyectos .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    #modal-proyectos .modal-box {
        max-width: calc(100vw - 32px);
        max-height: 95vh;
    }

    #modal-proyectos .modal-body {
        padding: 16px;
    }
}

@media (max-width: 768px) {
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-select,
    .filter-input {
        min-width: 0;
        width: 100%;
    }

    .data-table thead th:nth-child(5),
    .data-table tbody td:nth-child(5) {
        display: none;
    }
}

@media (max-width: 480px) {
    .mod-proyectos .stats-grid {
        grid-template-columns: 1fr;
    }

    .data-table thead th:nth-child(4),
    .data-table tbody td:nth-child(4) {
        display: none;
    }
}
