/* ═══════════════════════════════════════════════════════════════════════
   maigica Configurator — Styles
   Loaded as secondary stylesheet in the unified landing page.
   Only configurator-specific styles; navbar/base handled by website CSS.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    --danger:        #f87171;
    --danger-dim:    rgba(248, 113, 113, 0.15);
    --success:       #34d399;
    --topbar-h:      52px;
    --conf-title-h:  120px;
    --selectbar-h:   48px;
}

/* ── Configurator title ───────────────────────────────────────────────── */
.conf-title-wrap.page-inner {
    padding-bottom: 0;
}

/* ── Layout ───────────────────────────────────────────────────────────── */
.layout {
    margin-top: var(--selectbar-h);
    height: calc(100vh - var(--topbar-h) - var(--selectbar-h) - 10rem);
    display: flex;
    flex-direction: column;
}

/* ── Selector bar (replaces sidebar) ────────────────────────────────── */
.selector-bar {
    position: sticky; top: 52px; left: 0; right: 0; z-index: 40;
    height: var(--selectbar-h);
    background: var(--bg-primary);
    display: flex; align-items: center; justify-content: center;
    padding: 0 2.5rem;
}
.selector-bar-inner {
    display: flex; align-items: center; gap: 0.75rem;
    width: 100%; max-width: 720px;
}
/* ── Configurator fade-in animations ──────────────────────────────────── */
@keyframes conf-fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
.selector-bar,
.config-form {
    opacity: 0;
    animation: conf-fade-up 0.45s ease forwards;
}
.selector-bar   { animation-delay: 0.06s; }
.config-form    { animation-delay: 0.14s; }
.config-select {
    width: 100%; max-width: 320px;
    padding: 0.45rem 2rem 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
    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='%238b949e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
}
.config-select:focus { border-color: var(--accent); }
.config-select option { background: var(--bg-card); color: var(--text-primary); }

/* ── Editor ───────────────────────────────────────────────────────────── */
.editor {
    flex: 1; min-height: 0; overflow-y: auto; padding: 0 2.5rem 2rem;
    box-sizing: border-box;
}
/* ── Wizard icon button (selector bar) ─────────────────────────────── */
/* visibility controlled after #page-configurator .btn block below */
.btn-wizard:hover { filter: brightness(1.15); }

/* ── Form ─────────────────────────────────────────────────────────────── */
.config-form { max-width: 720px; margin: 0 auto; }

/* ── Tab bar ──────────────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    position: sticky;
    top: 42px;
    z-index: 11;
    background: var(--bg-primary);
    padding-top: 0;
}
.tab-btn {
    padding: 0.55rem 1.15rem;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font);
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.tab-btn:hover {
    color: var(--text-secondary);
}
.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.tab-btn[hidden] { display: none; }

/* ── Tab panels ───────────────────────────────────────────────────────── */
.tab-panel {
    display: none;
}
.tab-panel.active {
    display: block;
    animation: tab-fade 0.2s ease;
}
.tab-panel[hidden] { display: none !important; }
@keyframes tab-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { border-bottom: none; }

.section-heading {
    font-size: 1rem; font-weight: 500; color: var(--accent);
    margin-bottom: 1rem; letter-spacing: 0.3px;
}
.sub-heading {
    font-size: 0.85rem; font-weight: 500; color: var(--text-secondary);
    margin: 1rem 0 0.75rem; letter-spacing: 0.3px;
}

.field-row {
    display: flex; align-items: center; gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.65rem;
}
.field-row.full { flex-direction: column; align-items: stretch; }
.field-row label {
    min-width: 180px; font-size: 0.85rem; color: var(--text-secondary);
    flex-shrink: 0;
}
.field-row.full label { min-width: unset; }
.field-row .hint { font-size: 0.75rem; color: var(--text-muted); }

.field-row input[type="text"],
.field-row input[type="number"],
.field-row input[type="password"],
.field-row select,
.field-row textarea {
    flex: 1;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}
.field-row input:focus,
.field-row select:focus,
.field-row textarea:focus { border-color: var(--accent); }
.field-row input::placeholder,
.field-row textarea::placeholder { color: var(--text-muted); }

