/* ─── Chat Overlay Configurator — Styles ─────────────────────────────────── */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0e0e10;
    color: #efeff1;
    min-height: 100vh;
    padding: 40px 24px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
    color: #efeff1;
    display: flex;
    align-items: center;
    gap: 10px;
}
.page-title svg { color: #9146FF; }

/* ── Layout rows ───────────────────────────────────────────────────────────── */
.row-full  { width: 100%; margin-bottom: 10px; }
.row-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
    align-items: start;
}

/* ── Accordion ─────────────────────────────────────────────────────────────── */
.accordion {
    border: 1px solid #2f2f35;
    border-radius: 8px;
    overflow: hidden;
    background: #18181b;
    transition: opacity 0.2s;
}

.accordion.locked {
    opacity: 0.4;
    pointer-events: none;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    background: #1f1f23;
    gap: 10px;
}
.accordion-header:hover { background: #26262c; }

.accordion-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
}
.accordion-title svg { color: #9146FF; flex-shrink: 0; }

.accordion-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 99px;
    background: #2ecc7122;
    color: #2ecc71;
    border: 1px solid #2ecc7133;
}
.accordion-badge.locked-badge {
    background: #ffffff0a;
    color: #666;
    border-color: #ffffff11;
}

.accordion-chevron {
    transition: transform 0.2s;
    flex-shrink: 0;
    color: #888;
}
.accordion.open .accordion-chevron { transform: rotate(180deg); }

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
    padding: 0 20px;
    border-top: 0px solid #2f2f35;
}
.accordion.open .accordion-body {
    max-height: 2000px;
    padding: 20px;
    border-top: 1px solid #2f2f35;
}

