/* CDX Cookies Banner — v2.0.0 */

/* ─── Reset & Base ─────────────────────────────────── */
#cdxc-banner *,
#cdxc-banner *::before,
#cdxc-banner *::after {
    box-sizing: border-box;
    margin: 0;
}

#cdxc-banner {
    position: fixed;
    z-index: 999999;
    direction: rtl;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: var(--cdxc-font-size, 14px);
    color: var(--cdxc-text, #e0e0e0);
    line-height: 1.6;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
}

#cdxc-banner.cdxc-visible {
    opacity: 1;
    visibility: visible;
}

/* ─── Overlay ──────────────────────────────────────── */
.cdxc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.cdxc-overlay.cdxc-visible {
    opacity: 1;
    visibility: visible;
}

/* ─── Position Variants ────────────────────────────── */
#cdxc-banner[data-position="bottom"] {
    bottom: 10px;
    left: 10px;
    right: 10px;
    transform: translateY(30px);
}
#cdxc-banner[data-position="bottom"].cdxc-visible {
    transform: translateY(0);
}

#cdxc-banner[data-position="bottom"] .cdxc-inner {
    border-radius: var(--cdxc-radius, 12px);
}

#cdxc-banner[data-position="top"] {
    top: 0;
    left: 0;
    right: 0;
    transform: translateY(-30px);
}
#cdxc-banner[data-position="top"].cdxc-visible {
    transform: translateY(0);
}

#cdxc-banner[data-position="top"] .cdxc-inner {
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.25);
}

#cdxc-banner[data-position="bottom-left"] {
    bottom: 20px;
    left: 20px;
    max-width: 420px;
    transform: translateY(20px);
}
#cdxc-banner[data-position="bottom-left"].cdxc-visible {
    transform: translateY(0);
}

#cdxc-banner[data-position="bottom-right"] {
    bottom: 20px;
    right: 20px;
    max-width: 420px;
    transform: translateY(20px);
}
#cdxc-banner[data-position="bottom-right"].cdxc-visible {
    transform: translateY(0);
}

/* ─── Inner Container ──────────────────────────────── */
.cdxc-inner {
    background: var(--cdxc-bg, #1a1a2e);
    padding: 20px 28px;
    border-radius: var(--cdxc-radius, 12px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

/* Top position has no border-radius since it touches the edge */
#cdxc-banner[data-position="top"] .cdxc-inner {
    border-radius: 0;
}

/* ─── Layout: Bar ──────────────────────────────────── */
.cdxc-main {
    min-height: 60px;
}

.cdxc-inner[data-layout="bar"] .cdxc-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    flex-wrap: wrap;
    padding: 12px!important;
}

.cdxc-inner[data-layout="bar"] .cdxc-content {
    flex: 1 1 450px;
    padding: 8px 0;
}

.cdxc-inner[data-layout="bar"] .cdxc-actions {
    flex-shrink: 0;
    padding: 8px 0;
}

/* ─── Layout: Box ──────────────────────────────────── */
.cdxc-inner[data-layout="box"] .cdxc-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ─── Title ────────────────────────────────────────── */
.cdxc-title {
    font-size: 1.1em;
    font-weight: 700;
    margin-bottom: 6px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Description ──────────────────────────────────── */
.cdxc-desc {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
    font-size: 0.9em;
}

.cdxc-desc a {
    color: var(--cdxc-accept-bg, #00d68f);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ─── Buttons ──────────────────────────────────────── */
.cdxc-actions {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    align-items: center;
    flex-shrink: 0;
}

.cdxc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.2;
    min-width: 100px;
}

.cdxc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.cdxc-btn:active {
    transform: translateY(0);
}

.cdxc-btn-accept {
    background: var(--cdxc-accept-bg, #00d68f);
    color: var(--cdxc-accept-text, #fff);
    box-shadow: 0 2px 8px rgba(0, 214, 143, 0.3);
}

.cdxc-btn-accept:hover {
    background: #00c27f;
    box-shadow: 0 4px 15px rgba(0, 214, 143, 0.4);
}

.cdxc-btn-decline {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.cdxc-btn-decline:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

.cdxc-btn-prefs {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    padding: 12px 16px;
    min-width: auto;
}

.cdxc-btn-prefs:hover {
    color: #fff;
    box-shadow: none;
    transform: none;
}

/* ─── Preferences Panel ───────────────────────────── */
.cdxc-prefs-panel {
    display: none;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.cdxc-prefs-panel.cdxc-open {
    display: block;
    animation: cdxcSlideDown 0.3s ease;
}

@keyframes cdxcSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Category Items ───────────────────────────────── */
.cdxc-category {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cdxc-category:last-of-type {
    border-bottom: none;
}

.cdxc-cat-info {
    flex: 1;
}

.cdxc-cat-name {
    font-weight: 600;
    margin-bottom: 4px;
    color: #fff;
}

.cdxc-cat-desc {
    font-size: 0.85em;
    opacity: 0.75;
    line-height: 1.5;
}

/* ─── Toggle Switch ────────────────────────────────── */
.cdxc-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.cdxc-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.cdxc-toggle-track {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.25s ease;
}

.cdxc-toggle-track::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    right: 3px;
    transition: transform 0.25s ease;
}

.cdxc-toggle input:checked + .cdxc-toggle-track {
    background: var(--cdxc-accept-bg, #00d68f);
}

.cdxc-toggle input:checked + .cdxc-toggle-track::after {
    transform: translateX(-20px);
}

.cdxc-toggle input:disabled + .cdxc-toggle-track {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─── Save prefs button row ────────────────────────── */
.cdxc-prefs-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 14px;
}

/* ─── Floating re-open button ──────────────────────── */
#cdxc-reopen {
    position: fixed;
    bottom: 90px;
    left: 20px;
    z-index: 999997;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--cdxc-reopen-bg, #1a1a2e);
    color: var(--cdxc-text, #e0e0e0);
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    font-size: 22px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#cdxc-reopen:hover {
    transform: scale(1.1);
}

#cdxc-reopen.cdxc-visible {
    display: flex;
}

#cdxc-reopen img,
#cdxc-reopen svg {
    min-width: 24px !important;
}

/* ─── WordPress Admin Bar Support ──────────────────── */
.admin-bar #cdxc-banner[data-position="top"] {
    top: 32px;
}

@media (max-width: 782px) {
    .admin-bar #cdxc-banner[data-position="top"] {
        top: 46px;
    }
}

/* ─── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
    .cdxc-inner {
        padding: 20px 20px;
        max-height: calc(100vh - 80px);
    }

    .cdxc-inner[data-layout="bar"] .cdxc-main {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .cdxc-title {
        font-size: 1.1em;
    }

    .cdxc-actions {
        flex-direction: row;
        justify-content: center;
    }

    .cdxc-btn {
        flex: 1;
        text-align: center;
        padding: 12px 16px;
    }

    .cdxc-btn-prefs {
        flex: 0 0 auto;
    }

    #cdxc-banner[data-position="bottom-left"],
    #cdxc-banner[data-position="bottom-right"] {
        left: 10px;
        right: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .cdxc-inner {
        padding: 16px;
    }

    .cdxc-actions {
        flex-direction: column;
    }

    .cdxc-btn {
        width: 100%;
    }
}
