/* ═══════════════════════════════════════════════════════════════════════════
   Admin Controls — shared drawer component for mini app prompt editing
   All colours via design tokens; dark mode via [data-theme="dark"] on <html>
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Trigger button ─────────────────────────────────────────────────────── */
.ac-admin-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 6px 14px 6px 10px;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: opacity 0.15s, transform 0.12s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    white-space: nowrap;
    flex-shrink: 0;
}
.ac-admin-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.ac-admin-btn:active {
    transform: translateY(0);
    opacity: 1;
}

.ac-admin-btn__icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.92;
}

/* ── Overlay ─────────────────────────────────────────────────────────────── */
.ac-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1200;
    animation: acFadeIn 0.2s ease;
    backdrop-filter: blur(2px);
}

/* ── Drawer ──────────────────────────────────────────────────────────────── */
.ac-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 520px;
    max-width: 96vw;
    background: var(--bg-primary);
    border-left: 1px solid var(--border);
    z-index: 1201;
    display: flex;
    flex-direction: column;
    animation: acSlideIn 0.26s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.28);
}

@keyframes acFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes acSlideIn {
    from { transform: translateX(100%); }
    to   { transform: translateX(0);    }
}

/* ── Drawer header ───────────────────────────────────────────────────────── */
.ac-drawer__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 22px 22px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-primary);
}

.ac-drawer__tag {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ac-drawer__tag::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

.ac-drawer__title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.ac-drawer__close {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 999px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: var(--font-ui);
    margin-top: 2px;
}
.ac-drawer__close:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

/* ── Scrollable body ─────────────────────────────────────────────────────── */
.ac-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* ── Sections ────────────────────────────────────────────────────────────── */
.ac-section {
    display: flex;
    flex-direction: column;
}

.ac-section--row {
    flex-direction: row;
    gap: 14px;
    align-items: flex-start;
}

.ac-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

/* ── Labels ──────────────────────────────────────────────────────────────── */
.ac-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
    display: block;
    margin-bottom: 6px;
}

.ac-char-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.ac-char-count--warn {
    color: #e05252;
}

.ac-hint {
    font-size: 0.77rem;
    color: var(--text-muted);
    margin: 0 0 10px;
    line-height: 1.55;
}
.ac-hint code {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.73rem;
    color: var(--accent);
    font-family: 'Courier New', monospace;
}

.ac-field-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin: 5px 0 0;
    line-height: 1.4;
}

/* ── Prompt textarea ─────────────────────────────────────────────────────── */
.ac-prompt-textarea {
    width: 100%;
    min-height: 280px;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.76rem;
    line-height: 1.65;
    padding: 14px;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.ac-prompt-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* ── Modified badge ──────────────────────────────────────────────────────── */
.ac-modified-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #b45309;
    background: rgba(180, 83, 9, 0.08);
    border: 1px solid rgba(180, 83, 9, 0.22);
    border-radius: 999px;
    padding: 3px 10px;
    align-self: flex-start;
}
.ac-modified-badge::before {
    content: '✎';
    font-size: 0.72rem;
}
[data-theme="dark"] .ac-modified-badge {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.08);
    border-color: rgba(251, 191, 36, 0.22);
}

/* ── Fields ──────────────────────────────────────────────────────────────── */
.ac-field {
    flex: 1;
    min-width: 0;
}
.ac-field--sm {
    flex: 0 0 130px;
}

.ac-select,
.ac-input {
    width: 100%;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    padding: 9px 12px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: auto;
}
.ac-select:focus,
.ac-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.ac-select option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* ── Sticky footer ───────────────────────────────────────────────────────── */
.ac-drawer__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-primary);
    gap: 12px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.ac-btn {
    font-family: var(--font-ui);
    font-size: 0.83rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 8px 20px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.ac-btn--ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}
.ac-btn--ghost:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.ac-btn--save {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.ac-btn--save:hover:not(:disabled) {
    opacity: 0.88;
}
.ac-btn--save:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.ac-btn--saved {
    background: #059669 !important;
    border-color: #059669 !important;
}
.ac-btn--error {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
}

/* ── Loading state ───────────────────────────────────────────────────────── */
.ac-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--text-muted);
    font-size: 0.86rem;
    padding: 48px;
}
.ac-loading__spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: acSpin 0.75s linear infinite;
}
@keyframes acSpin {
    to { transform: rotate(360deg); }
}
