/**
 * CSS Frontend para Bloques de WooCommerce Product Dates
 * Ruta: /wp-content/plugins/woocommerce-product-dates/assets/css/blocks-frontend.css
 */

/* === BLOQUE 1: TEXTO DE FECHAS DISPONIBLES === */
.wc-available-dates-text {
    display: block;
    margin: 16px 0;
    line-height: 1.5;
}

.wc-dates-no-product,
.wc-dates-no-dates,
.wc-dates-no-future-dates {
    color: #666;
    font-style: italic;
    margin: 12px 0;
}

/* === BLOQUE 2: FILTRO DE CALENDARIO === */
.wc-calendar-filter {
    max-width: 400px;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.wc-calendar-title {
    margin: 0 0 16px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--wp--preset--color--foreground, #1a202c);
}

/* === CONTENEDOR DEL CALENDARIO === */
.wc-calendar-container {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius, 8px);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
}

.wc-calendar-container:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* === TAMAÑOS === */
.wc-calendar-filter[data-size="small"] .wc-calendar-container {
    font-size: 13px;
    max-width: 280px;
}

.wc-calendar-filter[data-size="medium"] .wc-calendar-container {
    font-size: 14px;
    max-width: 350px;
}

.wc-calendar-filter[data-size="large"] .wc-calendar-container {
    font-size: 16px;
    max-width: 420px;
}

/* === HEADER DEL CALENDARIO === */
.wc-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.wc-calendar-nav {
    background: none;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #4a5568;
    font-weight: bold;
    transition: all 0.2s ease;
}

.wc-calendar-nav:hover {
    background: #e2e8f0;
    border-color: #a0aec0;
    color: #2d3748;
}

.wc-calendar-nav:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wc-calendar-month-year {
    font-weight: 600;
    font-size: 1.1em;
    color: #2d3748;
    min-width: 140px;
    text-align: center;
}

/* === DÍAS DE LA SEMANA === */
.wc-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.wc-calendar-weekday {
    padding: 8px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85em;
    color: #64748b;
    background: #f1f5f9;
}

/* === GRID DE DÍAS === */
.wc-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e2e8f0;
}

.wc-calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #4a5568;
    font-weight: 500;
    cursor: default;
    transition: all 0.2s ease;
    position: relative;
    min-height: 40px;
}

/* === ESTADOS DE LOS DÍAS === */
.wc-calendar-day.other-month {
    color: #cbd5e0;
    background: #f8fafc;
}

.wc-calendar-day.today {
    background: #e6fffa;
    color: #0d9488;
    font-weight: 700;
}

.wc-calendar-day.available {
    cursor: pointer;
    background: #f0f9ff;
    color: #0369a1;
    font-weight: 600;
}

.wc-calendar-day.available:hover {
    background: var(--accent-color, #0073aa);
    color: #ffffff;
    transform: scale(1.05);
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
}

.wc-calendar-day.available::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--accent-color, #0073aa);
    border-radius: 50%;
}

.wc-calendar-day.available:hover::after {
    background: #ffffff;
}

.wc-calendar-day.selected {
    background: var(--accent-color, #0073aa) !important;
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.3);
}

.wc-calendar-day.selected::after {
    background: #ffffff;
}

.wc-calendar-day.unavailable {
    color: #e2e8f0;
    cursor: not-allowed;
}

/* === CONTADOR DE PRODUCTOS === */
.wc-calendar-product-count {
    padding: 8px 16px;
    background: #f0f9ff;
    border-top: 1px solid #e2e8f0;
    text-align: center;
    font-size: 0.9em;
    color: #0369a1;
    font-weight: 500;
}

/* === ACCIONES DEL CALENDARIO === */
.wc-calendar-actions {
    padding: 16px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    justify-content: center;
}

.wc-calendar-apply,
.wc-calendar-clear {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
}

