/**
 * IP Cookie Consent - Estilos
 * RGPD / LSSI-CE / ePrivacy 2026
 * Diseño responsive, accesible y completamente configurable
 */

/* ================================================================
   VARIABLES CSS
   ================================================================ */
:root {
    --ipc-primary:        #c8a96e;
    --ipc-primary-dark:   #a8894e;
    --ipc-primary-light:  #e8c98e;
    --ipc-secondary:      #4a4a4a;
    --ipc-bg:             #ffffff;
    --ipc-text:           #1a1a1a;
    --ipc-text-light:     #666666;
    --ipc-border:         #e0e0e0;
    --ipc-overlay:        rgba(0, 0, 0, 0.78);
    --ipc-shadow:         0 20px 60px rgba(0, 0, 0, 0.3), 0 4px 20px rgba(0, 0, 0, 0.15);
    --ipc-radius:         12px;
    --ipc-radius-sm:      8px;
    --ipc-transition:     0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --ipc-font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ipc-z-overlay:      2147483640;
    --ipc-z-banner:       2147483641;
    --ipc-z-float:        2147483639;
}

/* ================================================================
   OVERLAY (Pantalla oscurecida)
   ================================================================ */
.ip-cookie-overlay {
    position: fixed;
    inset: 0;
    background: var(--ipc-overlay);
    z-index: var(--ipc-z-overlay);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: ipcOverlayFadeIn 0.3s ease forwards;
}

@keyframes ipcOverlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ================================================================
   BANNER PRINCIPAL
   ================================================================ */
.ip-cookie-banner {
    background: var(--ipc-bg);
    border-radius: var(--ipc-radius);
    box-shadow: var(--ipc-shadow);
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: var(--ipc-z-banner);
    font-family: var(--ipc-font);
    color: var(--ipc-text);
    position: relative;
    animation: ipcBannerSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    scrollbar-width: thin;
    scrollbar-color: var(--ipc-primary) var(--ipc-border);
}

.ip-cookie-banner::-webkit-scrollbar {
    width: 5px;
}
.ip-cookie-banner::-webkit-scrollbar-track {
    background: var(--ipc-border);
    border-radius: 10px;
}
.ip-cookie-banner::-webkit-scrollbar-thumb {
    background: var(--ipc-primary);
    border-radius: 10px;
}

@keyframes ipcBannerSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ================================================================
   HEADER DEL BANNER
   ================================================================ */
.ip-cookie-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 28px 16px;
    border-bottom: 1px solid var(--ipc-border);
}

.ip-cookie-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--ipc-primary), var(--ipc-primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

.ip-cookie-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ipc-text);
    line-height: 1.3;
}

/* ================================================================
   CUERPO DEL BANNER
   ================================================================ */
.ip-cookie-body {
    padding: 20px 28px 8px;
}

.ip-cookie-description {
    margin: 0 0 10px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--ipc-text-light);
}

.ip-cookie-links {
    margin: 0;
    font-size: 0.85rem;
}
.ip-cookie-links a {
    color: var(--ipc-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--ipc-transition);
}
.ip-cookie-links a:hover {
    color: var(--ipc-primary-dark);
    text-decoration: underline;
}

/* ================================================================
   BOTONES DE ACCIÓN PRINCIPAL
   ================================================================ */