.field-row select {
    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='%238b949e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 2rem;
}
.field-row select option { background: var(--bg-card); color: var(--text-primary); }

.field-row textarea { resize: vertical; min-height: 60px; }

.field-row input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px; height: 16px;
    margin-right: 0.35rem;
    cursor: pointer;
}

.input-with-btn { display: flex; flex: 1; gap: 0.4rem; }
.input-with-btn input { flex: 1; }

.checkbox-group { display: flex; gap: 1.5rem; }
.checkbox-group label { min-width: unset; display: flex; align-items: center; cursor: pointer; }

.tools-grid {
    display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem;
    padding: 0.5rem 0;
}
.tools-grid label {
    min-width: unset; display: flex; align-items: center; cursor: pointer;
    font-size: 0.85rem; color: var(--text-secondary);
}
.tools-grid label input { margin-right: 0.35rem; }

/* ── Field descriptions ───────────────────────────────────────────────── */
.field-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-basis: 100%;
    text-align: left;
    padding-left: 0;
    margin-top: -0.25rem;
    margin-bottom: 0.35rem;
}

/* (admin collapsible section removed — now using tabs) */

.small-talk-sub { padding-left: 1.5rem; }

/* ── Knowledge sources list ────────────────────────────────────────────── */
.knowledge-sources-list {
    display: flex; flex-direction: column; gap: 0.45rem;
}
.ks-row {
    display: flex; gap: 0.4rem; align-items: center;
}
.ks-row .input-url {
    flex: 1;
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font);
}
.ks-row .input-url:focus {
    outline: none; border-color: var(--accent);
}
.ks-row .input-label {
    width: 120px; min-width: 80px;
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font);
}
.ks-row .input-label:focus {
    outline: none; border-color: var(--accent);
}
.ks-row .btn { flex-shrink: 0; }
.ks-row .btn-fetch.loading {
    opacity: 0.6; pointer-events: none;
}

/* ── Premium badge (matches maigica brand) ───────────────────────────── */
.badge-premium {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    border: 1.5px solid #a78bfa;
    background: rgba(167, 139, 250, 0.10);
    color: #a78bfa;
    vertical-align: middle;
    margin-left: 0.35rem;
}
.badge-premium::before {
    content: "✦✦ ";
    font-size: 0.5rem;
    vertical-align: 0.05em;
}

/* ── Premium-locked dim state ─────────────────────────────────────────── */
.premium-locked .knowledge-sources-list,
.premium-locked #btn-add-source,
.premium-locked .endpoints-list,
.premium-locked .endpoints-actions,
.premium-locked .webhooks-list,
.premium-locked .webhooks-actions {
    opacity: 0.45;
    pointer-events: none;
}
/* Dim checkboxes/labels in locked interface section */
.premium-locked .field-row label,
.premium-locked .field-row .field-desc {
    opacity: 0.45;
}
.premium-hint {
    color: var(--text-secondary, #888);
    display: block;
    margin-top: 0.25rem;
}

/* ── Legacy fetch-generate-row (kept for backward compat) ─────────────── */
.fetch-generate-row {
    display: flex; gap: 0.5rem; align-items: center;
}
.fetch-generate-row .input-url {
    flex: 1;
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font);
}
.fetch-generate-row .input-url:focus {
    outline: none; border-color: var(--accent);
}
.fetch-generate-row .btn { flex-shrink: 0; }
#btn-fetch-generate.loading {
    opacity: 0.6; pointer-events: none;
}
#btn-fetch-reviews.loading {
    opacity: 0.6; pointer-events: none;
}

