/* =====================================================================
 * Cookie Consent Banner & Modal — Storefront CSS
 *
 * Phase 46: GDPR & Privacy Compliance
 *
 * Works alongside Tailwind CSS. Provides styling for:
 *   - Bottom-fixed consent banner
 *   - Cookie preference customization modal
 *   - Toggle switches for consent categories
 *   - Responsive design with dark theme support
 * ===================================================================== */

/* -----------------------------------------------------------------
 * 1. Cookie Banner
 * --------------------------------------------------------------- */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    background: rgba(15, 15, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 1.5rem;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: rgba(255, 255, 255, 0.85);
}

.cookie-banner--visible {
    transform: translateY(0);
}

.cookie-banner--hidden {
    transform: translateY(100%);
    pointer-events: none;
}

.cookie-banner__content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.cookie-banner__content p {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    flex: 1;
    min-width: 250px;
}

.cookie-banner__link {
    color: #818cf8;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cookie-banner__link:hover {
    color: #a5b4fc;
}

.cookie-banner__actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.cookie-banner__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
}

.cookie-banner__btn--accept {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.cookie-banner__btn--accept:hover {
    background: linear-gradient(135deg, #7c3aed, #6366f1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.cookie-banner__btn--reject {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.cookie-banner__btn--reject:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.cookie-banner__btn--customize {
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cookie-banner__btn--customize:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

/* -----------------------------------------------------------------
 * 2. Cookie Modal
 * --------------------------------------------------------------- */
.cookie-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.cookie-modal--visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.cookie-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
}

.cookie-modal__dialog {
    position: relative;
    width: 90%;
    max-width: 520px;
    max-height: 80vh;
    background: rgba(20, 20, 40, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.25rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: cookieModalSlideUp 0.3s ease-out;
}

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

.cookie-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cookie-modal__header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: #fff;
}

.cookie-modal__close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.cookie-modal__close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.cookie-modal__body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
    color: rgba(255, 255, 255, 0.7);
}

.cookie-modal__body > p {
    margin: 0 0 1rem;
    font-size: 0.8125rem;
    line-height: 1.6;
}

/* -----------------------------------------------------------------
 * 3. Category toggle rows
 * --------------------------------------------------------------- */
.cookie-modal__category {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cookie-modal__category:last-child {
    border-bottom: none;
}

.cookie-modal__category-info {
    flex: 1;
}

.cookie-modal__category-info strong {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.25rem;
}

.cookie-modal__category-info p {
    margin: 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
}

.cookie-modal__required {
    font-size: 0.6875rem;
    color: #818cf8;
    font-weight: 500;
}

/* -----------------------------------------------------------------
 * 4. Toggle switch
 * --------------------------------------------------------------- */
.cookie-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.cookie-toggle__slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    transition: all 0.3s;
}

.cookie-toggle__slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.cookie-toggle input:checked + .cookie-toggle__slider {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
}

.cookie-toggle input:checked + .cookie-toggle__slider::before {
    transform: translateX(20px);
}

.cookie-toggle input:disabled + .cookie-toggle__slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* -----------------------------------------------------------------
 * 5. Modal footer
 * --------------------------------------------------------------- */
.cookie-modal__footer {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    justify-content: flex-end;
}

/* -----------------------------------------------------------------
 * 6. Responsive
 * --------------------------------------------------------------- */
@media (max-width: 640px) {
    .cookie-banner {
        padding: 1rem;
    }

    .cookie-banner__content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .cookie-banner__actions {
        width: 100%;
        justify-content: center;
    }

    .cookie-banner__btn {
        flex: 1;
        min-width: 0;
        padding: 0.625rem 1rem;
    }

    .cookie-modal__dialog {
        width: 95%;
        max-height: 85vh;
    }

    .cookie-modal__footer {
        flex-direction: column;
    }
}

/* -----------------------------------------------------------------
 * 7. Dark theme support (already dark by default)
 * --------------------------------------------------------------- */
@media (prefers-color-scheme: light) {
    .cookie-banner {
        background: rgba(255, 255, 255, 0.95);
        border-top-color: rgba(0, 0, 0, 0.1);
        color: #374151;
    }

    .cookie-banner__link {
        color: #6366f1;
    }

    .cookie-banner__btn--reject {
        background: rgba(0, 0, 0, 0.05);
        color: #374151;
        border-color: rgba(0, 0, 0, 0.15);
    }

    .cookie-banner__btn--customize {
        color: #6b7280;
        border-color: rgba(0, 0, 0, 0.1);
    }

    .cookie-modal__dialog {
        background: #fff;
        border-color: rgba(0, 0, 0, 0.1);
    }

    .cookie-modal__header {
        border-bottom-color: rgba(0, 0, 0, 0.08);
    }

    .cookie-modal__header h3 {
        color: #111827;
    }

    .cookie-modal__close {
        color: #9ca3af;
    }

    .cookie-modal__body {
        color: #6b7280;
    }

    .cookie-modal__category {
        border-bottom-color: rgba(0, 0, 0, 0.06);
    }

    .cookie-modal__category-info strong {
        color: #111827;
    }

    .cookie-modal__category-info p {
        color: #9ca3af;
    }

    .cookie-toggle__slider {
        background: #d1d5db;
    }

    .cookie-modal__footer {
        border-top-color: rgba(0, 0, 0, 0.08);
    }
}

/* -----------------------------------------------------------------
 * 8. No-JS fallback: hide banner elements since no consent = no cookies
 * --------------------------------------------------------------- */
noscript .cookie-banner {
    display: none;
}

/* -----------------------------------------------------------------
 * 9. Print: hide cookie UI
 * --------------------------------------------------------------- */
@media print {
    .cookie-banner,
    .cookie-modal {
        display: none !important;
    }
}
