/**
 * Total Compliance Engine — Consent Banner Styles
 *
 * Modern, accessible, responsive consent banner and preferences modal.
 */

/* ========================================
   CSS Custom Properties
   ======================================== */
:root {
    /* Dark theme (default) */
    --tce-bg: #1a1a2e;
    --tce-bg-secondary: #16213e;
    --tce-bg-modal: #0f0f23;
    --tce-surface: #1e2a45;
    --tce-border: rgba(255, 255, 255, 0.08);
    --tce-text: #e8e8f0;
    --tce-text-secondary: #a0a0b8;
    --tce-accent: #6c63ff;
    --tce-accent-hover: #7b73ff;
    --tce-accent-glow: rgba(108, 99, 255, 0.25);
    --tce-accept-bg: #6c63ff;
    --tce-accept-hover: #7b73ff;
    --tce-reject-bg: transparent;
    --tce-reject-border: rgba(255, 255, 255, 0.2);
    --tce-reject-hover: rgba(255, 255, 255, 0.08);
    --tce-prefs-bg: transparent;
    --tce-prefs-hover: rgba(255, 255, 255, 0.05);
    --tce-toggle-off: #3a3a5c;
    --tce-toggle-on: #6c63ff;
    --tce-toggle-knob: #ffffff;
    --tce-overlay: rgba(0, 0, 0, 0.6);
    --tce-radius: 16px;
    --tce-radius-sm: 10px;
    --tce-shadow: 0 -4px 32px rgba(0, 0, 0, 0.4);
    --tce-shadow-modal: 0 24px 80px rgba(0, 0, 0, 0.5);
    --tce-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    --tce-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --tce-banner-max-width: 1200px;
}

/* Light theme */
[data-tce-theme="light"] {
    --tce-bg: #ffffff;
    --tce-bg-secondary: #f8f9fc;
    --tce-bg-modal: #ffffff;
    --tce-surface: #f0f2f8;
    --tce-border: rgba(0, 0, 0, 0.08);
    --tce-text: #1a1a2e;
    --tce-text-secondary: #5a5a7a;
    --tce-reject-border: rgba(0, 0, 0, 0.15);
    --tce-reject-hover: rgba(0, 0, 0, 0.04);
    --tce-prefs-hover: rgba(0, 0, 0, 0.04);
    --tce-toggle-off: #d0d0e0;
    --tce-overlay: rgba(0, 0, 0, 0.4);
    --tce-shadow: 0 -4px 32px rgba(0, 0, 0, 0.1);
    --tce-shadow-modal: 0 24px 80px rgba(0, 0, 0, 0.15);
}

/* ========================================
   Banner — Bottom Bar
   ======================================== */
.tce-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999999;
    font-family: var(--tce-font);
    transform: translateY(100%);
    opacity: 0;
    transition: transform var(--tce-transition), opacity var(--tce-transition);
    pointer-events: none;
}

