/**
 * Edenred Icon Widget Styles
 * 
 * Estilos para el widget de iconos de Edenred
 * Incluye estilos del editor y del frontend
 */

/* ==========================================================================
   Widget Container
   ========================================================================== */

/* Base Layout */
.edenred-icon-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--edenred-icon-gap, 15px);
}

/* Helper to define directions */
.edenred-icon-position-top .edenred-icon-box,
.edenred-icon-position-tablet-top .edenred-icon-box,
.edenred-icon-position-mobile-top .edenred-icon-box {
    flex-direction: column;
}

.edenred-icon-position-left .edenred-icon-box,
.edenred-icon-position-tablet-left .edenred-icon-box,
.edenred-icon-position-mobile-left .edenred-icon-box {
    flex-direction: row;
    align-items: center;
}

.edenred-icon-position-right .edenred-icon-box,
.edenred-icon-position-tablet-right .edenred-icon-box,
.edenred-icon-position-mobile-right .edenred-icon-box {
    flex-direction: row-reverse;
    align-items: center;
}

/* Responsive Overrides */
@media (min-width: 1025px) {
    .edenred-icon-position-top .edenred-icon-box {
        flex-direction: column;
    }

    .edenred-icon-position-left .edenred-icon-box {
        flex-direction: row;
    }

    .edenred-icon-position-right .edenred-icon-box {
        flex-direction: row-reverse;
    }
}

@media (max-width: 1024px) {
    .edenred-icon-position-tablet-top .edenred-icon-box {
        flex-direction: column;
    }

    .edenred-icon-position-tablet-left .edenred-icon-box {
        flex-direction: row;
    }

    .edenred-icon-position-tablet-right .edenred-icon-box {
        flex-direction: row-reverse;
    }
}

@media (max-width: 767px) {
    .edenred-icon-position-mobile-top .edenred-icon-box {
        flex-direction: column;
    }

    .edenred-icon-position-mobile-left .edenred-icon-box {
        flex-direction: row;
    }

    .edenred-icon-position-mobile-right .edenred-icon-box {
        flex-direction: row-reverse;
    }
}

/* ==========================================================================
   Icon Styles
   ========================================================================== */

.edenred-icon-box__icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.edenred-icon-box__icon svg {
    display: block;
    width: 80px;
    height: 80px;
    max-width: 100%;
    height: auto;
}

/* Placeholder cuando no hay icono */
.edenred-icon-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 4px;
    color: #999;
    font-size: 32px;
}

/* Error del icono en editor */
.edenred-icon-error {
    padding: 10px;
    margin-bottom: 10px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    font-size: 12px;
    text-align: center;
}

.edenred-icon-error i {
    font-size: 16px;
    margin-bottom: 5px;
}

.edenred-icon-error p {
    margin: 0;
}

/* ==========================================================================
   Content Styles
   ========================================================================== */

.edenred-icon-box__content {
    flex: 1;
    min-width: 0;
}

.edenred-icon-box__title {
    margin: 0 0 10px 0;
    /*font-size: 24px;*/
    font-weight: 600;
    line-height: 1.3;
    color: #333;
}

.edenred-icon-box__description {
    margin: 0;
    /*font-size: 16px;*/
    line-height: 1.6;
    color: #666;
}

.edenred-icon-box__description p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   Link Styles
   ========================================================================== */

.edenred-icon-box a {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: inherit;
    align-items: inherit;
    gap: inherit;
}

.edenred-icon-box a:hover .edenred-icon-box__title {
    color: #0073aa;
}

/* ==========================================================================
   Editor Specific Styles
   ========================================================================== */

/* Botón de abrir galería en el panel */
.edenred-icon-selector-wrapper {
    margin: 10px 0;
}