/* ── Buttons (scoped to configurator) ─────────────────────────────────── */
#page-configurator .btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 1rem; border-radius: 8px;
    font-weight: 500; font-size: 0.85rem; cursor: pointer;
    transition: opacity 0.2s, background 0.2s, border-color 0.2s;
    border: 1px solid transparent; font-family: var(--font);
    white-space: nowrap;
}
#page-configurator .btn-sm { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
#page-configurator .btn.btn-wizard,
#page-configurator #btn-wizard { display: none !important; }
#page-configurator .btn-accent { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
#page-configurator .btn-accent:hover { background: var(--accent); color: var(--bg-primary); }
#page-configurator .btn-primary { background: var(--accent); color: var(--bg-primary); border-color: var(--accent); }
#page-configurator .btn-primary:hover { opacity: 0.85; }
#page-configurator .btn-secondary { background: transparent; border-color: var(--border); color: var(--text-secondary); }
#page-configurator .btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.form-actions {
    display: flex; gap: 0.75rem; padding: 0.5rem 0 0.5rem; flex-wrap: wrap;
    justify-content: flex-end;
    position: sticky; top: 0; z-index: 12;
    background: var(--bg-primary);
}

/* ── Endpoint editor ───────────────────────────────────────────────────── */
.endpoints-section {
    margin-top: 0.5rem;
    padding: 0 0.25rem;
}
.endpoints-header {
    display: flex; align-items: baseline; gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.endpoints-header label {
    font-size: 0.85rem; font-weight: 600; color: var(--text-primary);
    min-width: 80px;
}
.endpoints-actions {
    display: flex; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap;
}
.endpoints-list {
    display: flex; flex-direction: column; gap: 0.5rem;
    margin-bottom: 1.25rem;
}

/* Card (collapsible <details>) */
.ep-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.ep-card[open] {
    border-color: var(--accent);
}
.ep-summary {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    list-style: none;
    user-select: none;
}
.ep-summary::-webkit-details-marker { display: none; }
.ep-summary::before {
    content: "▸"; font-size: 0.75rem; color: var(--text-muted);
    transition: transform 0.15s ease;
}
.ep-card[open] > .ep-summary::before { transform: rotate(90deg); }
.ep-method {
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    letter-spacing: 0.04em;
}
.ep-name {
    flex: 1; color: var(--text-primary); font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ep-remove {
    margin-left: auto;
    font-size: 1rem; line-height: 1;
    padding: 0.15rem 0.4rem;
}

/* Card body */
.ep-body {
    padding: 0.5rem 0.75rem 0.75rem;
    display: flex; flex-wrap: wrap; gap: 0.5rem 1rem;
    border-top: 1px solid var(--border);
}
.ep-row {
    display: flex; flex-direction: column; gap: 0.2rem;
    min-width: 180px; flex: 1 1 calc(50% - 0.5rem);
}
.ep-row.ep-full { flex: 1 1 100%; }

.ep-row label {
    font-size: 0.78rem; color: var(--text-secondary); font-weight: 500;
}
.ep-row .hint {
    font-weight: 400; font-size: 0.72rem; color: var(--text-muted);
}
.ep-row input[type="text"],
.ep-row input[type="number"],
.ep-row select,
.ep-row textarea {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.82rem;
    padding: 0.35rem 0.5rem;
    font-family: var(--font);
    width: 100%;
}
.ep-row textarea {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    resize: vertical;
}
.ep-row input:focus,
.ep-row select:focus,
.ep-row textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

/* ── Toasts ───────────────────────────────────────────────────────────── */
.toasts {
    position: fixed; bottom: 1.5rem; right: 6rem;
    display: flex; flex-direction: column-reverse; gap: 0.5rem;
    z-index: 9999;
    pointer-events: none;
}
.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: #fff;
    background: var(--bg-card);
    border: 1px solid var(--border);
    animation: toast-in 0.35s ease;
    max-width: 400px;
    pointer-events: auto;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.toast.success { background: #065f46; border-color: var(--success); color: #d1fae5; }
.toast.success a { color: #6ee7b7; text-decoration: underline; font-weight: 500; }
.toast.success a:hover { color: #fff; }
.toast.error   { background: #7f1d1d; border-color: var(--danger); color: #fecaca; }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Voice gender toggle group ─────────────────────────────────────────── */
.toggle-group {
    display: flex; gap: 0; border-radius: var(--radius-md); overflow: hidden;
    border: 1px solid var(--border);
}
.toggle-btn {
    flex: 1;
    padding: 0.45rem 1rem;
    font-size: 0.85rem; font-weight: 500;
    text-align: center;
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.toggle-btn + .toggle-btn { border-left: 1px solid var(--border); }
.toggle-btn:hover { background: var(--bg-card); color: var(--text-primary); }
.toggle-btn.active {
    background: var(--accent);
    color: #fff;
}
.toggle-btn.active:hover {
    background: var(--accent-hover, var(--accent));
}

/* voice picker option styling */
#f-elVoicePicker { font-size: 0.85rem; flex: 1; min-width: 0; }

/* voice picker + play button wrapper */
.voice-picker-wrap {
    display: flex; align-items: center; gap: 0.5rem;
    flex: 1; min-width: 0;
}
.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex-shrink: 0;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--bg-input); color: var(--text-secondary);
    cursor: pointer; transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn-icon:hover {
    background: var(--bg-card); color: var(--accent); border-color: var(--accent);
}
.btn-icon.playing {
    background: var(--accent); color: #fff; border-color: var(--accent);
    animation: pulse-play 1s ease-in-out infinite;
}
@keyframes pulse-play {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* conditional voice settings group (kept for potential future use) */
.conditional-group {
    margin: 0.25rem 0 0.75rem;
}

/* ── Field validation error highlight ──────────────────────────────────── */
.field-error {
    outline: 2px solid #e74c3c !important;
    border-color: #e74c3c !important;
    animation: field-shake 0.4s ease;
}
@keyframes field-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

/* ── AI Wizard ────────────────────────────────────────────────────────── */
.ai-wizard {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem 2rem;
    max-width: 720px;
    width: 100%;
    margin: 1rem auto 0;
    text-align: left;
    animation: conf-fade-up 0.4s ease both;
    animation-delay: 0.15s;
    box-sizing: border-box;
}
.ai-wizard-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.ai-wizard-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}
.ai-wizard-icon {
    flex-shrink: 0;
}
.ai-wizard-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 0 1rem;
}
.ai-wizard-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.ai-wizard-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.ai-wizard-field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.ai-wizard-field label .hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.75rem;
}
.ai-wizard-field textarea,
.ai-wizard-field input,
.ai-wizard-field select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color 0.2s;
}
.ai-wizard-field textarea:focus,
.ai-wizard-field input:focus,
.ai-wizard-field select:focus {
    border-color: var(--accent);
    outline: none;
}
.ai-wizard-field textarea {
    resize: vertical;
    min-height: 80px;
}
.ai-wizard-row {
    display: flex;
    gap: 0.75rem;
}
.ai-wizard-field--url { flex: 1; }
.ai-wizard-field--lang { flex: 0 0 130px; }
.ai-wizard-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 0.25rem;
    transition: opacity 0.2s, transform 0.15s;
}
.ai-wizard-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}
.ai-wizard-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.ai-wizard-btn-icon {
    flex-shrink: 0;
}
.ai-wizard-progress {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--accent);
    padding: 0.25rem 0;
}
.ai-wizard-progress[hidden] { display: none; }
.ai-wizard-error[hidden]    { display: none; }
.ai-wizard-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: wizard-spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes wizard-spin {
    to { transform: rotate(360deg); }
}
.ai-wizard-error {
    font-size: 0.85rem;
    color: #e74c3c;
    margin: 0;
    padding: 0.25rem 0;
}