.tce-banner.tce-banner--visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.tce-banner__inner {
    background: var(--tce-bg);
    border-top: 1px solid var(--tce-border);
    box-shadow: var(--tce-shadow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 24px 42px;
    height: auto;
}

.tce-banner__container {
    max-width: var(--tce-banner-max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
}

.tce-banner__content {
    flex: 1 1 400px;
    min-width: 280px;
}

.tce-banner__heading {
    font-size: 16px;
    font-weight: 700;
    color: var(--tce-text);
    margin: 0 0 6px 0;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.tce-banner__text {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--tce-text-secondary);
    margin: 0;
}

.tce-banner__actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
}

/* ========================================
   Banner Layout Options
   ======================================== */

/* Option: Floating Box (Left) */
.tce-banner[data-tce-position="box-bottom-left"] {
    right: auto;
    width: 100%;
    max-width: 420px;
    padding: 20px;
    bottom: 20px;
}
.tce-banner[data-tce-position="box-bottom-left"] .tce-banner__inner {
    border-radius: var(--tce-radius);
    border: 1px solid var(--tce-border);
    padding: 34px;
    height: auto;
}

/* Option: Floating Box (Right) */
.tce-banner[data-tce-position="box-bottom-right"] {
    left: auto;
    width: 100%;
    max-width: 420px;
    padding: 20px;
    bottom: 20px;
}
.tce-banner[data-tce-position="box-bottom-right"] .tce-banner__inner {
    border-radius: var(--tce-radius);
    border: 1px solid var(--tce-border);
    padding: 34px;
    height: auto;
}

/* Option: Centered Modal Po-pup */
.tce-banner[data-tce-position="modal-center"] {
    top: 50%;
    left: 50%;
    bottom: auto;
    right: auto;
    width: 100%;
    max-width: 520px;
    transform: translate(-50%, -40%);
}
.tce-banner[data-tce-position="modal-center"].tce-banner--visible {
    transform: translate(-50%, -50%);
}
.tce-banner[data-tce-position="modal-center"] .tce-banner__inner {
    border-radius: var(--tce-radius);
    border: 1px solid var(--tce-border);
    box-shadow: var(--tce-shadow-modal);
    padding: 42px;
    height: auto;
}
.tce-banner[data-tce-position="modal-center"] .tce-banner__container {
    flex-direction: column;
    text-align: center;
    gap: 20px;
}
.tce-banner[data-tce-position="modal-center"] .tce-banner__actions {
    justify-content: center;
    width: 100%;
}
.tce-banner[data-tce-position="modal-center"]::before {
    /* Create a dark backdrop overlay behind the initial modal */
    content: '';
    position: fixed;
    top: -50vh;
    left: -50vw;
    width: 200vw;
    height: 200vh;
    background: var(--tce-overlay);
    z-index: -1;
    pointer-events: auto;
}

/* ========================================
   Buttons
   ======================================== */
.tce-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 24px;
    border-radius: 10px;
    font-family: var(--tce-font);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background var(--tce-transition), transform 0.15s ease, box-shadow var(--tce-transition), border-color var(--tce-transition);
    white-space: nowrap;
    line-height: 1;
    text-decoration: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.tce-btn:focus-visible {
    outline: 2px solid var(--tce-accent);
    outline-offset: 2px;
}

.tce-btn:active {
    transform: scale(0.97);
}

.tce-btn--accept {
    background: var(--tce-accept-bg);
    color: #ffffff;
    box-shadow: 0 2px 12px var(--tce-accent-glow);
}

.tce-btn--accept:hover {
    background: var(--tce-accept-hover);
    box-shadow: 0 4px 20px var(--tce-accent-glow);
}

.tce-btn--reject {
    background: var(--tce-reject-bg);
    color: var(--tce-text);
    border: 1.5px solid var(--tce-reject-border);
}

.tce-btn--reject:hover {
    background: var(--tce-reject-hover);
    border-color: var(--tce-text-secondary);
}

.tce-btn--prefs {
    background: var(--tce-prefs-bg);
    color: var(--tce-text-secondary);
    padding: 11px 16px;
    font-weight: 500;
}

.tce-btn--prefs:hover {
    background: var(--tce-prefs-hover);
    color: var(--tce-text);
}

/* ========================================
   Modal Overlay
   ======================================== */
.tce-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    background: var(--tce-overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--tce-transition), visibility var(--tce-transition);
}

.tce-overlay.tce-overlay--visible {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Preferences Modal
   ======================================== */
.tce-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 1000001;
    transform: translate(-50%, -50%) scale(0.92);
    opacity: 0;
    visibility: hidden;
    width: min(540px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    background: var(--tce-bg-modal);
    border-radius: var(--tce-radius);
    border: 1px solid var(--tce-border);
    box-shadow: var(--tce-shadow-modal);
    font-family: var(--tce-font);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--tce-transition), opacity var(--tce-transition), visibility var(--tce-transition);
}

.tce-modal.tce-modal--visible {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

.tce-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 28px 18px;
    border-bottom: 1px solid var(--tce-border);
}

.tce-modal__title {
    font-size: 18px;
    font-weight: 700;
    color: var(--tce-text);
    margin: 0;
    letter-spacing: -0.02em;
}

.tce-modal__close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--tce-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--tce-transition), color var(--tce-transition);
    padding: 0;
    flex-shrink: 0;
}

.tce-modal__close:hover {
    background: var(--tce-surface);
    color: var(--tce-text);
}

.tce-modal__close svg {
    width: 18px;
    height: 18px;
}

