/**
 * CBD FunHouse Core - Legal (Age Gate + Cookie Consent)
 * v2.0.1
 */

/* Force hide when [hidden] attribute is set (overrides display: flex) */
.cbdfh-age-gate[hidden],
.cbdfh-cookie-banner[hidden],
.cbdfh-cookie-modal[hidden] { display: none !important; }

/* Base variables (fallback if theme not loaded) */
:root {
    --cbdfh-primary: #2C4C3B;
    --cbdfh-accent: #b67e53;
    --cbdfh-bg: #fdf3f2;
    --cbdfh-text: #202020;
    --cbdfh-border: #E7EADB;
    --cbdfh-white: #ffffff;
    --cbdfh-shadow: 0 -4px 20px rgba(0,0,0,0.10);
}

/* Common buttons */
.cbdfh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 50px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.25s ease;
    line-height: 1;
    white-space: nowrap;
}
.cbdfh-btn-sm { padding: 10px 18px; font-size: 0.78rem; }
.cbdfh-btn-accent { background: var(--cbdfh-accent); color: #fff; border-color: var(--cbdfh-accent); }
.cbdfh-btn-accent:hover { background: #9a6a45; border-color: #9a6a45; transform: translateY(-1px); }
.cbdfh-btn-outline { background: transparent; color: var(--cbdfh-primary); border-color: var(--cbdfh-border); }
.cbdfh-btn-outline:hover { border-color: var(--cbdfh-primary); background: rgba(0,0,0,0.03); }

/* =========================================================
   AGE GATE
   ========================================================= */

/* BANNER (bottom, non-blocking, stacks above cookie banner) */
.cbdfh-age-gate.cbdfh-age-banner {
    position: fixed;
    left: 15px;
    right: 15px;
    bottom: 15px;
    z-index: 999998;
    background: var(--cbdfh-white);
    border: 1px solid var(--cbdfh-border);
    border-radius: 14px;
    box-shadow: var(--cbdfh-shadow);
    padding: 18px 22px;
    animation: cbdfhSlideUp 0.35s ease;
    max-width: 720px;
    margin: 0 auto;
}
.cbdfh-age-banner .cbdfh-age-inner {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}
.cbdfh-age-banner .cbdfh-age-icon {
    font-size: 2rem;
    flex-shrink: 0;
    line-height: 1;
}
.cbdfh-age-banner .cbdfh-age-content { flex: 1; min-width: 200px; }
.cbdfh-age-banner .cbdfh-age-content h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    color: var(--cbdfh-primary);
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
}
.cbdfh-age-banner .cbdfh-age-content p {
    margin: 0;
    font-size: 0.85rem;
    color: #555;
    line-height: 1.5;
}
.cbdfh-age-banner .cbdfh-age-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* MODAL (fullscreen, blocking) */
.cbdfh-age-gate.cbdfh-age-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(15,31,24,0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: cbdfhFadeIn 0.3s ease;
}
.cbdfh-age-modal .cbdfh-age-inner {
    background: var(--cbdfh-white);
    border-radius: 16px;
    max-width: 480px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: cbdfhZoomIn 0.35s ease;
}
.cbdfh-age-modal .cbdfh-age-icon {
    font-size: 3.5rem;
    margin-bottom: 10px;
}
.cbdfh-age-modal .cbdfh-age-content h3 {
    margin: 0 0 12px;
    font-size: 1.5rem;
    color: var(--cbdfh-primary);
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
}
.cbdfh-age-modal .cbdfh-age-content p {
    margin: 0 0 24px;
    color: #555;
    font-size: 0.95rem;
    line-height: 1.6;
}
.cbdfh-age-modal .cbdfh-age-actions {
    display: flex;
    gap: 10px;
    flex-direction: column;
}

/* Body class when modal is open */
body.cbdfh-age-locked { overflow: hidden !important; }
body.cbdfh-age-locked .cbdfh-cookie-banner { display: none !important; }

/* =========================================================
   COOKIE CONSENT BANNER
   ========================================================= */
.cbdfh-cookie-banner {
    position: fixed;
    left: 15px;
    right: 15px;
    bottom: 15px;
    z-index: 999997;
    background: var(--cbdfh-primary);
    color: #fff;
    border-radius: 14px;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
    padding: 20px 24px;
    max-width: 1100px;
    margin: 0 auto;
    animation: cbdfhSlideUp 0.35s ease 0.2s both;
}

.cbdfh-cookie-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.cbdfh-cookie-content {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 260px;
}
.cbdfh-cookie-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
    line-height: 1;
}
.cbdfh-cookie-text {
    font-size: 0.85rem;
    line-height: 1.55;
    color: rgba(255,255,255,0.92);
}
.cbdfh-cookie-link {
    color: #fff !important;
    text-decoration: underline;
    margin-left: 5px;
    font-weight: 600;
}
.cbdfh-cookie-link:hover { color: var(--cbdfh-accent) !important; }
.cbdfh-cookie-banner .cbdfh-btn-outline {
    color: #fff;
    border-color: rgba(255,255,255,0.4);
}
.cbdfh-cookie-banner .cbdfh-btn-outline:hover {
    background: rgba(255,255,255,0.08);
    border-color: #fff;
}
.cbdfh-cookie-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =========================================================
   COOKIE PREFERENCES MODAL
   ========================================================= */