.ip-cookie-actions {
    padding: 16px 28px 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ip-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 11px 20px;
    border-radius: var(--ipc-radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--ipc-transition);
    white-space: nowrap;
    letter-spacing: 0.3px;
    font-family: var(--ipc-font);
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
.ip-btn:focus-visible {
    outline: 3px solid var(--ipc-primary);
    outline-offset: 2px;
}

.ip-btn-primary {
    background: linear-gradient(135deg, var(--ipc-primary), var(--ipc-primary-dark));
    color: #ffffff;
    border-color: transparent;
}
.ip-btn-primary:hover {
    background: linear-gradient(135deg, var(--ipc-primary-dark), #8a6930);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(200, 169, 110, 0.4);
}
.ip-btn-primary:active {
    transform: translateY(0);
}

.ip-btn-secondary {
    background: transparent;
    color: var(--ipc-secondary);
    border-color: var(--ipc-border);
}
.ip-btn-secondary:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.ip-btn-outline {
    background: transparent;
    color: var(--ipc-primary);
    border-color: var(--ipc-primary);
}
.ip-btn-outline:hover {
    background: rgba(200, 169, 110, 0.08);
}

/* ================================================================
   PANEL DE PREFERENCIAS
   ================================================================ */
.ip-cookie-preferences {
    padding: 0 28px 24px;
    border-top: 1px solid var(--ipc-border);
    margin-top: 4px;
    animation: ipcPrefsSlideDown 0.3s ease forwards;
}

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

.ip-prefs-title {
    margin: 20px 0 16px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ipc-text);
}

/* ================================================================
   CATEGORÍAS DE COOKIES
   ================================================================ */
.ip-cookie-category {
    border: 1px solid var(--ipc-border);
    border-radius: var(--ipc-radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color var(--ipc-transition);
}
.ip-cookie-category:hover {
    border-color: var(--ipc-primary);
}

.ip-category-necessary {
    border-color: rgba(200, 169, 110, 0.3);
    background: rgba(200, 169, 110, 0.03);
}

.ip-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ip-category-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
}

.ip-category-icon {
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.ip-category-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ipc-text);
    display: block;
    margin-bottom: 4px;
}

.ip-category-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ip-badge-required {
    background: rgba(200, 169, 110, 0.15);
    color: var(--ipc-primary-dark);
}

.ip-category-description {
    font-size: 0.85rem;
    color: var(--ipc-text-light);
    line-height: 1.55;
    margin: 10px 0 8px;
}

.ip-category-providers {
    font-size: 0.8rem;
    color: var(--ipc-text-light);
    margin: 0 0 8px;
    font-style: italic;
}

/* ================================================================
   TOGGLE SWITCHES
   ================================================================ */
.ip-toggle-wrapper {
    flex-shrink: 0;
}

.ip-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.ip-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.ip-toggle-slider {
    position: absolute;
    inset: 0;
    background-color: #ccc;
    border-radius: 26px;
    transition: all var(--ipc-transition);
}

.ip-toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: all var(--ipc-transition);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.ip-toggle input:checked + .ip-toggle-slider {
    background-color: var(--ipc-primary);
}

.ip-toggle input:checked + .ip-toggle-slider::before {
    transform: translateX(22px);
}

.ip-toggle input:focus-visible + .ip-toggle-slider {
    outline: 3px solid var(--ipc-primary);
    outline-offset: 2px;
}

.ip-toggle-disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.ip-toggle-disabled input:checked + .ip-toggle-slider {
    background-color: var(--ipc-primary);
}

/* ================================================================
   BOTÓN DESPLEGABLE DE DETALLES
   ================================================================ */
.ip-btn-detail-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--ipc-primary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    font-family: var(--ipc-font);
    transition: color var(--ipc-transition);
}
.ip-btn-detail-toggle:hover {
    color: var(--ipc-primary-dark);
}
.ip-btn-detail-toggle:focus-visible {
    outline: 2px solid var(--ipc-primary);
    outline-offset: 2px;
    border-radius: 3px;
}

.ip-chevron {
    display: inline-block;
    transition: transform var(--ipc-transition);
    font-size: 0.65rem;
}
.ip-btn-detail-toggle[aria-expanded="true"] .ip-chevron {
    transform: rotate(180deg);
}

/* ================================================================
   TABLA DE COOKIES DETALLADA
   ================================================================ */
.ip-cookie-detail-table {
    margin-top: 10px;
    border-radius: var(--ipc-radius-sm);
    overflow: hidden;
    border: 1px solid var(--ipc-border);
    animation: ipcTableFadeIn 0.2s ease forwards;
}

@keyframes ipcTableFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.ip-loading {
    padding: 12px;
    text-align: center;
    color: var(--ipc-text-light);
    font-size: 0.85rem;
}

.ip-cookies-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.ip-cookies-table thead {
    background: #f9f9f9;
}

.ip-cookies-table th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 700;
    color: var(--ipc-text);
    border-bottom: 1px solid var(--ipc-border);
    white-space: nowrap;
}

.ip-cookies-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    color: var(--ipc-text-light);
    vertical-align: top;
}

.ip-cookies-table tr:last-child td {
    border-bottom: none;
}

