/**
 * Legal Compliance ES - Frontend Styles
 * Version: 1.0.0
 */

/* ========================================
   1. BANNER DE COOKIES
   ======================================== */
#lce-cookie-banner {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 999999; /* Por encima de todo, incluso WP Admin Bar */
    padding: 20px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

#lce-cookie-banner * {
    box-sizing: border-box;
}

#lce-cookie-banner.bottom {
    bottom: 0;
    border-top: 1px solid rgba(0,0,0,0.05);
}

#lce-cookie-banner.top {
    top: 0;
    bottom: auto;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.lce-banner-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    flex-wrap: wrap;
}

.lce-banner-text {
    flex: 1;
    min-width: 300px;
}

.lce-banner-text h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

.lce-banner-text p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.lce-banner-text a {
    text-decoration: underline;
    font-weight: 500;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.lce-banner-text a:hover {
    opacity: 1;
}

/* Botones del Banner */
.lce-banner-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.lce-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
    text-align: center;
}

.lce-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.lce-btn:active {
    transform: translateY(0);
}

.lce-btn-accept {
    /* Color definido en línea por PHP, fallback aquí */
    background: #10b981;
    color: white;
}

.lce-btn-reject {
    background: #ef4444; /* Rojo suave */
    color: white;
    border: 1px solid rgba(0,0,0,0.05);
}

.lce-btn-config {
    background: transparent;
    border: 1px solid currentColor;
    opacity: 0.8;
}

.lce-btn-config:hover {
    background: rgba(0,0,0,0.05);
    opacity: 1;
}

/* ========================================
   2. MODAL DE CONFIGURACIÓN
   ======================================== */
#lce-cookie-modal {
    display: none; /* Oculto por defecto */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1000000;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
}

#lce-cookie-modal.active {
    display: flex;
    animation: lceFadeIn 0.3s ease;
}

@keyframes lceFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lce-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Cabecera del Modal */
.lce-modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-radius: 12px 12px 0 0;
}

.lce-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

/* Cuerpo del Modal (Scrollable) */
.lce-modal-body {
    padding: 25px;
    overflow-y: auto;
    color: #4b5563;
    font-size: 15px;
    line-height: 1.6;
}

.lce-modal-body > p {
    margin-top: 0;
    margin-bottom: 20px;
}

/* Categorías de Cookies */
.lce-cookie-category {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    transition: border-color 0.2s;
}

.lce-cookie-category:hover {
    border-color: #d1d5db;
}

.lce-cookie-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.lce-cookie-category-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lce-cookie-category p {
    margin: 5px 0 0;
    font-size: 13px;
    color: #6b7280;
}

.lce-cookie-category strong {
    color: #374151;
}

/* Footer del Modal */
.lce-modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    background: #f9fafb;
    border-radius: 0 0 12px 12px;
}

/* ========================================
   3. INTERRUPTORES (SWITCHES)
   ======================================== */
.lce-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.lce-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.lce-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 34px;
}

.lce-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .lce-slider {
    background-color: #10b981; /* Verde activo */
}

input:focus + .lce-slider {
    box-shadow: 0 0 1px #10b981;
}

input:checked + .lce-slider:before {
    transform: translateX(20px);
}

/* Estado deshabilitado (Cookies Necesarias) */
input:disabled + .lce-slider {
    background-color: #94a3b8;
    opacity: 0.6;
    cursor: not-allowed;
}

input:checked:disabled + .lce-slider {
    background-color: #10b981;
    opacity: 0.5;
}

/* ========================================
   4. BOTÓN FLOTANTE (REABRIR)
   ======================================== */
#lce-modify-consent {
    position: fixed;
    bottom: 25px;
    background: #ffffff;
    color: #333333;
    padding: 10px 18px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    font-size: 13px;
    font-weight: 600;
    z-index: 999998;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #f3f4f6;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Posicionamiento */
#lce-modify-consent.left {
    left: 25px;
    right: auto;
}

#lce-modify-consent.right {
    right: 25px;
    left: auto;
}

/* Hover Effect */
#lce-modify-consent:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    color: #2563eb;
    border-color: #2563eb;
}

/* Icono cookie */
#lce-modify-consent::before {
    content: "🍪";
    font-size: 16px;
    line-height: 1;
}

/* ========================================
   5. BOTÓN EN POLÍTICA DE COOKIES
   ======================================== */
.lce-btn-config-cookies {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.lce-btn-config-cookies:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #111827;
}

/* ========================================
   6. RESPONSIVE (MÓVIL)
   ======================================== */
@media (max-width: 768px) {
    /* Banner */
    .lce-banner-content {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
    }
    
    .lce-banner-text {
        text-align: center;
    }
    
    .lce-banner-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .lce-btn {
        width: 100%;
        padding: 12px;
        font-size: 15px;
    }

    /* Modal */
    #lce-cookie-modal {
        padding: 0;
        align-items: flex-end; /* Sheet style en móvil */
    }

    .lce-modal-content {
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        max-width: 100%;
    }

    .lce-modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
        border-radius: 20px 20px 0 0;
    }

    .lce-modal-footer {
        flex-direction: column-reverse;
        padding-bottom: 30px; /* Safe area para iOS */
    }

    /* Botón flotante en móvil */
    #lce-modify-consent {
        bottom: 20px;
        padding: 8px 14px;
    }
    
    #lce-modify-consent.left { left: 15px; }
    #lce-modify-consent.right { right: 15px; }
}

/* Ajustes para impresión */
@media print {
    #lce-cookie-banner,
    #lce-cookie-modal,
    #lce-modify-consent {
        display: none !important;
    }
}