.edenred-open-icon-gallery {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.edenred-open-icon-gallery:hover {
    background: #0073aa !important;
    border-color: #0073aa !important;
    color: #fff !important;
}

/* Previsualización del icono en el panel de control */
.edenred-icon-preview-container {
    margin: 15px 0;
}

.edenred-icon-preview-box {
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    text-align: center;
}

.edenred-icon-preview-content {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.edenred-icon-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #999;
}

.edenred-icon-preview-placeholder i {
    font-size: 48px;
}

.edenred-icon-preview-placeholder p {
    margin: 0;
    font-size: 14px;
}

.edenred-icon-preview-svg {
    display: flex;
    justify-content: center;
    align-items: center;
}

.edenred-icon-preview-svg svg {
    max-width: 100px;
    max-height: 100px;
    height: auto;
}

/* Previsualización en el editor de Elementor */
.edenred-icon-preview-editor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px;
    background: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 4px;
    color: #666;
    font-size: 12px;
    min-width: 80px;
    min-height: 80px;
    justify-content: center;
}

.edenred-icon-preview-editor i {
    font-size: 24px;
}

/* ==========================================================================
   Modal de Galería
   ========================================================================== */

.edenred-icon-gallery-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    align-items: center;
    justify-content: center;
}

.edenred-icon-gallery-modal.active {
    display: flex;
}

.edenred-icon-gallery-content {
    background: #fff;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header de la modal */
.edenred-icon-gallery-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.edenred-icon-gallery-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.edenred-icon-gallery-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.edenred-icon-gallery-close:hover {
    background: #e0e0e0;
    color: #333;
}

/* Body de la modal */
.edenred-icon-gallery-body {
    padding: 30px;
    overflow-y: auto;
}

/* Grid de iconos */
.edenred-icon-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.edenred-icon-gallery-item {
    position: relative;
    aspect-ratio: 1;
    cursor: pointer;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    background: #fff;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.edenred-icon-gallery-item:hover {
    border-color: #0073aa;
    background: #f0f8ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.2);
}

.edenred-icon-gallery-item.selected {
    border-color: #0073aa;
    background: #e3f2fd;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.2);
}

.edenred-icon-gallery-item svg {
    width: 100%;
    height: 100%;
    max-width: 60px;
    max-height: 60px;
}

/* Tooltip con el nombre del icono */
.edenred-icon-gallery-item::after {
    content: attr(data-title);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.edenred-icon-gallery-item:hover::after {
    opacity: 1;
}

/* Footer de la modal */
.edenred-icon-gallery-footer {
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.edenred-icon-gallery-info {
    font-size: 13px;
    color: #666;
}

.edenred-icon-gallery-actions {
    display: flex;
    gap: 10px;
}

.edenred-icon-gallery-button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.edenred-icon-gallery-button-cancel {
    background: #f0f0f0;
    color: #666;
}

.edenred-icon-gallery-button-cancel:hover {
    background: #e0e0e0;
}

.edenred-icon-gallery-button-select {
    background: #0073aa;
    color: #fff;
}

.edenred-icon-gallery-button-select:hover {
    background: #005a87;
}

.edenred-icon-gallery-button-select:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Loading state */
.edenred-icon-gallery-loading {
    padding: 60px 30px;
    text-align: center;
    color: #666;
}

.edenred-icon-gallery-loading i {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
}

/* Empty state */
.edenred-icon-gallery-empty {
    padding: 60px 30px;
    text-align: center;
    color: #999;
}

.edenred-icon-gallery-empty i {
    font-size: 64px;
    margin-bottom: 15px;
    display: block;
    color: #ccc;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .edenred-icon-gallery-content {
        width: 95%;
        max-height: 90vh;
    }

    .edenred-icon-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 10px;
    }

    .edenred-icon-gallery-header,
    .edenred-icon-gallery-body,
    .edenred-icon-gallery-footer {
        padding: 15px 20px;
    }

    .edenred-icon-box__title {
        /*font-size: 20px;*/
    }

    .edenred-icon-box__description {
        /*font-size: 14px;*/
    }
}

@media (max-width: 480px) {
    .edenred-icon-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 8px;
    }

    .edenred-icon-position-left .edenred-icon-box,
    .edenred-icon-position-right .edenred-icon-box {
        /*flex-direction: column;*/
    }
}