.ip-cookies-table tr:hover td {
    background: rgba(200, 169, 110, 0.04);
}

.ip-cookie-name-cell {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.78rem;
    color: var(--ipc-text);
    font-weight: 600;
    word-break: break-all;
}

/* ================================================================
   ACCIONES DEL PANEL DE PREFERENCIAS
   ================================================================ */
.ip-prefs-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--ipc-border);
}

/* ================================================================
   INFORMACIÓN LEGAL
   ================================================================ */
.ip-legal-info {
    margin-top: 14px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: var(--ipc-radius-sm);
    border-left: 3px solid var(--ipc-primary);
}

.ip-legal-info p {
    margin: 0;
    font-size: 0.77rem;
    color: var(--ipc-text-light);
    line-height: 1.5;
    display: flex;
    gap: 6px;
    align-items: flex-start;
}

.ip-legal-info svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--ipc-primary);
}

.ip-legal-info a {
    color: var(--ipc-primary);
    font-weight: 600;
    text-decoration: none;
}
.ip-legal-info a:hover {
    text-decoration: underline;
}

/* ================================================================
   BOTÓN FLOTANTE
   ================================================================ */
.ip-cookie-float-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ipc-primary), var(--ipc-primary-dark));
    color: #ffffff;
    border: none;
    cursor: pointer;
    z-index: var(--ipc-z-float);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 14px rgba(200, 169, 110, 0.45);
    transition: all var(--ipc-transition);
    animation: ipcFloatBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.ip-cookie-float-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 20px rgba(200, 169, 110, 0.55);
}

.ip-cookie-float-btn:focus-visible {
    outline: 3px solid var(--ipc-primary);
    outline-offset: 3px;
}

@keyframes ipcFloatBounce {
    from { opacity: 0; transform: scale(0); }
    to   { opacity: 1; transform: scale(1); }
}

/* ================================================================
   RESPONSIVE - TABLET
   ================================================================ */
