/*
 * Cookie consent — storefront styles.
 * Colours, radius and fonts follow the active theme tokens with neutral fallbacks,
 * so the banner works in the default, Aurora and MoonCart themes.
 */

.kfp-root,
.kfp-preview-stage {
    --kfp-primary: var(--color-theme-primary, var(--theme-primary, #18181b));
    --kfp-on-primary: var(--color-theme-on-primary, var(--theme-on-primary, #ffffff));
    --kfp-surface: var(--color-theme-surface, var(--theme-surface, #ffffff));
    --kfp-text: var(--color-theme-text, var(--theme-text, #18181b));
    --kfp-muted: var(--color-theme-muted, var(--theme-text-muted, #52525b));
    --kfp-border: var(--color-theme-border, var(--theme-border, #d4d4d8));
    --kfp-track: var(--color-theme-border, var(--theme-border, #a1a1aa));
    --kfp-title-font: var(--font-title, inherit);
    --kfp-radius: var(--theme-radius, 0.75rem);
    --kfp-shadow: 0 12px 48px rgb(0 0 0 / 0.18);
    --kfp-speed: 200ms;
    color: var(--kfp-text);
    font: inherit;
    line-height: 1.5;
}

.kfp-root *,
.kfp-root *::before,
.kfp-root *::after,
.kfp-preview-stage *,
.kfp-preview-stage *::before,
.kfp-preview-stage *::after {
    box-sizing: border-box;
}

.kfp-root [hidden] {
    display: none !important;
}

/* ---------- Typography ---------- */

.kfp-title {
    margin: 0 0 0.5rem;
    font-family: var(--kfp-title-font);
    font-size: 1.125rem;
    font-weight: 650;
    line-height: 1.3;
    color: var(--kfp-text);
}

.kfp-body {
    margin: 0 0 0.5rem;
    font-size: 0.9375rem;
    color: var(--kfp-muted);
}

.kfp-policy-link,
.kfp-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.kfp-muted {
    color: var(--kfp-muted);
    font-size: 0.875rem;
}

.kfp-error {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #b91c1c;
}

/* ---------- Banner ---------- */

.kfp-banner {
    position: fixed;
    z-index: 2147483100;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: calc(100dvh - 2rem);
    overflow: auto;
    padding: 1.25rem 1.5rem;
    background: var(--kfp-surface);
    color: var(--kfp-text);
    border: 1px solid var(--kfp-border);
    border-radius: var(--kfp-radius);
    box-shadow: var(--kfp-shadow);
    animation: kfp-enter var(--kfp-speed) ease-out;
}

.kfp-box {
    width: min(30rem, calc(100% - 2rem));
}

.kfp-bar {
    left: 1rem;
    right: 1rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.kfp-bar .kfp-banner-text {
    max-width: 48rem;
}

.kfp-bottom-left {
    bottom: 1rem;
    left: 1rem;
}

.kfp-bottom-right {
    bottom: 1rem;
    right: 1rem;
}

.kfp-top-left {
    top: 1rem;
    left: 1rem;
}

.kfp-top-right {
    top: 1rem;
    right: 1rem;
}

.kfp-banner-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.kfp-bar .kfp-banner-actions {
    flex-shrink: 0;
    align-items: center;
}

/* ---------- Buttons ---------- */

.kfp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.kfp-actions .kfp-button {
    flex: 1 1 0;
    white-space: nowrap;
}

/* Accept and reject share one style so neither is visually preferred. */
.kfp-button {
    min-height: 44px;
    padding: 0.625rem 1.125rem;
    border: 1px solid var(--kfp-primary);
    border-radius: calc(var(--kfp-radius) * 0.66);
    background: var(--kfp-primary);
    color: var(--kfp-on-primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--kfp-speed) ease;
}

.kfp-button:hover {
    opacity: 0.9;
}

.kfp-button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.kfp-button-secondary {
    background: transparent;
    color: var(--kfp-text);
    border-color: var(--kfp-border);
}

.kfp-link {
    align-self: center;
    min-height: 44px;
    padding: 0.5rem;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 0.9375rem;
    cursor: pointer;
}

.kfp-button:focus-visible,
.kfp-link:focus-visible,
.kfp-close:focus-visible,
.kfp-reopen:focus-visible,
.kfp-policy-link:focus-visible,
.kfp-cookie-details summary:focus-visible,
.kfp-switch-input:focus-visible + .kfp-switch-track {
    outline: 3px solid var(--kfp-primary);
    outline-offset: 3px;
}

/* ---------- Preferences dialog ---------- */

.kfp-dialog {
    width: min(40rem, calc(100% - 2rem));
    max-height: calc(100dvh - 2rem);
    padding: 0;
    overflow: hidden;
    background: var(--kfp-surface);
    color: var(--kfp-text);
    border: 1px solid var(--kfp-border);
    border-radius: var(--kfp-radius);
    box-shadow: var(--kfp-shadow);
}

.kfp-dialog[open] {
    display: flex;
    flex-direction: column;
    animation: kfp-enter var(--kfp-speed) ease-out;
}

.kfp-dialog::backdrop {
    background: rgb(0 0 0 / 0.55);
}

.kfp-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--kfp-border);
}

.kfp-dialog-header .kfp-title {
    margin: 0;
}

.kfp-dialog-header .kfp-title:focus {
    outline: none;
}

.kfp-dialog-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.kfp-dialog-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid var(--kfp-border);
}

.kfp-dialog-footer .kfp-policy-link {
    align-self: center;
    font-size: 0.875rem;
}

.kfp-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-right: -0.625rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

/* ---------- Categories and toggle switches ---------- */

.kfp-category {
    padding: 1rem 0;
    border-bottom: 1px solid var(--kfp-border);
}

.kfp-category:last-child {
    border-bottom: 0;
}

.kfp-category-title {
    font-weight: 600;
    color: var(--kfp-text);
}

.kfp-category-description {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--kfp-muted);
}

.kfp-always-on {
    display: block;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--kfp-muted);
}

.kfp-switch {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 44px;
    cursor: pointer;
}

.kfp-switch-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.kfp-switch-track {
    position: relative;
    flex-shrink: 0;
    width: 2.75rem;
    height: 1.5rem;
    border-radius: 999px;
    background: var(--kfp-track);
    transition: background-color var(--kfp-speed) ease;
}

.kfp-switch-thumb {
    position: absolute;
    top: 0.1875rem;
    left: 0.1875rem;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
    transition: transform var(--kfp-speed) ease;
}

.kfp-switch-input:checked + .kfp-switch-track {
    background: var(--kfp-primary);
}

.kfp-switch-input:checked + .kfp-switch-track .kfp-switch-thumb {
    transform: translateX(1.25rem);
}

.kfp-switch-input:disabled + .kfp-switch-track {
    opacity: 0.55;
}

.kfp-switch:has(.kfp-switch-input:disabled) {
    cursor: default;
}

/* ---------- Cookie tables ---------- */

.kfp-cookie-details {
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.kfp-cookie-details summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.25rem 0;
}

.kfp-cookie-table-wrapper {
    margin-top: 0.5rem;
    overflow-x: auto;
}

.kfp-cookie-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.kfp-cookie-table th,
.kfp-cookie-table td {
    padding: 0.5rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--kfp-border);
}

.kfp-cookie-table th {
    font-weight: 600;
}

.kfp-cookie-table code {
    font-size: 0.8125rem;
    word-break: break-all;
}

.kfp-cookie-list-section {
    margin-bottom: 2rem;
}

/* ---------- Reopen button ---------- */

.kfp-reopen {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 2147483000;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 36px;
    padding: 0.375rem 0.75rem;
    background: var(--kfp-surface);
    color: var(--kfp-text);
    border: 1px solid var(--kfp-border);
    border-radius: 999px;
    box-shadow: 0 4px 16px rgb(0 0 0 / 0.12);
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

/* ---------- Admin preview ---------- */

.kfp-preview-stage {
    position: relative;
    display: flex;
    min-height: 22rem;
    padding: 1rem;
    border-radius: 0.75rem;
    background: repeating-linear-gradient(45deg, #f4f4f5, #f4f4f5 12px, #fafafa 12px, #fafafa 24px);
}

.kfp-preview-stage[data-position^="top"] {
    align-items: flex-start;
}

.kfp-preview-stage[data-position^="bottom"] {
    align-items: flex-end;
}

.kfp-preview-stage[data-position$="right"] {
    justify-content: flex-end;
}

.kfp-preview {
    position: static;
    animation: none;
}

.kfp-preview.kfp-bar {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
}

/* ---------- Motion and small screens ---------- */

@keyframes kfp-enter {
    from {
        opacity: 0;
        transform: translateY(0.75rem);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .kfp-root *,
    .kfp-root *::before,
    .kfp-root *::after,
    .kfp-root .kfp-banner,
    .kfp-root .kfp-dialog[open] {
        animation: none !important;
        transition: none !important;
    }
}

@media (max-width: 900px) {
    .kfp-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .kfp-bar .kfp-banner-actions {
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .kfp-banner,
    .kfp-box {
        left: 0.5rem;
        right: 0.5rem;
        width: auto;
        padding: 1rem;
    }

    .kfp-top-left,
    .kfp-top-right {
        top: 0.5rem;
    }

    .kfp-bottom-left,
    .kfp-bottom-right {
        bottom: 0.5rem;
    }

    .kfp-dialog {
        width: 100%;
        max-width: none;
        max-height: 100dvh;
        margin: auto 0 0;
        border-radius: var(--kfp-radius) var(--kfp-radius) 0 0;
    }

    .kfp-dialog-header,
    .kfp-dialog-body,
    .kfp-dialog-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .kfp-cookie-table thead {
        display: none;
    }

    .kfp-cookie-table tr {
        display: block;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--kfp-border);
    }

    .kfp-cookie-table td {
        display: grid;
        grid-template-columns: 7rem 1fr;
        gap: 0.5rem;
        padding: 0.25rem 0;
        border: 0;
    }

    .kfp-cookie-table td::before {
        content: attr(data-label);
        font-weight: 600;
    }
}