.cbdfh-cookie-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: cbdfhFadeIn 0.25s ease;
}
.cbdfh-cookie-modal-inner {
    background: #fff;
    border-radius: 14px;
    max-width: 500px;
    width: 100%;
    padding: 30px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: cbdfhZoomIn 0.3s ease;
}
.cbdfh-cookie-modal-close {
    position: absolute;
    top: 12px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}
.cbdfh-cookie-modal-close:hover { color: var(--cbdfh-primary); }
.cbdfh-cookie-modal h3 {
    margin: 0 0 20px;
    color: var(--cbdfh-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
}
.cbdfh-cookie-category {
    padding: 15px 0;
    border-bottom: 1px solid var(--cbdfh-border);
}
.cbdfh-cookie-category:last-of-type { border-bottom: 0; }
.cbdfh-cookie-category label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
}
.cbdfh-cookie-category input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--cbdfh-primary);
}
.cbdfh-cookie-category input[disabled] { opacity: 0.6; cursor: not-allowed; }
.cbdfh-cookie-category strong {
    color: var(--cbdfh-primary);
    font-weight: 600;
}
.cbdfh-cookie-required {
    font-size: 0.75rem;
    color: #999;
    font-style: italic;
}
.cbdfh-cookie-category p {
    margin: 8px 0 0 30px;
    font-size: 0.8rem;
    color: #666;
    line-height: 1.5;
}
.cbdfh-cookie-modal-actions {
    margin-top: 20px;
    text-align: right;
}

/* Animations */
@keyframes cbdfhSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes cbdfhFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes cbdfhZoomIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
    .cbdfh-age-banner .cbdfh-age-inner { flex-direction: column; text-align: center; }
    .cbdfh-age-banner .cbdfh-age-actions { width: 100%; justify-content: center; }
    .cbdfh-age-banner .cbdfh-btn { flex: 1; min-width: 120px; }

    .cbdfh-cookie-banner {
        left: 10px;
        right: 10px;
        bottom: 10px;
        padding: 16px 18px;
    }
    .cbdfh-cookie-inner { flex-direction: column; align-items: stretch; }
    .cbdfh-cookie-content { flex-direction: column; text-align: center; }
    .cbdfh-cookie-actions { justify-content: center; }
    .cbdfh-cookie-actions .cbdfh-btn { flex: 1; min-width: 100px; }

    .cbdfh-age-modal .cbdfh-age-inner { padding: 30px 20px; }
    .cbdfh-age-modal .cbdfh-age-icon { font-size: 2.8rem; }
    .cbdfh-age-modal .cbdfh-age-content h3 { font-size: 1.25rem; }
}

/* Dark mode friendliness */
body.cbdfh-dark .cbdfh-age-banner {
    background: #1e1e1e;
    border-color: #333;
}
body.cbdfh-dark .cbdfh-age-banner .cbdfh-age-content h3 { color: #fff; }
body.cbdfh-dark .cbdfh-age-banner .cbdfh-age-content p { color: #ccc; }
body.cbdfh-dark .cbdfh-btn-outline { color: #eee; border-color: #444; }
body.cbdfh-dark .cbdfh-btn-outline:hover { background: rgba(255,255,255,0.06); border-color: #666; }
body.cbdfh-dark .cbdfh-cookie-modal-inner { background: #1e1e1e; color: #ddd; }
body.cbdfh-dark .cbdfh-cookie-modal h3 { color: #fff; }
body.cbdfh-dark .cbdfh-cookie-category { border-color: #333; }
body.cbdfh-dark .cbdfh-cookie-category strong { color: #fff; }
body.cbdfh-dark .cbdfh-cookie-category p { color: #aaa; }

/* Admin Settings CSS - loaded only on cbdfh settings page */