/* ── Enterprise badge ─────────────────────────────────────────────────── */
.badge-enterprise {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    border: 1.5px solid #f59e0b;
    background: rgba(245, 158, 11, 0.10);
    color: #f59e0b;
    vertical-align: middle;
    margin-left: 0.35rem;
}
.badge-enterprise::before {
    content: "⚙ ";
    font-size: 0.55rem;
}

/* ── Business badge ─────────────────────────────────────────────────── */
.badge-business {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    border: 1.5px solid #3b82f6;
    background: rgba(59, 130, 246, 0.10);
    color: #3b82f6;
    vertical-align: middle;
    margin-left: 0.35rem;
}
.badge-business::before {
    content: "✦ ";
    font-size: 0.5rem;
    vertical-align: 0.05em;
}

/* ── Built-in tools list ─────────────────────────────────────────────── */
.builtin-tool-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background: var(--surface-2, #f5f5f5);
    margin-bottom: 0.4rem;
}
.builtin-tool-row input[type="checkbox"] {
    flex-shrink: 0;
}
.builtin-tool-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 7rem;
}
.builtin-tool-desc {
    font-size: 0.75rem;
    color: var(--text-secondary, #888);
    flex: 1;
    min-width: 0;
}

/* ── Char counter ────────────────────────────────────────────────────── */
.char-counter {
    font-size: 0.7rem;
    color: var(--text-secondary, #888);
    margin-left: 0.5rem;
    font-weight: 400;
}
.char-counter.over-limit {
    color: #ef4444;
    font-weight: 600;
}

/* ── Enterprise-locked dim state ─────────────────────────────────────── */
.enterprise-locked .endpoints-list,
.enterprise-locked .endpoints-actions {
    opacity: 0.45;
    pointer-events: none;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .editor { padding: 1.5rem; }
    .field-row { flex-direction: column; align-items: stretch; }
    .field-row label { min-width: unset; }
    .config-select { max-width: 100%; }
    .ai-wizard { padding: 1.25rem; }
    .ai-wizard-row { flex-direction: column; }
    .ai-wizard-field--lang { flex: 1; }
}
@media (max-width: 480px) {
    .editor { padding: 1rem; }
    .ai-wizard { padding: 1rem; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Webhook cards (simplified endpoint config for premium+ users)
   ═══════════════════════════════════════════════════════════════════════ */
.webhooks-list {
    display: flex; flex-direction: column; gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.wh-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.wh-card[open] {
    border-color: var(--accent);
}
.wh-summary {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    list-style: none;
    user-select: none;
}
.wh-summary::-webkit-details-marker { display: none; }
.wh-summary::before {
    content: "▸"; font-size: 0.75rem; color: var(--text-muted);
    transition: transform 0.15s ease;
}
.wh-card[open] > .wh-summary::before { transform: rotate(90deg); }

.wh-method {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    letter-spacing: 0.04em;
}
.wh-name {
    flex: 1; color: var(--text-primary); font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wh-remove {
    margin-left: auto;
    font-size: 1rem; line-height: 1;
    padding: 0.15rem 0.4rem;
}

.wh-body {
    padding: 0.5rem 0.75rem 0.75rem;
    display: flex; flex-direction: column; gap: 0.5rem;
    border-top: 1px solid var(--border);
}
.wh-row {
    display: flex; flex-direction: column; gap: 0.2rem;
}
.wh-row label {
    font-size: 0.78rem; color: var(--text-secondary); font-weight: 500;
}
.wh-row .hint {
    font-weight: 400; font-size: 0.72rem; color: var(--text-muted);
}
.wh-row .field-desc {
    font-size: 0.72rem; color: var(--text-muted); margin-top: 0;
}
.wh-row input[type="text"],
.wh-row input[type="url"],
.wh-row select,
.wh-row textarea {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.82rem;
    padding: 0.35rem 0.5rem;
    font-family: var(--font);
    width: 100%;
}
.wh-row textarea {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    resize: vertical;
}
.wh-row input:focus,
.wh-row select:focus,
.wh-row textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

/* Advanced settings toggle */
.wh-advanced {
    margin-top: 0.25rem;
}
.wh-advanced-toggle {
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    list-style: none;
    padding: 0.25rem 0;
}
.wh-advanced-toggle::-webkit-details-marker { display: none; }
.wh-advanced-toggle::before {
    content: "▸ "; font-size: 0.7rem;
    transition: transform 0.15s ease;
}
.wh-advanced[open] > .wh-advanced-toggle::before {
    content: "▾ ";
}
.wh-advanced-body {
    display: flex; flex-direction: column; gap: 0.5rem;
    margin-top: 0.25rem;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.wh-full { flex: 1 1 100%; }

/* ═══════════════════════════════════════════════════════════════════════
   Plan switcher (dev/testing: switch plans on the fly)
   ═══════════════════════════════════════════════════════════════════════ */
.plan-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    margin: 0 auto 0.5rem;
    max-width: 480px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
}
.plan-switcher__label {
    color: var(--text-secondary);
    font-weight: 500;
}
.plan-switcher__current {
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 6px;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 2px solid currentColor;
}
.plan-switcher__btns {
    display: flex;
    gap: 4px;
    margin-left: auto;
}
.plan-switcher__btn {
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.62rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.plan-switcher__btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}
/* Reuse plan-badge color scheme */
.plan-badge--free            { background: #2d333b; color: #8b949e; }
.plan-badge--personal_plus   { background: #8b5cf620; color: #a78bfa; border-color: #a78bfa40; }
.plan-badge--business        { background: #3b82f620; color: #60a5fa; border-color: #60a5fa40; }
.plan-badge--enterprise      { background: #f59e0b20; color: #fbbf24; border-color: #fbbf2440; }

/* ═══════════════════════════════════════════════════════════════════════
   Role-based configurator: Personal Assistant vs Full Configurator
   body.role-personal  = Free / Personal Plus (simplified view)
   body.role-business   = Business / Enterprise  (full view)
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Free tier: hide advanced fields (token + voice gender + language visible) ── */
body.tier-free .maigica-widget .mw-fab { display: none !important; }

body.tier-free .field-row:has(#f-name),
body.tier-free .field-row:has(#f-sysMsg),
body.tier-free .field-row:has(#f-knowledgeBase) {
    display: none !important;
}
/* Free tier: hide ElevenLabs / premium voice features */
body.tier-free #elevenlabs-fields,
body.tier-free #voice-picker-row,
body.tier-free .field-row:has(#f-autoListen),
body.tier-free .field-row:has(#f-voiceInterrupt),
body.tier-free .field-row:has(#f-voiceProvider) {
    display: none !important;
}
/* Free tier: hide the empty first voice section (all children hidden) + redundant heading */
body.tier-free .tab-panel[data-tab="voice"] > .form-section:first-child {
    display: none !important;
}
body.tier-free #voice-mode-settings .section-heading {
    display: none !important;
}
/* Free tier: hide the voice tab separator line */
body.tier-free .tab-panel[data-tab="voice"] {
    border-top: none !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
}
/* Free tier: hide voice-mode-settings section border */
body.tier-free #voice-mode-settings {
    border-bottom: none !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}
/* Free tier: show upgrade nudge in place of hidden fields */
.free-upgrade-nudge {
    display: none;
    padding: 1rem 1.2rem;
    margin: 0.5rem 0 1rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}
.free-upgrade-nudge a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.free-upgrade-nudge a:hover { text-decoration: underline; }
body.tier-free .free-upgrade-nudge {
    display: block;
}

/* ── Included tools info for personal users ────────────────────────── */
.included-tools-info {
    display: none;
    padding: 1rem 1.2rem;
    margin: 0.75rem 0 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.6;
}
.included-tools-info h4 {
    margin: 0 0 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary, var(--text));
}
.included-tools-info ul {
    margin: 0;
    padding-left: 1.2rem;
}
.included-tools-info li {
    margin-bottom: 0.25rem;
}
.included-tools-info li strong {
    color: var(--text-primary, var(--text));
}
.included-tools-upgrade {
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.included-tools-upgrade a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.included-tools-upgrade a:hover { text-decoration: underline; }
/* Free: show free-tier tools box only */
body.tier-free #included-tools-free {
    display: block;
}
body.tier-free #included-tools-paid {
    display: none !important;
}
/* Personal+ (paid personal): show paid tools box only */
body.role-personal:not(.tier-free) #included-tools-paid {
    display: block;
}
body.role-personal:not(.tier-free) #included-tools-free {
    display: none !important;
}

/* ── Personal mode: hide selector bar (only 1 assistant, auto-loaded) ── */
body.role-personal .selector-bar {
    display: none;
}
body.role-personal .layout {
    margin-top: 0;
    height: calc(100vh - var(--topbar-h) - 6rem);
}

/* ── Personal mode: hide tabs that personal users don't need ───────── */
/* Personal Plus: show General, Behavior, Voice, Tools — hide Interface + Admin */
body.role-personal .tab-btn[data-tab="ui"],
body.role-personal .tab-btn[data-tab="admin"] {
    display: none !important;
}
body.role-personal .tab-panel[data-tab="ui"],
body.role-personal .tab-panel[data-tab="admin"] {
    display: none !important;
}
/* Free tier: hide Behavior + Tools tabs (not available) */
body.tier-free .tab-btn[data-tab="behavior"],
body.tier-free .tab-btn[data-tab="tools"] {
    display: none !important;
}
body.tier-free .tab-panel[data-tab="behavior"],
body.tier-free .tab-panel[data-tab="tools"] {
    display: none !important;
}

/* ── Personal mode: hide business-only sections in Tools tab ───────── */
body.role-personal .builtin-tools-section,
body.role-personal .webhooks-section,
body.role-personal .endpoints-section {
    display: none !important;
}
/* Journal export: hide for business (they already have API access) */
body.role-business .journal-export-section {
    display: none;
}

/* ── Journal export row styling ──────────────────────────────────── */
.journal-export-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.journal-export-row:last-child { border-bottom: none; }
.journal-export-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.85rem;
}

/* ── Personal mode: hide advanced fields within General tab ────────── */
body.role-personal #knowledge-sources-section,
body.role-personal .field-row:has(#f-contentRefreshDays),
body.role-personal .field-row:has(#f-modeVoice) {
    display: none !important;
}

/* ── Personal mode: simplified header label ────────────────────────── */
.personal-mode-label {
    display: none;
    text-align: center;
    padding: 0.5rem 0 0;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 0.3px;
}
body.role-personal .personal-mode-label {
    display: block;
}

/* ── Free tier: hide tab bar, show stacked panels ─────────────────── */
body.tier-free .tab-bar {
    display: none;
}
/* Free tier: show General + Voice stacked (no tabs) */
body.tier-free .tab-panel[data-tab="general"],
body.tier-free .tab-panel[data-tab="voice"] {
    display: block !important;
}
body.tier-free .tab-panel[data-tab="voice"] {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    margin-top: 0.5rem;
}
body.tier-free .tab-panel[data-tab="voice"] .form-section {
    border-bottom: none;
    padding-bottom: 0;
}

/* ── Personal mode: Knowledge base becomes simpler ─────────────────── */
body.role-personal .field-row:has(#f-knowledgeBase) .field-desc {
    content: "";
}

/* ── Upgrade hint for personal users ──────────────────────────────── */
.upgrade-hint {
    display: none;
    text-align: center;
    margin-top: 1.5rem;
    padding: 1rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.upgrade-hint a {
    color: var(--accent);
    text-decoration: none;
}
.upgrade-hint a:hover { text-decoration: underline; }
body.role-personal .upgrade-hint {
    display: block;
}

/* ── QR pairing overlay ───────────────────────────────────────────────── */
.pair-overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}
.pair-overlay[hidden] { display: none; }
.pair-overlay__backdrop {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}
.pair-overlay__card {
    position: relative;
    background: var(--bg-secondary, #161b22);
    border: 1px solid var(--border, #30363d);
    border-radius: 12px;
    padding: 2rem;
    max-width: 360px; width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.pair-overlay__close {
    position: absolute; top: 0.5rem; right: 0.75rem;
    background: none; border: none; color: var(--text-secondary, #8b949e);
    font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.pair-overlay__close:hover { color: var(--text-primary, #e6edf3); }
.pair-overlay__title {
    margin: 0 0 0.5rem; font-size: 1.15rem; font-weight: 600;
    color: var(--text-primary, #e6edf3);
}
.pair-overlay__desc {
    margin: 0 0 1.25rem; font-size: 0.85rem;
    color: var(--text-secondary, #8b949e);
}
.pair-overlay__qr {
    display: flex; justify-content: center; margin: 0 0 1rem;
}
.pair-overlay__qr img {
    border-radius: 8px; background: #fff; padding: 12px;
}
.pair-overlay__hint {
    margin: 0 0 0.4rem; font-size: 0.75rem;
    color: var(--text-secondary, #8b949e);
}
.pair-overlay__url {
    display: block; font-size: 0.72rem;
    color: var(--accent, #a78bfa); word-break: break-all;
    user-select: all;
}