/* ── Form elements ─────────────────────────────────────────────────────────── */
.field-label {
    display: block;
    font-size: 12px;
    color: #adadb8;
    margin-bottom: 6px;
    margin-top: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.field-label:first-child { margin-top: 0; }

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 9px 12px;
    background: #0e0e10;
    border: 1px solid #2f2f35;
    color: #efeff1;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s;
}
input[type="text"]:focus,
input[type="number"]:focus { border-color: #9146FF; }

/* ── Auth status ───────────────────────────────────────────────────────────── */
.auth-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #adadb8;
    margin-bottom: 16px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-grey  { background: #555; }
.dot-green { background: #2ecc71; box-shadow: 0 0 6px #2ecc7188; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary  { background: #9146FF; color: white; width: 100%; }
.btn-primary:hover { background: #7b2fbe; }
.btn-secondary { background: #2f2f35; color: #efeff1; }
.btn-secondary:hover { background: #3f3f46; }
.btn-generate { background: #2ecc71; color: #0e1a14; width: 100%; margin-top: 6px; }
.btn-generate:hover { background: #27ae60; }
.btn-copy {
    width: 100%;
    margin-top: 8px;
    background: transparent;
    color: #9146FF;
    border: 2px solid rgba(145,70,255,0.6);
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(145,70,255,0.25);
    transition: all 0.3s cubic-bezier(0.68,-0.55,0.265,1.55);
}
.btn-copy:hover {
    background: rgba(145,70,255,0.12);
    border-color: #9146FF;
    box-shadow: 0 0 18px rgba(145,70,255,0.4), 0 0 36px rgba(145,70,255,0.2);
    transform: scale(1.02);
}
.btn-copy.copied {
    background: rgba(46,204,113,0.12);
    color: #2ecc71;
    border-color: rgba(46,204,113,0.6);
    box-shadow: 0 0 18px rgba(46,204,113,0.35);
}
.btn-row { display: flex; gap: 8px; }

/* ── Custom Checkbox ───────────────────────────────────────────────────────── */
.checkbox-wrapper {
    --checkbox-size: 20px;
    --checkbox-color: #9146FF;
    --checkbox-shadow: rgba(145, 70, 255, 0.35);
    --checkbox-border: rgba(145, 70, 255, 0.6);
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    padding: 6px 4px;
    overflow: visible;
}
.checkbox-wrapper input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}
.checkbox-wrapper .checkmark {
    position: relative;
    flex-shrink: 0;
    width: var(--checkbox-size);
    height: var(--checkbox-size);
    border: 2px solid var(--checkbox-border);
    border-radius: 6px;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.2);
    box-shadow: 0 0 10px var(--checkbox-shadow);
    overflow: hidden;
}
.checkbox-wrapper .checkmark::before {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, var(--checkbox-color), #bf94ff);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform: scale(0) rotate(-45deg);
}
.checkbox-wrapper input:checked ~ .checkmark::before {
    opacity: 1;
    transform: scale(1) rotate(0);
}
.checkbox-wrapper .checkmark svg {
    width: 0;
    height: 0;
    color: #fff;
    z-index: 1;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.5));
}
.checkbox-wrapper input:checked ~ .checkmark svg {
    width: 13px;
    height: 13px;
    transform: rotate(360deg);
}
.checkbox-wrapper:hover .checkmark {
    border-color: var(--checkbox-color);
    transform: scale(1.1);
    box-shadow: 0 0 16px var(--checkbox-shadow), 0 0 30px var(--checkbox-shadow), inset 0 0 8px var(--checkbox-shadow);
}
.checkbox-wrapper input:checked ~ .checkmark {
    animation: cb-pulse 1s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
@keyframes cb-pulse {
    0%   { transform: scale(1);   box-shadow: 0 0 16px var(--checkbox-shadow); }
    50%  { transform: scale(0.9); box-shadow: 0 0 28px var(--checkbox-shadow), 0 0 44px var(--checkbox-shadow); }
    100% { transform: scale(1);   box-shadow: 0 0 16px var(--checkbox-shadow); }
}
.checkbox-wrapper .cb-label {
    margin-left: 10px;
    font-size: 14px;
    color: #cfcfd4;
    transition: all 0.3s;
}
.checkbox-wrapper:hover .cb-label {
    color: #efeff1;
    transform: translateX(3px);
}

.divider { border: none; border-top: 1px solid #2f2f35; margin: 12px 0; }

/* ── Event type blocks ─────────────────────────────────────────────────────── */
.event-type-block {
    background: #0e0e10;
    border: 1px solid #2f2f35;
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 10px;
}
.event-type-block:last-child { margin-bottom: 0; }
.event-type-block .checkbox-wrapper { padding: 0; }

.event-options {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease, margin-top 0.25s ease;
}
.event-options.visible {
    max-height: 300px;
    margin-top: 10px;
}
.event-options-inner {
    padding-top: 10px;
    border-top: 1px solid #2f2f35;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.event-option-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: #adadb8;
}
.option-label { min-width: 100px; font-weight: 600; }

input[type="color"] {
    width: 30px; height: 26px;
    border: 1px solid #2f2f35;
    background: #0e0e10;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
}
.opacity-slider { flex: 1; accent-color: #9146FF; cursor: pointer; max-width: 100px; }
.opacity-label  { font-size: 12px; color: #666; min-width: 34px; }
.opacity-tag    { font-size: 12px; color: #555; white-space: nowrap; }

.text-override-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: #adadb8;
}
.text-override-row .option-label { min-width: 100px; font-weight: 600; }
.text-override-row input[type="text"] {
    flex: 1;
    padding: 6px 8px;
    font-size: 13px;
    background: #18181b;
    border: 1px solid #2f2f35;
    border-radius: 4px;
    color: #efeff1;
    width: auto;
}
.text-override-row input[type="text"]:focus { border-color: #9146FF; }

.event-warning {
    font-size: 12px;
    color: #f0a020;
    margin-top: 6px;
    line-height: 1.5;
    display: flex;
    gap: 5px;
}

/* ── Output ────────────────────────────────────────────────────────────────── */
.output-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 8px;
    margin-top: 14px;
}
.output-box {
    background: #0e0e10;
    border: 1px solid #2f2f35;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
    color: #adadb8;
    word-break: break-all;
    line-height: 1.5;
    min-height: 38px;
    font-family: monospace;
}

.hint {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
    display: block;
    line-height: 1.5;
}

/* ── Export / Import buttons ───────────────────────────────────────────────── */
.btn-export {
    background: transparent;
    color: #adadb8;
    border: 2px solid #2f2f35;
    border-radius: 8px;
    transition: all 0.2s;
}
.btn-export:hover {
    border-color: #9146FF;
    color: #efeff1;
    box-shadow: 0 0 12px rgba(145,70,255,0.2);
}
.btn-import {
    background: transparent;
    color: #adadb8;
    border: 2px solid #2f2f35;
    border-radius: 8px;
    transition: all 0.2s;
}
.btn-import:hover {
    border-color: #2ecc71;
    color: #2ecc71;
    box-shadow: 0 0 12px rgba(46,204,113,0.2);
}

/* ── Select / Dropdown ─────────────────────────────────────────────────────── */
select {
    width: 100%;
    padding: 9px 12px;
    background: #0e0e10;
    border: 1px solid #2f2f35;
    color: #efeff1;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
select:focus { border-color: #9146FF; }
select option { background: #18181b; }

/* ─── Login card ─────────────────────────────────────────────────────────── */
.login-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 12px;
    gap: 12px;
}

.login-card-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
    flex: 1;
    min-width: 0;
}

.login-card-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ─── Tab bar ────────────────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 12px;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.tab-btn:hover:not(.locked) {
    background: var(--border);
    color: var(--text);
}

.tab-btn.active {
    background: var(--accent);
    color: #fff;
}

.tab-btn.locked {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ─── Tab panels ─────────────────────────────────────────────────────────── */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ─── Tab sections ───────────────────────────────────────────────────────── */
.tab-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tab-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

/* ─── Locked tab blur ────────────────────────────────────────────────────── */
.tab-panel {
    position: relative;
}

.tab-panel.tab-locked {
    pointer-events: none;
    user-select: none;
}

.tab-panel.tab-locked > * {
    filter: blur(4px);
    opacity: 0.5;
    transition: filter 0.3s, opacity 0.3s;
}

.tab-panel:not(.tab-locked) > * {
    filter: none;
    opacity: 1;
    transition: filter 0.3s, opacity 0.3s;
}

/* PubSub-only feature warning */
.pubsub-warning {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 6px 0 2px;
    padding: 6px 8px;
    background: rgba(255, 160, 0, 0.08);
    border: 1px solid rgba(255, 160, 0, 0.3);
    border-radius: 5px;
    font-size: 11px;
    color: rgba(255, 160, 0, 0.85);
    line-height: 1.4;
}

.pubsub-warning svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* ─── Setting Tooltip Indicators ─────────────────────────────────────────────── */
.setting-tip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
    font-size: 10px;
    color: rgba(255,255,255,0.3);
    cursor: default;
    vertical-align: middle;
    transition: color 0.15s;
    font-style: normal;
    user-select: none;
}

.setting-tip-icon:hover {
    color: rgba(169, 112, 255, 0.9);
}

.setting-tooltip {
    position: absolute;
    z-index: 99999;
    background: #1a1a2e;
    border: 1px solid rgba(169, 112, 255, 0.4);
    border-radius: 6px;
    overflow: hidden;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}

.tip-desc {
    padding: 8px 10px;
    font-size: 11px;
    line-height: 1.5;
    color: rgba(255,255,255,0.75);
    white-space: normal;
    font-family: sans-serif;
}

/* ─── Two-column config layout ───────────────────────────────────────────── */
.config-layout {
    display: grid;
    grid-template-columns: 1fr 600px;
    gap: 20px;
    align-items: start;
}

.config-col {
    min-width: 0;
}

/* ─── Live chat preview panel ────────────────────────────────────────────── */
.preview-col {
    position: sticky;
    top: 20px;
}

.chat-preview-panel {
    background: #0e0e10;
    border: 1px solid #2f2f35;
    border-radius: 10px;
    overflow: hidden;
    min-height: 600px;
    max-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    background: #1f1f23;
    border-bottom: 1px solid #2f2f35;
    font-size: 12px;
    font-weight: 600;
    color: #adadb8;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}
.preview-header svg { color: #9146FF; }

.preview-light-btn {
    margin-left: auto;
    padding: 3px 10px;
    border-radius: 99px;
    border: 1px solid #3f3f46;
    background: #2a2a30;
    color: #adadb8;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
}
.preview-light-btn:hover {
    background: #3f3f46;
    color: #efeff1;
}

.preview-chat {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    scrollbar-width: thin;
    scrollbar-color: #2f2f35 transparent;
}
.preview-chat::-webkit-scrollbar { width: 4px; }
.preview-chat::-webkit-scrollbar-thumb { background: #2f2f35; border-radius: 2px; }

.pv-msg { word-break: break-word; }

/* ─── Generate blink ─────────────────────────────────────────────────────── */
@keyframes needs-regen-pulse {
    0%,100% { background: var(--accent, #9146FF); color: #fff; }
    50%      { background: #ff7043; color: #fff; box-shadow: 0 0 10px rgba(255,112,67,0.6); }
}

.needs-regen {
    animation: needs-regen-pulse 0.6s ease-in-out 3;
}

/* Collapse preview column on narrow viewports */
@media (max-width: 1200px) {
    .config-layout {
        grid-template-columns: 1fr;
    }
    .preview-col {
        position: static;
    }
    .chat-preview-panel {
        max-height: 400px;
    }
}