@media (max-width: 768px) {
    .ip-cookie-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .ip-cookie-banner {
        border-radius: var(--ipc-radius) var(--ipc-radius) 0 0;
        max-height: 85vh;
        animation: ipcBannerSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    }

    @keyframes ipcBannerSlideUp {
        from { opacity: 0; transform: translateY(100%); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .ip-cookie-header {
        padding: 20px 20px 14px;
    }

    .ip-cookie-body {
        padding: 16px 20px 8px;
    }

    .ip-cookie-actions {
        padding: 12px 20px 20px;
        flex-direction: column;
    }

    .ip-btn {
        width: 100%;
        justify-content: center;
        padding: 13px 20px;
    }

    .ip-cookie-preferences {
        padding: 0 20px 20px;
    }

    .ip-cookie-title {
        font-size: 1.05rem;
    }
}

/* ================================================================
   RESPONSIVE - MÓVIL PEQUEÑO
   ================================================================ */
@media (max-width: 480px) {
    .ip-cookie-icon {
        width: 40px;
        height: 40px;
    }
    .ip-cookie-icon svg {
        width: 24px;
        height: 24px;
    }
    .ip-cookie-title {
        font-size: 0.98rem;
    }
    .ip-category-name {
        font-size: 0.88rem;
    }
    .ip-category-description {
        font-size: 0.82rem;
    }
    .ip-cookies-table th,
    .ip-cookies-table td {
        padding: 6px 8px;
        font-size: 0.75rem;
    }
    /* Tabla responsive en móvil */
    .ip-cookies-table,
    .ip-cookies-table thead,
    .ip-cookies-table tbody,
    .ip-cookies-table th,
    .ip-cookies-table td,
    .ip-cookies-table tr {
        display: block;
    }
    .ip-cookies-table thead {
        display: none;
    }
    .ip-cookies-table td {
        padding-left: 40%;
        position: relative;
        border-bottom: 1px solid #f0f0f0;
    }
    .ip-cookies-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 8px;
        width: 35%;
        font-weight: 700;
        color: var(--ipc-text);
        font-size: 0.72rem;
    }
    .ip-cookies-table tr {
        border-bottom: 2px solid var(--ipc-border);
        margin-bottom: 4px;
    }
}

/* ================================================================
   ACCESIBILIDAD - NO MOVIMIENTO
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
    .ip-cookie-overlay,
    .ip-cookie-banner,
    .ip-cookie-preferences,
    .ip-cookie-detail-table,
    .ip-cookie-float-btn,
    .ip-btn,
    .ip-toggle-slider,
    .ip-toggle-slider::before,
    .ip-chevron {
        animation: none !important;
        transition: none !important;
    }
}

/* ================================================================
   FOCUS RING PARA TECLADO
   ================================================================ */
:focus-visible {
    outline-color: var(--ipc-primary);
}

/* Ocultar overlay del cuerpo cuando el banner está activo */
body.ip-cookie-active {
    overflow: hidden;
}

/* ================================================================
   ESTILOS PARA LAS PÁGINAS LEGALES GENERADAS
   Afectan a .ip-legal-page dentro de las CMS de PS
   ================================================================ */
.ip-legal-page {
    font-family: var(--ipc-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    color: #1a1a1a;
    line-height: 1.7;
    max-width: 900px;
    margin: 0 auto;
}

.ip-legal-update {
    background: #f0f8ff;
    border-left: 4px solid #3498db;
    padding: 8px 14px;
    border-radius: 0 6px 6px 0;
    font-size: 0.88em;
    margin-bottom: 28px;
}

.ip-legal-page h2 {
    margin-top: 36px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
    font-size: 1.25rem;
    color: #1a1a1a;
}

.ip-legal-page h3 {
    margin-top: 24px;
    margin-bottom: 10px;
    font-size: 1.05rem;
    color: #333;
}

.ip-legal-page ul {
    padding-left: 20px;
    margin-bottom: 16px;
}

.ip-legal-page li {
    margin-bottom: 6px;
}

/* Tablas legales */
.ip-legal-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 0.88em;
}

.ip-legal-table th,
.ip-legal-table td {
    border: 1px solid #e0e0e0;
    padding: 10px 14px;
    vertical-align: top;
    line-height: 1.5;
}

.ip-legal-table thead th {
    background: #f5f5f5;
    font-weight: 700;
    color: #333;
    white-space: nowrap;
}

.ip-legal-table tbody tr:nth-child(even) td {
    background: #fafafa;
}

.ip-legal-table tbody tr:hover td {
    background: rgba(200, 169, 110, 0.06);
}

.ip-legal-table th:first-child {
    width: 200px;
    white-space: nowrap;
}

/* Tabla de cookies con código */
.ip-cookies-detail-table code {
    background: #f0f0f0;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
    color: #c0392b;
    font-family: 'Courier New', Courier, monospace;
    word-break: break-all;
}

/* Wrapper con scroll horizontal en móvil */
.ip-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
    border-radius: 6px;
}

/* Intro box en política de cookies */
.ip-cookies-intro-box {
    background: linear-gradient(135deg, rgba(200, 169, 110, 0.08), rgba(200, 169, 110, 0.03));
    border: 1px solid rgba(200, 169, 110, 0.3);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 28px;
    font-size: 0.95em;
}

/* Botón de gestión de cookies en la página de política */
.ip-cookie-manage-btn-wrapper {
    margin-top: 32px;
    text-align: center;
}

.ip-btn-manage-cookies {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #c8a96e, #a8894e);
    color: #fff;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--ipc-font, sans-serif);
}

.ip-btn-manage-cookies:hover {
    background: linear-gradient(135deg, #a8894e, #8a6930);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(200, 169, 110, 0.45);
}

/* Responsive para tablas en móvil */
@media (max-width: 600px) {
    .ip-legal-table,
    .ip-legal-table thead,
    .ip-legal-table tbody,
    .ip-legal-table th,
    .ip-legal-table td,
    .ip-legal-table tr {
        display: block;
    }
    .ip-legal-table thead {
        display: none;
    }
    .ip-legal-table td {
        border: none;
        border-bottom: 1px solid #f0f0f0;
        padding: 8px 10px;
        position: relative;
    }
    .ip-legal-table tr {
        border: 1px solid #e0e0e0;
        border-radius: 6px;
        margin-bottom: 10px;
        overflow: hidden;
    }
    /* Mantener la tabla de Responsable en dos columnas */
    .ip-legal-page > table.ip-legal-table th:first-child {
        width: auto;
    }
}
