/* 
 * CSS Frontend para WooCommerce Product Dates - Sistema Modal FSE Compatible
 * Ruta: /wp-content/plugins/woocommerce-product-dates/assets/css/frontend.css
 */

/* === MODAL BASE === */
.wc-dates-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.wc-dates-modal.show {
    opacity: 1;
    visibility: visible;
}

/* === BACKDROP === */
.wc-dates-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

/* === CONTENEDOR PRINCIPAL === */
.wc-dates-modal-container {
    position: relative;
    background: var(--wp--preset--color--background, #ffffff);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    width: 500px;
    overflow: hidden;
    transform: scale(0.7);
    transition: transform 0.3s ease;
}

.wc-dates-modal.show .wc-dates-modal-container {
    transform: scale(1);
}

/* === HEADER === */
.wc-dates-modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--wp--preset--color--neutral-200, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--wp--preset--color--background, #ffffff);
}

.wc-dates-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--wp--preset--color--foreground, #1a202c);
    line-height: 1.3;
}

.wc-dates-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    color: var(--wp--preset--color--neutral-500, #64748b);
    transition: all 0.2s ease;
    line-height: 1;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wc-dates-modal-close:hover {
    background: var(--wp--preset--color--neutral-100, #f1f5f9);
    color: var(--wp--preset--color--foreground, #1a202c);
}

/* === BODY === */
.wc-dates-modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.wc-dates-modal-description {
    margin: 0 0 20px 0;
    color: var(--wp--preset--color--neutral-600, #475569);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* === LISTA DE FECHAS === */
.wc-dates-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.wc-date-option {
    position: relative;
}

.wc-date-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* === TARJETAS DE FECHA === */
.wc-date-card {
    display: block;
    padding: 16px;
    border: 2px solid var(--wp--preset--color--neutral-200, #e2e8f0);
    border-radius: 8px;
    background: var(--wp--preset--color--background, #ffffff);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.wc-date-card:hover {
    border-color: var(--wp--preset--color--primary, #0073aa);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.15);
    transform: translateY(-1px);
    text-decoration: none;
}

.wc-date-option.selected .wc-date-card,
.wc-date-option input[type="radio"]:checked + .wc-date-card {
    border-color: var(--wp--preset--color--primary, #0073aa);
    background: linear-gradient(135deg, var(--wp--preset--color--primary, #0073aa), var(--wp--preset--color--primary, #0073aa));
    color: #ffffff;
    box-shadow: 0 8px 25px rgba(0, 115, 170, 0.3);
}

/* === CONTENIDO DE FECHA === */
.wc-date-info {
    text-align: center;
}

.wc-date-primary {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.3;
}

.wc-date-time {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 6px;
}

.wc-date-title {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 4px;
}

.wc-date-option:not(.selected) .wc-date-title {
    background: var(--wp--preset--color--neutral-100, #f1f5f9);
    color: var(--wp--preset--color--primary, #0073aa);
}

/* === INDICADOR DE SELECCIÓN === */
.wc-date-option.selected .wc-date-card::before,
.wc-date-option input[type="radio"]:checked + .wc-date-card::before {
    content: "✓";
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ffffff;
    color: var(--wp--preset--color--primary, #0073aa);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* === STATES DE CARGA Y ERROR === */
.wc-dates-modal-loading {
    text-align: center;
    padding: 40px 24px;
    color: var(--wp--preset--color--neutral-600, #475569);
}

.wc-dates-modal-loading .spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--wp--preset--color--neutral-200, #e2e8f0);
    border-top: 3px solid var(--wp--preset--color--primary, #0073aa);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.wc-dates-modal-error {
    text-align: center;
    padding: 40px 24px;
    color: #dc2626;
}

.wc-dates-modal-error p {
    margin: 0;
    font-size: 0.95rem;
}

/* === FOOTER === */
.wc-dates-modal-footer {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--wp--preset--color--neutral-200, #e2e8f0);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: var(--wp--preset--color--background, #ffffff);
}

/* === BOTONES === */
.wc-dates-btn {
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
}

.wc-dates-btn-secondary {
    background: var(--wp--preset--color--neutral-100, #f1f5f9);
    color: var(--wp--preset--color--neutral-700, #374151);
    border: 1px solid var(--wp--preset--color--neutral-300, #d1d5db);
}

.wc-dates-btn-secondary:hover {
    background: var(--wp--preset--color--neutral-200, #e2e8f0);
    color: var(--wp--preset--color--neutral-800, #1f2937);
}

.wc-dates-btn-primary {
    background: var(--wp--preset--color--primary, #0073aa);
    color: #ffffff;
    border: 1px solid var(--wp--preset--color--primary, #0073aa);
}

.wc-dates-btn-primary:hover:not(:disabled) {
    background: var(--wp--preset--color--primary-dark, #005a87);
    border-color: var(--wp--preset--color--primary-dark, #005a87);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.wc-dates-btn-primary:disabled {
    background: var(--wp--preset--color--neutral-400, #94a3b8);
    border-color: var(--wp--preset--color--neutral-400, #94a3b8);
    cursor: not-allowed;
    opacity: 0.6;
}

/* === BODY LOCK === */
body.wc-dates-modal-open {
    overflow: hidden;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .wc-dates-modal-container {
        width: 95vw;
        max-height: 95vh;
        margin: 20px;
    }
    
    .wc-dates-list {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .wc-dates-modal-header {
        padding: 20px 20px 12px;
    }
    
    .wc-dates-modal-header h3 {
        font-size: 1.1rem;
    }
    
    .wc-dates-modal-body {
        padding: 20px;
    }
    
    .wc-dates-modal-footer {
        padding: 12px 20px 20px;
        flex-direction: column-reverse;
    }
    
    .wc-dates-btn {
        width: 100%;
        justify-content: center;
    }
    
    .wc-date-card {
        padding: 14px;
    }
}

@media (max-width: 480px) {
    .wc-dates-modal-container {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
    
    .wc-dates-modal-body {
        max-height: calc(100vh - 160px);
    }
    
    .wc-dates-modal-header h3 {
        font-size: 1rem;
        line-height: 1.4;
    }
    
    .wc-date-primary {
        font-size: 1rem;
    }
}

/* === ACCESIBILIDAD === */
@media (prefers-reduced-motion: reduce) {
    .wc-dates-modal,
    .wc-dates-modal-container,
    .wc-date-card,
    .wc-dates-btn {
        transition: none;
    }
    
    .wc-date-card:hover {
        transform: none;
    }
    
    .wc-dates-btn-primary:hover:not(:disabled) {
        transform: none;
    }
    
    .spinner {
        animation: none;
    }
}

.wc-dates-modal:focus-within .wc-date-card:focus,
.wc-date-card:focus-visible {
    outline: 2px solid var(--wp--preset--color--primary, #0073aa);
    outline-offset: 2px;
}

.wc-dates-btn:focus-visible {
    outline: 2px solid var(--wp--preset--color--primary, #0073aa);
    outline-offset: 2px;
}

/* === MODO OSCURO === */
@media (prefers-color-scheme: dark) {
    .wc-dates-modal-backdrop {
        background: rgba(0, 0, 0, 0.8);
    }
    
    .wc-dates-modal-container {
        background: var(--wp--preset--color--background, #1a202c);
        color: var(--wp--preset--color--foreground, #f7fafc);
    }
    
    .wc-dates-modal-header {
        border-bottom-color: var(--wp--preset--color--neutral-700, #374151);
        background: var(--wp--preset--color--background, #1a202c);
    }
    
    .wc-dates-modal-footer {
        border-top-color: var(--wp--preset--color--neutral-700, #374151);
        background: var(--wp--preset--color--background, #1a202c);
    }
    
    .wc-date-card {
        background: var(--wp--preset--color--neutral-800, #2d3748);
        border-color: var(--wp--preset--color--neutral-600, #4a5568);
        color: var(--wp--preset--color--foreground, #f7fafc);
    }
    
    .wc-date-option:not(.selected) .wc-date-title {
        background: var(--wp--preset--color--neutral-700, #374151);
        color: var(--wp--preset--color--primary-light, #63b3ed);
    }
}

/* === INTEGRACIÓN CON TEMAS FSE === */
.wp-site-blocks .wc-dates-modal {
    font-family: var(--wp--preset--font-family--system, system-ui, -apple-system, sans-serif);
}

.wp-site-blocks .wc-dates-modal-header h3 {
    font-family: var(--wp--preset--font-family--heading, inherit);
}

/* === COMPATIBILIDAD CON WOOCOMMERCE === */
.woocommerce .wc-dates-modal {
    z-index: 999999;
}

.single-product .wc-dates-modal {
    z-index: 999999;
}

/* === ANIMACIONES ADICIONALES === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wc-dates-list .wc-date-option {
    animation: fadeInUp 0.3s ease forwards;
}

.wc-dates-list .wc-date-option:nth-child(1) { animation-delay: 0.05s; }
.wc-dates-list .wc-date-option:nth-child(2) { animation-delay: 0.1s; }
.wc-dates-list .wc-date-option:nth-child(3) { animation-delay: 0.15s; }
.wc-dates-list .wc-date-option:nth-child(4) { animation-delay: 0.2s; }
.wc-dates-list .wc-date-option:nth-child(5) { animation-delay: 0.25s; }
.wc-dates-list .wc-date-option:nth-child(6) { animation-delay: 0.3s; }

/* === ALTA DENSIDAD DE PÍXELES === */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .wc-dates-modal-container {
        box-shadow: 0 25px 70px rgba(0, 0, 0, 0.35);
    }
}

/* === IMPRESIÓN === */
@media print {
    .wc-dates-modal {
        display: none !important;
    }
}