/**
 * Estilos Frontend — Enlace Directorio de Oficinas V1
 *
 * Diseño institucional, responsivo, accesible y sin dependencias externas.
 * Compatible con WP Engine, temas clásicos (TrueMag) y constructores visuales.
 */

:root {
    --enlace-dir-navy: #081728;
    --enlace-dir-navy-light: #213373;
    --enlace-dir-cyan: #00CCCC;
    --enlace-dir-cyan-hover: #0aaed5;
    --enlace-dir-gold: #fac200;
    --enlace-dir-text: #1e293b;
    --enlace-dir-text-muted: #64748b;
    --enlace-dir-bg-card: #ffffff;
    --enlace-dir-bg-subtle: #f8fafc;
    --enlace-dir-border: #e2e8f0;
    --enlace-dir-radius: 16px;
    --enlace-dir-radius-sm: 8px;
    --enlace-dir-radius-pill: 40px;
    --enlace-dir-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --enlace-dir-shadow-md: 0 4px 14px rgba(8, 23, 40, 0.08);
    --enlace-dir-shadow-lg: 0 10px 25px rgba(8, 23, 40, 0.12);
    --enlace-dir-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   1. Contenedor Principal del Directorio (Estilos Scoped)
   ========================================================================== */

/* Contenedor Principal del Directorio */
.enlace-directorio-wrapper {
    box-sizing: border-box;
    font-family: inherit;
    color: var(--enlace-dir-text);
    margin-bottom: 45px;
    padding-bottom: 25px;
    border-bottom: 2px solid #edf2f7;
}

.enlace-directorio-wrapper *,
.enlace-directorio-wrapper *::before,
.enlace-directorio-wrapper *::after {
    box-sizing: border-box;
}

/* Banner de Vista Previa (Borrador) */
.enlace-oficina-preview-banner {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-left: 5px solid #d97706;
    border-radius: var(--enlace-dir-radius-sm);
    padding: 12px 18px;
    margin-bottom: 24px;
    box-shadow: var(--enlace-dir-shadow-sm);
}

.enlace-preview-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 14px;
    color: #92400e;
}

.enlace-preview-icon {
    display: inline-flex;
    color: #d97706;
}

.enlace-preview-edit-link {
    margin-left: auto;
    background: #d97706;
    color: #ffffff !important;
    padding: 6px 14px;
    border-radius: var(--enlace-dir-radius-pill);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    transition: var(--enlace-dir-transition);
}

.enlace-preview-edit-link:hover {
    background: #b45309;
}

/* ==========================================================================
   2. Encabezado de la Oficina
   ========================================================================== */

.enlace-oficina-header {
    background: linear-gradient(135deg, #081728 0%, #172a45 100%);
    border-radius: var(--enlace-dir-radius);
    padding: 30px 35px;
    color: #ffffff;
    margin-bottom: 25px;
    box-shadow: var(--enlace-dir-shadow-md);
}

.enlace-oficina-header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.enlace-oficina-identity {
    display: flex;
    align-items: center;
    gap: 18px;
}

.enlace-oficina-flag-wrap {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 3px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.enlace-oficina-flag {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.enlace-oficina-titles {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.enlace-oficina-title {
    margin: 0 !important;
    padding: 0;
    font-size: 28px !important;
    font-weight: 800;
    color: #ffffff !important;
    line-height: 1.2;
}

.enlace-oficina-header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

/* Botones del Directorio */
.enlace-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    min-height: 44px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none !important;
    border-radius: var(--enlace-dir-radius-pill);
    cursor: pointer;
    transition: var(--enlace-dir-transition);
    border: none;
    line-height: 1;
}

.enlace-btn-primary {
    background: var(--enlace-dir-cyan);
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0, 204, 204, 0.3);
}

.enlace-btn-primary:hover {
    background: var(--enlace-dir-cyan-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 204, 204, 0.45);
}

.enlace-btn-secondary {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.enlace-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.enlace-icon-arrow {
    transition: transform 0.2s ease;
}

.enlace-btn:hover .enlace-icon-arrow {
    transform: translateY(2px);
}

.enlace-btn-toggle-methods {
    cursor: pointer;
}

.enlace-btn-toggle-methods .enlace-icon-arrow {
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
}

.enlace-btn-toggle-methods[aria-expanded="true"] .enlace-icon-arrow,
.enlace-btn-toggle-methods.is-open .enlace-icon-arrow {
    transform: rotate(180deg);
}

.enlace-btn-toggle-methods[aria-expanded="true"],
.enlace-btn-toggle-methods.is-open {
    background: rgba(255, 255, 255, 0.26);
    border-color: var(--enlace-dir-cyan);
    box-shadow: 0 0 0 2px rgba(0, 204, 204, 0.3);
}

/* ==========================================================================
   3. Tarjetas de Contacto
   ========================================================================== */

.enlace-oficina-contacts-section {
    margin-bottom: 40px;
}

.enlace-oficina-contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.enlace-contact-card {
    background: var(--enlace-dir-bg-card);
    border: 1px solid var(--enlace-dir-border);
    border-radius: var(--enlace-dir-radius);
    padding: 18px 20px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    box-shadow: var(--enlace-dir-shadow-sm);
    transition: var(--enlace-dir-transition);
}

.enlace-contact-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--enlace-dir-shadow-md);
    border-color: #cbd5e1;
}

.enlace-contact-card-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(0, 204, 204, 0.12);
    color: var(--enlace-dir-cyan-hover);
    display: flex;
    align-items: center;
    justify-content: center;
}

