/* ============================================================
   PRESUPUESTOS ARCHIVE — v2
   Fuentes: Plus Jakarta Sans (títulos) + Nunito (cuerpo)
   Alta especificidad para convivir con DIVI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@600;700;800&family=Nunito:wght@400;500;600;700&display=swap');

/* ── Reset selectivo contra DIVI ────────────────────────────── */
#pres-archive,
#pres-archive *,
#pres-archive *::before,
#pres-archive *::after {
    box-sizing: border-box;
}

#pres-archive a,
#pres-archive a:hover,
#pres-archive a:focus,
#pres-archive a:visited {
    text-decoration: none !important;
}

#pres-archive button {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
}

#pres-archive img {
    max-width: 100%;
    display: block;
}

/* ── Variables ─────────────────────────────────────────────── */
#pres-archive {
    --c-bg:          #f4f6f9;
    --c-surface:     #ffffff;
    --c-border:      #e2e6ed;
    --c-text:        #111827;
    --c-text-2:      #374151;
    --c-muted:       #6b7280;
    --c-accent:      #1d4ed8;
    --c-accent-light:#eff6ff;
    --c-accent-hover:#1e40af;

    --c-creado:      #475569;
    --c-enviado:     #0369a1;
    --c-aceptado:    #15803d;
    --c-rechazado:   #b91c1c;

    --radius-sm:     6px;
    --radius-md:     12px;
    --radius-lg:     16px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:     0 4px 16px rgba(0,0,0,0.09), 0 1px 4px rgba(0,0,0,0.05);
    --shadow-lg:     0 12px 36px rgba(0,0,0,0.13), 0 4px 12px rgba(0,0,0,0.06);
    --transition:    0.2s cubic-bezier(0.4, 0, 0.2, 1);

    font-family: 'Nunito', sans-serif;
    color: var(--c-text);
    background: var(--c-bg);
    padding: 2.5rem 1.5rem 4rem;
    max-width: 1320px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ── Cabecera ───────────────────────────────────────────────── */
#pres-archive .pres-archive__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 2px solid var(--c-border);
}

#pres-archive .pres-archive__title {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    font-weight: 800 !important;
    font-size: clamp(1.5rem, 2.5vw, 2rem) !important;
    color: var(--c-text) !important;
    margin: 0 !important;
    padding: 0 !important;
    letter-spacing: -0.025em;
    line-height: 1.15 !important;
    border: none !important;
}

#pres-archive .pres-archive__count {
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    color: var(--c-accent) !important;
    background: var(--c-accent-light) !important;
    padding: 0.3rem 0.9rem !important;
    border-radius: 999px !important;
    font-family: 'Nunito', sans-serif !important;
    letter-spacing: 0.01em;
    border: 1px solid rgba(29, 78, 216, 0.15) !important;
}

/* ── Panel de filtros ───────────────────────────────────────── */
#pres-archive .pres-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.5rem;
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background: var(--c-surface) !important;
    border: 1px solid var(--c-border) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm) !important;
}

/* Separador vertical entre búsqueda y botones */
#pres-archive .pres-filters__search {
    position: relative;
    flex: 0 1 260px;
    min-width: 180px;
}

#pres-archive .pres-filters__search::after {
    content: '';
    position: absolute;
    right: -0.75rem;
    top: 50%;
    transform: translateY(-50%);
    height: 28px;
    width: 1px;
    background: var(--c-border);
}

#pres-archive .pres-filters__search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 1;
    line-height: 1;
}

#pres-archive .pres-filters__input {
    width: 100% !important;
    padding: 0.6rem 0.9rem 0.6rem 2.35rem !important;
    border: 1.5px solid var(--c-border) !important;
    border-radius: var(--radius-sm) !important;
    font-family: 'Nunito', sans-serif !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    color: var(--c-text) !important;
    background: var(--c-bg) !important;
    transition: border-color var(--transition), box-shadow var(--transition) !important;
    height: auto !important;
    box-shadow: none !important;
    outline: none !important;
    margin: 0 !important;
}

#pres-archive .pres-filters__input:focus {
    border-color: var(--c-accent) !important;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1) !important;
    background: #fff !important;
}

#pres-archive .pres-filters__input::placeholder {
    color: var(--c-muted) !important;
    font-weight: 400 !important;
}

/* Botones de estado */
#pres-archive .pres-filters__estados {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    flex: 1;
}

