/* ============================================================
   Cookie consent banner + preferences modal (Pipeit marketing + LMS)
   Self-contained; uses :root tokens from main stylesheets when present.
   ============================================================ */

.pc-cookie-banner {
    position: fixed;
    z-index: 160;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0));
    display: flex;
    justify-content: center;
    pointer-events: none;
    transform: translate3d(0, 110%, 0);
    opacity: 0;
    transition:
        transform 0.38s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.32s ease;
}

.pc-cookie-banner.is-visible {
    transform: translate3d(0, 0, 0);
    opacity: 1;
    pointer-events: auto;
}

.pc-cookie-banner-inner {
    width: 100%;
    max-width: 52rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    padding: 1rem 1.125rem;
    background: var(--card, hsl(0, 0%, 100%));
    border: 1px solid var(--border, hsl(220, 13%, 91%));
    box-shadow:
        0 -4px 24px hsl(222 47% 11% / 0.08),
        0 0 0 1px hsl(220 13% 91% / 0.5);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--foreground, hsl(222, 47%, 11%));
}

@media (min-width: 640px) {
    .pc-cookie-banner-inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1.25rem;
        padding: 1rem 1.25rem;
        border-radius: var(--radius, 0);
    }
}

.pc-cookie-banner-text {
    flex: 1;
    min-width: 0;
    margin: 0;
    color: var(--muted-foreground, hsl(220, 9%, 46%));
}

.pc-cookie-banner-text strong {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: var(--foreground, hsl(222, 47%, 11%));
    font-size: 0.9375rem;
}

.pc-cookie-banner-text a {
    color: var(--primary, hsl(24, 90%, 48%));
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pc-cookie-banner-text a:hover {
    opacity: 0.9;
}

.pc-cookie-banner-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Buttons — self-contained (marketing + LMS + legacy layouts without .btn) */
.pc-cookie-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2.25rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius, 0);
    border: 1px solid transparent;
    transition:
        background-color 0.2s,
        color 0.2s,
        border-color 0.2s,
        opacity 0.2s;
}

.pc-cookie-btn:focus-visible {
    outline: 2px solid var(--ring, hsl(24, 90%, 48%));
    outline-offset: 2px;
}

.pc-cookie-btn--primary {
    background: var(--gradient-cta, linear-gradient(135deg, hsl(24, 90%, 48%), hsl(28, 85%, 52%)));
    color: var(--primary-foreground, hsl(0, 0%, 100%));
    border-color: transparent;
}

.pc-cookie-btn--primary:hover {
    opacity: 0.92;
}

.pc-cookie-btn--outline {
    background: var(--background, hsl(220, 20%, 97%));
    color: var(--foreground, hsl(222, 47%, 11%));
    border-color: var(--input, hsl(220, 13%, 91%));
}

.pc-cookie-btn--outline:hover {
    background: var(--muted, hsl(220, 14%, 96%));
}

/* Preferences modal (works on marketing + LMS without relying on .open vs .hidden) */
.pc-cookie-pref-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 250;
    background: hsl(0 0% 0% / 0.5);
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: pc-cookie-backdrop-in 0.18s ease;
}

.pc-cookie-pref-backdrop.is-open {
    display: flex;
}

@keyframes pc-cookie-backdrop-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.pc-cookie-pref-dialog {
    background: var(--card, hsl(0, 0%, 100%));
    border: 1px solid var(--border, hsl(220, 13%, 91%));
    border-radius: var(--radius, 0);
    box-shadow: 0 20px 60px hsl(0 0% 0% / 0.2);
    width: 100%;
    max-width: 26rem;
    max-height: 90vh;
    overflow-y: auto;
    animation: pc-cookie-dialog-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pc-cookie-dialog-in {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.pc-cookie-pref-header {
    padding: 1.125rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border, hsl(220, 13%, 91%));
}

.pc-cookie-pref-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--foreground, hsl(222, 47%, 11%));
}

.pc-cookie-pref-desc {
    margin: 0.35rem 0 0;
    font-size: 0.8125rem;
    color: var(--muted-foreground, hsl(220, 9%, 46%));
}

.pc-cookie-pref-body {
    padding: 1rem 1.25rem;
}

.pc-cookie-pref-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border, hsl(220, 13%, 91%));
}

.pc-cookie-pref-row:last-of-type {
    border-bottom: none;
}

.pc-cookie-pref-row--disabled {
    opacity: 0.65;
}

.pc-cookie-pref-label {
    flex: 1;
    min-width: 0;
}

.pc-cookie-pref-label span {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--foreground, hsl(222, 47%, 11%));
}

.pc-cookie-pref-label small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--muted-foreground, hsl(220, 9%, 46%));
    line-height: 1.4;
}

/* Toggle switch */
.pc-cookie-toggle {
    position: relative;
    width: 2.75rem;
    height: 1.5rem;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--muted, hsl(220, 14%, 96%));
    border: 1px solid var(--border, hsl(220, 13%, 91%));
    cursor: pointer;
    transition: background 0.2s ease;
}

.pc-cookie-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(1.5rem - 6px);
    height: calc(1.5rem - 6px);
    border-radius: 50%;
    background: var(--background, hsl(220, 20%, 97%));
    box-shadow: 0 1px 2px hsl(0 0% 0% / 0.15);
    transition: transform 0.2s ease;
}

.pc-cookie-toggle[aria-checked='true'] {
    background: var(--primary, hsl(24, 90%, 48%));
    border-color: transparent;
}

.pc-cookie-toggle[aria-checked='true']::after {
    transform: translateX(1.2rem);
    background: var(--primary-foreground, hsl(0, 0%, 100%));
}

.pc-cookie-toggle:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.pc-cookie-pref-footer {
    padding: 0.75rem 1.25rem 1.125rem;
    border-top: 1px solid var(--border, hsl(220, 13%, 91%));
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
    .pc-cookie-banner,
    .pc-cookie-pref-backdrop,
    .pc-cookie-pref-dialog,
    .pc-cookie-toggle,
    .pc-cookie-toggle::after {
        transition: none;
        animation: none;
    }

    .pc-cookie-banner.is-visible {
        transform: none;
    }
}

/* Re-open link (footer, dashboard bar, etc.) */
a[data-pc-cookie-open] {
    color: var(--primary, hsl(24, 90%, 48%));
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}

a[data-pc-cookie-open]:hover {
    opacity: 0.9;
}