.enlace-contact-card-body {
    flex: 1;
    min-width: 0;
}

.enlace-contact-card-title {
    margin: 0 0 6px 0 !important;
    font-size: 13px !important;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--enlace-dir-text-muted);
}

.enlace-contact-card-content {
    font-size: 15px;
    font-weight: 600;
    color: var(--enlace-dir-navy);
    line-height: 1.45;
    word-break: break-word;
}

.enlace-contact-link {
    color: var(--enlace-dir-navy) !important;
    text-decoration: none !important;
    transition: color 0.2s ease;
}

.enlace-contact-link:hover {
    color: var(--enlace-dir-cyan-hover) !important;
    text-decoration: underline !important;
}

.enlace-icon-inline {
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.7;
}

/* ==========================================================================
   4. Métodos Dinámicos de Ofrenda
   ========================================================================== */

.enlace-oficina-methods-section {
    background: var(--enlace-dir-bg-subtle);
    border: 1px solid var(--enlace-dir-border);
    border-radius: var(--enlace-dir-radius);
    padding: 35px 30px;
    scroll-margin-top: 80px;
}

.enlace-oficina-methods-section[hidden],
.enlace-oficina-methods-section.is-collapsed {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
    opacity: 0 !important;
}

.enlace-oficina-methods-section.is-expanded {
    display: block !important;
    animation: enlaceMethodsFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes enlaceMethodsFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.enlace-methods-header {
    margin-bottom: 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 18px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 18px;
}

.enlace-methods-section-title {
    margin: 0 0 6px 0 !important;
    font-size: 24px !important;
    font-weight: 800;
    color: var(--enlace-dir-navy) !important;
}

.enlace-methods-section-subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--enlace-dir-text-muted);
}

/* Filtros por Categoría */
.enlace-methods-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.enlace-filter-pill {
    background: #ffffff;
    border: 1px solid var(--enlace-dir-border);
    color: var(--enlace-dir-text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 16px;
    border-radius: var(--enlace-dir-radius-pill);
    cursor: pointer;
    transition: var(--enlace-dir-transition);
}

.enlace-filter-pill:hover {
    border-color: var(--enlace-dir-cyan);
    color: var(--enlace-dir-navy);
}

.enlace-filter-pill.is-active {
    background: var(--enlace-dir-navy);
    border-color: var(--enlace-dir-navy);
    color: #ffffff;
}

/* Grid de Métodos (V1.4.3: align-items: stretch para altura uniforme por fila) */
.enlace-oficina-methods-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
    align-items: stretch;
}

/* Anchos de tarjeta configurables por método (V1.5) */
.enlace-method-card.enlace-method-span-1 {
    grid-column: span 1;
}

.enlace-method-card.enlace-method-span-2 {
    grid-column: span 2;
}

.enlace-method-card.enlace-method-span-3 {
    grid-column: span 3;
}

@media (max-width: 1080px) {
    .enlace-oficina-methods-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .enlace-method-card.enlace-method-span-1 {
        grid-column: span 1;
    }

    .enlace-method-card.enlace-method-span-2,
    .enlace-method-card.enlace-method-span-3 {
        grid-column: span 2;
    }
}

@media (max-width: 680px) {
    .enlace-oficina-methods-grid {
        grid-template-columns: 1fr;
    }

    .enlace-method-card.enlace-method-span-1,
    .enlace-method-card.enlace-method-span-2,
    .enlace-method-card.enlace-method-span-3 {
        grid-column: span 1;
        width: 100%;
    }
}