#pres-archive .pres-filter-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.35rem !important;
    padding: 0.4rem 1rem !important;
    border-radius: 999px !important;
    border: 1.5px solid var(--c-border) !important;
    background: transparent !important;
    font-family: 'Nunito', sans-serif !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    color: var(--c-muted) !important;
    transition: all var(--transition) !important;
    white-space: nowrap !important;
    line-height: 1.4 !important;
    box-shadow: none !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

#pres-archive .pres-filter-btn::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition);
}

#pres-archive .pres-filter-btn:hover {
    border-color: var(--btn-color, var(--c-accent)) !important;
    color: var(--btn-color, var(--c-accent)) !important;
    background: color-mix(in srgb, var(--btn-color, var(--c-accent)) 7%, white) !important;
}

#pres-archive .pres-filter-btn:hover::before,
#pres-archive .pres-filter-btn.active::before {
    opacity: 1;
    transform: scale(1);
}

#pres-archive .pres-filter-btn.active {
    background: var(--btn-color, var(--c-accent)) !important;
    border-color: var(--btn-color, var(--c-accent)) !important;
    color: #fff !important;
    box-shadow: 0 2px 10px color-mix(in srgb, var(--btn-color, var(--c-accent)) 35%, transparent) !important;
}

/* ── Grid de tarjetas ───────────────────────────────────────── */
#pres-archive .pres-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)) !important;
    gap: 1.5rem !important;
    transition: opacity 0.2s ease;
}

#pres-archive .pres-grid.is-loading {
    opacity: 0.4;
    pointer-events: none;
}

/* ── Tarjeta ────────────────────────────────────────────────── */
#pres-archive .pres-card {
    background: var(--c-surface) !important;
    border: 1px solid var(--c-border) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition) !important;
    animation: cardReveal 0.4s ease both;
    position: relative;
}

/* Stagger de entrada */
#pres-archive .pres-card:nth-child(1)  { animation-delay: 0.03s; }
#pres-archive .pres-card:nth-child(2)  { animation-delay: 0.07s; }
#pres-archive .pres-card:nth-child(3)  { animation-delay: 0.11s; }
#pres-archive .pres-card:nth-child(4)  { animation-delay: 0.15s; }
#pres-archive .pres-card:nth-child(5)  { animation-delay: 0.19s; }
#pres-archive .pres-card:nth-child(6)  { animation-delay: 0.23s; }
#pres-archive .pres-card:nth-child(n+7) { animation-delay: 0.27s; }

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

#pres-archive .pres-card:hover {
    transform: translateY(-5px) !important;
    box-shadow: var(--shadow-lg) !important;
    border-color: #d0d8e8 !important;
}

/* Línea de color superior según estado */
#pres-archive .pres-card::before {
    content: '';
    display: block;
    height: 3px;
    background: var(--estado-color, var(--c-border));
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1;
    transition: height var(--transition);
}

#pres-archive .pres-card:hover::before {
    height: 4px;
}

/* Thumb */
#pres-archive .pres-card__thumb {
    position: relative !important;
    height: 190px !important;
    overflow: hidden !important;
    background: #f1f5f9 !important;
    margin-top: 3px;
}

#pres-archive .pres-card__thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    transition: transform 0.45s ease !important;
    display: block !important;
}

#pres-archive .pres-card:hover .pres-card__thumb img {
    transform: scale(1.05) !important;
}

#pres-archive .pres-card__thumb-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 40%, rgba(17, 24, 39, 0.22));
}

#pres-archive .pres-card__thumb--empty {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 2.75rem !important;
    color: #cbd5e1 !important;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9) !important;
}

/* Cuerpo */
#pres-archive .pres-card__body {
    padding: 1.25rem 1.4rem 1.4rem !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.55rem !important;
    flex: 1 !important;
}

/* Header de la tarjeta */
#pres-archive .pres-card__header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.5rem !important;
}

/* Badge de estado */
#pres-archive .pres-card__estado {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.3rem !important;
    font-size: 0.7rem !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.07em !important;
    padding: 0.22rem 0.65rem !important;
    border-radius: 999px !important;
    background: color-mix(in srgb, var(--estado-color) 12%, white) !important;
    color: var(--estado-color) !important;
    border: 1px solid color-mix(in srgb, var(--estado-color) 25%, transparent) !important;
    font-family: 'Nunito', sans-serif !important;
    line-height: 1.4 !important;
}

#pres-archive .pres-card__estado::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* Fecha */
#pres-archive .pres-card__fecha {
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    color: var(--c-muted) !important;
    white-space: nowrap !important;
    font-family: 'Nunito', sans-serif !important;
    letter-spacing: 0 !important;
}