.wc-calendar-apply {
    background: var(--accent-color, #0073aa);
    color: #ffffff;
}

.wc-calendar-apply:hover {
    background: var(--accent-color-dark, #005a87);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.wc-calendar-apply:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.wc-calendar-clear {
    background: #ffffff;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

.wc-calendar-clear:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #4b5563;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .wc-calendar-filter {
        max-width: 100%;
    }
    
    .wc-calendar-container {
        font-size: 13px;
    }
    
    .wc-calendar-header {
        padding: 12px 16px;
    }
    
    .wc-calendar-nav {
        width: 28px;
        height: 28px;
    }
    
    .wc-calendar-day {
        min-height: 35px;
    }
    
    .wc-calendar-actions {
        padding: 12px 16px;
        flex-direction: column;
    }
    
    .wc-calendar-apply,
    .wc-calendar-clear {
        width: 100%;
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .wc-calendar-day {
        min-height: 30px;
        font-size: 0.9em;
    }
    
    .wc-calendar-weekday {
        padding: 6px 4px;
        font-size: 0.8em;
    }
    
    .wc-calendar-header {
        padding: 10px 12px;
    }
    
    .wc-calendar-month-year {
        font-size: 1em;
        min-width: 120px;
    }
}

/* === FILTRO ACTIVO === */
.wc-filter-active-indicator {
    background: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 16px;
    color: #1e40af;
    font-size: 0.9em;
    font-weight: 500;
}

/* === MENSAJE DE FILTRO === */
.wc-filter-message {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* === MODO OSCURO === */
@media (prefers-color-scheme: dark) {
    .wc-calendar-container {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .wc-calendar-header {
        background: #111827;
        border-color: #374151;
    }
    
    .wc-calendar-month-year {
        color: #f9fafb;
    }
    
    .wc-calendar-nav {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }
    
    .wc-calendar-nav:hover {
        background: #4b5563;
        color: #f9fafb;
    }
    
    .wc-calendar-weekdays {
        background: #111827;
        border-color: #374151;
    }
    
    .wc-calendar-weekday {
        background: #111827;
        color: #9ca3af;
    }
    
    .wc-calendar-grid {
        background: #374151;
    }
    
    .wc-calendar-day {
        background: #1f2937;
        color: #d1d5db;
    }
    
    .wc-calendar-day.other-month {
        background: #111827;
        color: #6b7280;
    }
    
    .wc-calendar-day.today {
        background: #065f46;
        color: #34d399;
    }
    
    .wc-calendar-day.available {
        background: #1e3a8a;
        color: #93c5fd;
    }
    
    .wc-calendar-actions {
        background: #111827;
        border-color: #374151;
    }
    
    .wc-calendar-clear {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }
    
    .wc-calendar-clear:hover {
        background: #4b5563;
        color: #f9fafb;
    }
}

/* === ACCESIBILIDAD === */
@media (prefers-reduced-motion: reduce) {
    .wc-calendar-day,
    .wc-calendar-nav,
    .wc-calendar-apply,
    .wc-calendar-clear {
        transition: none;
    }
    
    .wc-calendar-day.available:hover {
        transform: none;
    }
    
    .wc-calendar-apply:hover {
        transform: none;
    }
    
    .wc-filter-message {
        animation: none;
    }
}

.wc-calendar-day:focus-visible {
    outline: 2px solid var(--accent-color, #0073aa);
    outline-offset: 2px;
}

.wc-calendar-nav:focus-visible,
.wc-calendar-apply:focus-visible,
.wc-calendar-clear:focus-visible {
    outline: 2px solid var(--accent-color, #0073aa);
    outline-offset: 2px;
}

/* === LOADING STATES === */
.wc-calendar-container.loading {
    opacity: 0.6;
    pointer-events: none;
}

.wc-calendar-container.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--accent-color, #0073aa);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === INTEGRACIÓN CON WOOCOMMERCE === */
.woocommerce .wc-calendar-filter {
    margin: 20px 0;
}

.woocommerce-page .wc-calendar-filter {
    margin: 20px 0;
}

/* === COMPATIBILIDAD CON TEMAS === */
.wp-block-wc-product-dates-available-dates-text {
    margin: 1em 0;
}

.wp-block-wc-product-dates-calendar-filter {
    margin: 2em 0;
}

/* === VARIABLES CSS PERSONALIZABLES === */
:root {
    --wc-calendar-accent: #0073aa;
    --wc-calendar-radius: 8px;
    --wc-calendar-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wc-calendar-filter {
    --accent-color: var(--wc-calendar-accent);
    --border-radius: var(--wc-calendar-radius);
}

.wc-calendar-container {
    box-shadow: var(--wc-calendar-shadow);
}

/* === IMPRESIÓN === */
@media print {
    .wc-calendar-filter {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .wc-calendar-actions {
        display: none;
    }
    
    .wc-calendar-day.available::after {
        display: none;
    }
    
    .wc-calendar-day.selected {
        background: #000 !important;
        color: #fff !important;
        border: 2px solid #000;
    }
}