.tce-modal__body {
    padding: 20px 28px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar styles */
.tce-modal__body::-webkit-scrollbar {
    width: 4px;
}

.tce-modal__body::-webkit-scrollbar-track {
    background: transparent;
}

.tce-modal__body::-webkit-scrollbar-thumb {
    background: var(--tce-border);
    border-radius: 4px;
}

.tce-modal__footer {
    padding: 16px 28px 22px;
    border-top: 1px solid var(--tce-border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ========================================
   Category Cards
   ======================================== */
.tce-category {
    background: var(--tce-surface);
    border-radius: var(--tce-radius-sm);
    padding: 18px 20px;
    margin-bottom: 12px;
    border: 1px solid var(--tce-border);
    transition: border-color var(--tce-transition);
}

.tce-category:last-child {
    margin-bottom: 0;
}

.tce-category:hover {
    border-color: rgba(108, 99, 255, 0.15);
}

.tce-category__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.tce-category__label {
    font-size: 14px;
    font-weight: 600;
    color: var(--tce-text);
    margin: 0;
}

.tce-category__desc {
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--tce-text-secondary);
    margin: 0;
}

.tce-category__badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--tce-accent);
    background: var(--tce-accent-glow);
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ========================================
   Toggle Switch
   ======================================== */
.tce-toggle {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

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

.tce-toggle__slider {
    position: absolute;
    inset: 0;
    background: var(--tce-toggle-off);
    border-radius: 24px;
    cursor: pointer;
    transition: background var(--tce-transition);
}

.tce-toggle__slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--tce-toggle-knob);
    border-radius: 50%;
    transition: transform var(--tce-transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.tce-toggle input:checked + .tce-toggle__slider {
    background: var(--tce-toggle-on);
}

.tce-toggle input:checked + .tce-toggle__slider::after {
    transform: translateX(18px);
}

.tce-toggle input:focus-visible + .tce-toggle__slider {
    outline: 2px solid var(--tce-accent);
    outline-offset: 2px;
}

.tce-toggle input:disabled + .tce-toggle__slider {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========================================
   Iframe Placeholder
   ======================================== */
.tce-iframe-placeholder {
    position: relative;
    background: var(--tce-surface);
    border-radius: var(--tce-radius-sm);
    border: 1px dashed var(--tce-border);
    overflow: hidden;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tce-iframe-placeholder iframe {
    display: none;
}

.tce-iframe-placeholder.tce-iframe--loaded {
    border: none;
    background: transparent;
}

.tce-iframe-placeholder.tce-iframe--loaded iframe {
    display: block;
}

.tce-iframe-placeholder.tce-iframe--loaded .tce-iframe-placeholder__message {
    display: none;
}

.tce-iframe-placeholder__message {
    text-align: center;
    padding: 32px 24px;
    color: var(--tce-text-secondary);
}

.tce-iframe-placeholder__message svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.tce-iframe-placeholder__message p {
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 16px 0;
    font-family: var(--tce-font);
}

.tce-iframe-accept-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--tce-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--tce-transition);
    font-family: var(--tce-font);
}

.tce-iframe-accept-btn:hover {
    background: var(--tce-accent-hover);
}

/* ========================================
   Manage Cookies Button (persistent)
   ======================================== */
.tce-manage-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 999998;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--tce-bg);
    border: 1px solid var(--tce-border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tce-accent);
    transition: transform 0.2s ease, box-shadow var(--tce-transition);
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.tce-manage-btn.tce-manage-btn--visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.tce-manage-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.tce-manage-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 640px) {
    .tce-banner__inner {
        padding: 20px 16px;
    }

    .tce-banner__container {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .tce-banner__actions {
        flex-direction: column;
        width: 100%;
    }

    .tce-btn {
        width: 100%;
        padding: 13px 24px;
    }

    .tce-modal {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 24px);
        border-radius: 14px;
    }

    .tce-modal__header {
        padding: 18px 20px 14px;
    }

    .tce-modal__body {
        padding: 16px 20px;
    }

    .tce-modal__footer {
        padding: 14px 20px 18px;
        flex-direction: column;
    }

    .tce-modal__footer .tce-btn {
        width: 100%;
    }

    .tce-category {
        padding: 14px 16px;
    }
}

/* ========================================
   Animations
   ======================================== */
@keyframes tce-slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes tce-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes tce-scaleIn {
    from {
        transform: translate(-50%, -50%) scale(0.92);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .tce-banner,
    .tce-modal,
    .tce-overlay,
    .tce-manage-btn,
    .tce-btn,
    .tce-toggle__slider,
    .tce-toggle__slider::after {
        transition: none !important;
        animation: none !important;
    }
}

/* Print — hide banner */
@media print {
    .tce-banner,
    .tce-modal,
    .tce-overlay,
    .tce-manage-btn,
    .tce-iframe-placeholder__message {
        display: none !important;
    }
}