/* Título */
#pres-archive .pres-card__title {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    font-size: 0.975rem !important;
    font-weight: 700 !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.35 !important;
    border: none !important;
    color: var(--c-text) !important;
}

#pres-archive .pres-card__title a {
    color: var(--c-text) !important;
    text-decoration: none !important;
    transition: color var(--transition) !important;
}

#pres-archive .pres-card__title a:hover {
    color: var(--c-accent) !important;
}

/* Cliente */
#pres-archive .pres-card__cliente {
    display: flex !important;
    align-items: center !important;
    gap: 0.4rem !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    color: var(--c-text-2) !important;
    font-family: 'Nunito', sans-serif !important;
    padding: 0.45rem 0.65rem !important;
    background: var(--c-bg) !important;
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--c-border) !important;
}

#pres-archive .pres-card__cliente-icon {
    font-size: 0.8rem;
    flex-shrink: 0;
    line-height: 1;
}

#pres-archive .pres-card__cliente a {
    color: var(--c-accent) !important;
    transition: color var(--transition) !important;
}

#pres-archive .pres-card__cliente a:hover {
    color: var(--c-accent-hover) !important;
    text-decoration: underline !important;
}

/* Descripción */
#pres-archive .pres-card__desc {
    font-size: 0.825rem !important;
    color: var(--c-muted) !important;
    line-height: 1.6 !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 1 !important;
    font-family: 'Nunito', sans-serif !important;
}

/* CTA */
#pres-archive .pres-card__cta {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.4rem !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    color: var(--c-accent) !important;
    text-decoration: none !important;
    margin-top: auto !important;
    padding: 0.65rem 1rem !important;
    border-radius: var(--radius-sm) !important;
    border: 1.5px solid rgba(29, 78, 216, 0.2) !important;
    background: var(--c-accent-light) !important;
    transition: all var(--transition) !important;
    font-family: 'Nunito', sans-serif !important;
    letter-spacing: 0.01em !important;
}

#pres-archive .pres-card__cta:hover {
    background: var(--c-accent) !important;
    color: #fff !important;
    border-color: var(--c-accent) !important;
    gap: 0.6rem !important;
    box-shadow: 0 4px 14px rgba(29, 78, 216, 0.3) !important;
}

/* ── Estado vacío ───────────────────────────────────────────── */
#pres-archive .pres-empty {
    grid-column: 1 / -1 !important;
    text-align: center !important;
    padding: 5rem 2rem !important;
    color: var(--c-muted) !important;
}

#pres-archive .pres-empty__icon {
    font-size: 3.5rem !important;
    display: block !important;
    margin-bottom: 1rem !important;
    opacity: 0.4 !important;
    line-height: 1 !important;
}

#pres-archive .pres-empty p {
    font-size: 1rem !important;
    margin: 0 !important;
    font-weight: 500 !important;
    color: var(--c-muted) !important;
}

/* ── Paginación ─────────────────────────────────────────────── */
#pres-archive .pres-pagination {
    display: flex !important;
    justify-content: center !important;
    gap: 0.4rem !important;
    margin-top: 3rem !important;
    flex-wrap: wrap !important;
}

#pres-archive .pres-page-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 38px !important;
    height: 38px !important;
    padding: 0 0.6rem !important;
    border: 1.5px solid var(--c-border) !important;
    border-radius: var(--radius-sm) !important;
    background: var(--c-surface) !important;
    font-family: 'Nunito', sans-serif !important;
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    color: var(--c-muted) !important;
    transition: all var(--transition) !important;
    box-shadow: var(--shadow-sm) !important;
    line-height: 1 !important;
}

#pres-archive .pres-page-btn:hover {
    border-color: var(--c-accent) !important;
    color: var(--c-accent) !important;
    background: var(--c-accent-light) !important;
}

#pres-archive .pres-page-btn.active {
    background: var(--c-accent) !important;
    border-color: var(--c-accent) !important;
    color: #fff !important;
    box-shadow: 0 3px 10px rgba(29, 78, 216, 0.35) !important;
}