/* Tarjeta Individual de Método (V1.4.3: Altura uniforme por fila en grid, contenido agrupado arriba) */
.enlace-method-card {
    background: var(--enlace-dir-bg-card);
    border: 1px solid var(--enlace-dir-border);
    border-top: 4px solid var(--method-accent, var(--enlace-dir-cyan));
    border-radius: var(--enlace-dir-radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    box-shadow: var(--enlace-dir-shadow-sm);
    transition: var(--enlace-dir-transition);
    position: relative;
    box-sizing: border-box;
    width: 100%;
}

/* Sincronización fluida de alturas por fila visual */
@supports (grid-template-rows: subgrid) {
    .enlace-oficina-methods-grid {
        grid-auto-rows: auto;
    }
}

.enlace-method-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--enlace-dir-shadow-lg);
    border-color: #cbd5e1;
    border-top-color: var(--method-accent, var(--enlace-dir-cyan));
}

.enlace-method-card.is-hidden-by-filter {
    display: none !important;
}

.enlace-method-draft-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #fef3c7;
    color: #92400e;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #fde68a;
}

/* Cabecera del Método (V1.4: Centrada verticalmente con icono proporcionado) */
.enlace-method-card-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
}

.enlace-method-icon-wrap {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.enlace-method-icon-wrap svg {
    width: 20px;
    height: 20px;
}

.enlace-method-title-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.enlace-method-category-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--enlace-dir-text-muted);
    margin-bottom: 2px;
}

.enlace-method-title {
    margin: 0 !important;
    font-size: 17px !important;
    font-weight: 500 !important;
    color: var(--enlace-dir-navy) !important;
    line-height: 1.3 !important;
}

/* Descripción */
.enlace-method-description {
    font-size: 14px;
    color: #475569;
    line-height: 1.5;
    margin-bottom: 14px;
    width: 100%;
    box-sizing: border-box;
}

.enlace-method-description p {
    margin: 0;
}

/* Lista de Campos Informativos */
.enlace-method-fields-list {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--enlace-dir-radius-sm);
    padding: 12px 14px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.enlace-method-field-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 8px;
}

.enlace-method-field-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.enlace-field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--enlace-dir-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1.4;
}

.enlace-field-value-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.enlace-field-value {
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--enlace-dir-navy);
    word-break: normal;
    overflow-wrap: break-word;
    word-wrap: break-word;
    flex: 1 1 auto;
    min-width: 0;
}

.enlace-field-multiline {
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    white-space: pre-line;
    word-break: normal;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.enlace-field-link {
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--enlace-dir-navy-light) !important;
    text-decoration: underline !important;
    word-break: normal;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Botón Copiar al Portapapeles */
.enlace-btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: var(--enlace-dir-navy);
    padding: 4px 10px;
    border-radius: var(--enlace-dir-radius-pill);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--enlace-dir-transition);
    line-height: 1;
    flex-shrink: 0;
}

.enlace-btn-copy:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.enlace-btn-copy.is-copied {
    background: #10b981;
    border-color: #10b981;
    color: #ffffff;
}

/* Instrucciones (V1.4.2: Altura natural según contenido, 100% de ancho sin forzar min-height ni flex-grow) */
.enlace-method-instructions {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    align-self: stretch !important;
    background: #f0fdfa;
    border: 1px solid #ccfbf1;
    border-radius: var(--enlace-dir-radius-sm);
    padding: 12px 14px;
    font-size: 13px;
    color: #0f766e;
    margin-bottom: 0;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: auto;
    flex-grow: 0;
}

.enlace-instructions-heading {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.enlace-instructions-content,
.enlace-method-instructions p {
    margin: 0 !important;
    flex: none;
    color: #0f766e;
    line-height: 1.5;
    word-break: break-word;
    width: 100%;
}

/* Botón de Acción */
.enlace-method-action-wrap {
    margin-top: 14px;
    width: 100%;
    box-sizing: border-box;
}

.enlace-btn-action {
    width: 100%;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.enlace-btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    filter: brightness(1.08);
}

.enlace-btn-action .enlace-icon-arrow {
    transition: transform 0.2s ease;
}

.enlace-btn-action:hover .enlace-icon-arrow {
    transform: translateX(3px);
}

/* ==========================================================================
   5. Responsividad Móvil Estricta
   ========================================================================== */

@media (max-width: 768px) {
    .enlace-oficina-header {
        padding: 24px 20px;
    }

    .enlace-oficina-title {
        font-size: 22px !important;
    }

    .enlace-oficina-header-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .enlace-oficina-header-actions .enlace-btn {
        width: 100%;
    }

    .enlace-oficina-methods-section {
        padding: 24px 18px;
    }
}

/* Accesibilidad: Reducción de Movimiento */
@media (prefers-reduced-motion: reduce) {
    .enlace-oficina-methods-section.is-expanded {
        animation: none !important;
    }

    .enlace-btn-toggle-methods .enlace-icon-arrow,
    .enlace-icon-arrow {
        transition: none !important;
    }
}
