/* ==========================================================================
   Toggle switches, the cookie dialog, and the shared modal overlay
   ========================================================================== */

/* --- Toggle Switch --- */
.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    flex-shrink: 0;
}

.toggle-switch .toggle-thumb {
    position: absolute;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.2s;
}

.toggle-switch.on {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.toggle-switch.on .toggle-thumb {
    background: var(--white);
    left: 22px;
}

.toggle-switch.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- The cookie dialog ---
   A native <dialog> opened with showModal(): the browser dims the page, makes
   it inert and keeps focus inside. The dialog has no padding of its own, so a
   press that lands on it rather than inside a view is a press on the dimmed
   page. docs/COOKIE-CONSENT.md §3 for why it may wait for an answer. */
.bt-consent {
    width: min(440px, calc(100% - 32px));
    max-width: none;
    max-height: calc(100% - 32px);
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 24px 64px rgba(0,0,0,0.35);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.bt-consent::backdrop {
    background: rgba(0,0,0,0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.bt-consent[open] { animation: btConsentIn 0.22s ease-out; }
.bt-consent[open]::backdrop { animation: btConsentFade 0.22s ease-out; }
/* The page behind stays where it is while the question is open. */
html:has(.bt-consent[open]) { overflow: hidden; }

.bt-consent-view { padding: 24px 24px 20px; }
.bt-consent-title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.bt-consent-text {
    margin: 0 0 18px;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--text-secondary);
}
.bt-consent-actions { display: flex; gap: 10px; }
.bt-consent-actions .btn {
    flex: 1 1 0;
    padding: 10px 12px;
    font-weight: 600;
    white-space: nowrap;
}
.bt-consent-foot {
    margin: 14px 0 0;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-muted);
}
.bt-consent-more { display: flex; gap: 16px; margin-top: 8px; }
.bt-consent-more a,
.bt-consent-link { color: var(--accent-color); }
/* Settings is a button, because it opens a view rather than going anywhere. */
.bt-consent-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.bt-consent-rows {
    margin: 0 0 18px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}
.bt-consent-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
}
.bt-consent-row + .bt-consent-row { border-top: 1px solid var(--border-color); }
.bt-consent-row b { display: block; font-size: 0.88rem; font-weight: 600; color: var(--text-primary); }
.bt-consent-row small { display: block; margin-top: 2px; font-size: 0.78rem; line-height: 1.4; color: var(--text-muted); }

@keyframes btConsentIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}
@keyframes btConsentUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: none; }
}
@keyframes btConsentFade { from { opacity: 0; } to { opacity: 1; } }

/* On a phone it comes up from the bottom edge, as every dialog there does. */
@media (max-width: 767.98px) {
    .bt-consent {
        width: 100%;
        max-height: 88vh;
        margin: auto 0 0;
        border-bottom: 0;
        border-radius: 20px 20px 0 0;
    }
    .bt-consent-view { padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); }
    .bt-consent[open] { animation: btConsentUp 0.24s ease-out; }
}
@media (prefers-reduced-motion: reduce) {
    .bt-consent[open],
    .bt-consent[open]::backdrop { animation: none; }
}

/* --- Modal Overlay (shared) --- */
body.modal-open { overflow: hidden; }
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.show {
    display: flex;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Shared Confirm Modal (bt-modal, used by modal.js) --- */
.bt-modal {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 16px; padding: 0; width: 90%; max-width: 420px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalIn 0.2s ease-out;
}
/* A dialog whose content is a grid of pictures to choose from. */
.bt-modal.bt-modal-wide { max-width: 1120px; width: 94vw; }
.bt-modal-video { max-width: 720px; }
.bt-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 20px 0;
}
.bt-modal-title {
    display: flex; align-items: center; gap: 10px;
    font-size: 1.05rem; font-weight: 600; color: var(--text-primary);
}
.bt-modal-close {
    background: none; border: none; font-size: 1.5rem; line-height: 1;
    color: var(--text-muted); cursor: pointer; padding: 0;
}
.bt-modal-close:hover { color: var(--text-primary); }
.bt-modal-body {
    padding: 12px 20px 0; font-size: 0.88rem; color: var(--text-secondary); line-height: 1.6;
}
.bt-modal-body strong { color: var(--text-primary); }
/* A field inside a dialog: its label above, the input the dialog's width. */
.bt-modal-field { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 0; }
.bt-modal-field span { font-size: .78rem; font-weight: 600; color: var(--text-secondary); }
.bt-modal-field input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-color);
    background: var(--bg-primary); color: var(--text-primary); font: inherit; font-size: .92rem; }
.bt-modal-field input:focus { outline: none; border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-alpha); }
.bt-modal-video-body { padding: 12px 0 0; }
.bt-modal-actions {
    display: flex; gap: 10px; padding: 18px 20px;
}
.bt-modal-actions .btn { flex: 1; padding: 8px 16px; }
.modal-icon-wrap {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-alpha); color: var(--accent-color);
}
.modal-icon-wrap.text-danger { background: var(--error-alpha); color: var(--error-color); }
.modal-icon-wrap.text-warning { background: var(--warning-alpha); color: var(--warning-color); }