/* ── Colores de estado para la línea superior de tarjeta ─────── */
#pres-archive .pres-card[data-estado="creado"]    { --estado-color: var(--c-creado); }
#pres-archive .pres-card[data-estado="enviado"]   { --estado-color: var(--c-enviado); }
#pres-archive .pres-card[data-estado="aceptado"]  { --estado-color: var(--c-aceptado); }
#pres-archive .pres-card[data-estado="rechazado"] { --estado-color: var(--c-rechazado); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    #pres-archive {
        padding: 1.5rem 1rem 3rem;
    }

    #pres-archive .pres-filters {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #pres-archive .pres-filters__search {
        flex: 1 1 100% !important;
        min-width: 0 !important;
    }

    #pres-archive .pres-filters__search::after {
        display: none;
    }

    #pres-archive .pres-filters__estados {
        justify-content: flex-start;
    }

    #pres-archive .pres-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}

@media (min-width: 769px) and (max-width: 1100px) {
    #pres-archive .pres-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ============================================================
   CREAR SERVICIO — Botón + formulario desplegable
   ============================================================ */

#pres-archive .pres-card__crear-servicio {
    margin-top: 0.5rem !important;
    border-top: 1px solid var(--c-border) !important;
    padding-top: 0.75rem !important;
}

#pres-archive .pres-btn-crear-servicio {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.45rem !important;
    width: 100% !important;
    justify-content: center !important;
    padding: 0.65rem 1rem !important;
    border-radius: var(--radius-sm) !important;
    border: 1.5px solid #16a34a !important;
    background: #f0fdf4 !important;
    font-family: 'Nunito', sans-serif !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    color: #15803d !important;
    transition: all var(--transition) !important;
    box-shadow: none !important;
    line-height: 1 !important;
    cursor: pointer !important;
}

#pres-archive .pres-btn-crear-servicio:hover {
    background: #15803d !important;
    color: #fff !important;
    border-color: #15803d !important;
    box-shadow: 0 4px 14px rgba(21, 128, 61, 0.3) !important;
}

#pres-archive .pres-btn-crear-servicio[aria-expanded="true"] {
    background: #15803d !important;
    color: #fff !important;
    border-color: #15803d !important;
}

#pres-archive .pres-btn-icon {
    font-size: 0.85rem;
    transition: transform var(--transition);
    line-height: 1;
}

#pres-archive .pres-btn-crear-servicio[aria-expanded="true"] .pres-btn-icon {
    transform: rotate(45deg);
}

/* Contenedor del formulario */
#pres-archive .pres-form-wrap {
    margin-top: 0.75rem !important;
    border: 1px solid #bbf7d0 !important;
    border-radius: var(--radius-md) !important;
    background: #f0fdf4 !important;
    overflow: hidden !important;
}

#pres-archive .pres-form-wrap[hidden] {
    display: none !important;
}

#pres-archive .pres-form-inner {
    padding: 1.25rem !important;
}

/* Loading spinner */
#pres-archive .pres-form-loading {
    display: flex !important;
    align-items: center !important;
    gap: 0.6rem !important;
    font-size: 0.85rem !important;
    color: var(--c-muted) !important;
    font-family: 'Nunito', sans-serif !important;
    padding: 0.5rem 0 !important;
}

#pres-archive .pres-form-loading[hidden] {
    display: none !important;
}

#pres-archive .pres-spinner {
    display: inline-block !important;
    width: 16px !important;
    height: 16px !important;
    border: 2px solid #bbf7d0 !important;
    border-top-color: #15803d !important;
    border-radius: 50% !important;
    animation: presSpinnerSpin 0.7s linear infinite !important;
    flex-shrink: 0 !important;
}

@keyframes presSpinnerSpin {
    to { transform: rotate(360deg); }
}

/* Formulario ACFE dentro del wrap — reset básico */
#pres-archive .pres-form-content .acf-form-submit {
    margin-top: 1rem;
}

#pres-archive .pres-form-content .acf-form-submit .acf-btn,
#pres-archive .pres-form-content .acf-form-submit input[type="submit"],
#pres-archive .pres-form-content .acf-form-submit button[type="submit"] {
    background: #15803d !important;
    border-color: #15803d !important;
    color: #fff !important;
    font-family: 'Nunito', sans-serif !important;
    font-weight: 700 !important;
    border-radius: var(--radius-sm) !important;
    padding: 0.6rem 1.4rem !important;
    font-size: 0.875rem !important;
    cursor: pointer !important;
    transition: background var(--transition) !important;
}

#pres-archive .pres-form-content .acf-form-submit .acf-btn:hover,
#pres-archive .pres-form-content .acf-form-submit input[type="submit"]:hover,
#pres-archive .pres-form-content .acf-form-submit button[type="submit"]:hover {
    background: #166534 !important;
    border-color: #166534 !important;
}
