/* ═══════════════════════════════════════════════════════
   Discord Dashboard — Ember Dark Theme
   Inspired by EmberBot dashboard design
   ═══════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
    color-scheme: dark;
    --bg: #0c0a09;
    --surface: rgba(28, 25, 23, 0.92);
    --surface-solid: #1c1917;
    --surface-2: rgba(41, 37, 36, 0.6);
    --surface-2-solid: #292524;
    --surface-3: #1a1816;
    --glass: rgba(28, 25, 23, 0.7);
    --border: rgba(68, 64, 60, 0.5);
    --border-hover: rgba(249, 115, 22, 0.35);
    --text: #fafaf9;
    --text-secondary: #d6d3d1;
    --muted: #a8a29e;
    --primary: #f97316;
    --primary-dim: rgba(249, 115, 22, 0.12);
    --primary-glow: rgba(249, 115, 22, 0.2);
    --primary-vivid: #fb923c;
    --cyan: #22d3ee;
    --green: #34d399;
    --green-dim: rgba(52, 211, 153, 0.1);
    --rose: #fb7185;
    --rose-dim: rgba(251, 113, 133, 0.1);
    --amber: #fbbf24;
    --amber-dim: rgba(251, 191, 36, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-ember: 0 0 40px rgba(249, 115, 22, 0.12);
    --shadow-glow: 0 0 60px rgba(249, 115, 22, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-mode {
    color-scheme: light;
    --bg: #fafaf9;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-solid: #ffffff;
    --surface-2: rgba(245, 245, 244, 0.8);
    --surface-2-solid: #f5f5f4;
    --surface-3: #e7e5e4;
    --glass: rgba(255, 255, 255, 0.65);
    --border: rgba(214, 211, 209, 0.7);
    --border-hover: rgba(249, 115, 22, 0.3);
    --text: #1c1917;
    --text-secondary: #44403c;
    --muted: #78716c;
    --shadow: 0 8px 32px rgba(28, 25, 23, 0.08);
    --shadow-lg: 0 20px 60px rgba(28, 25, 23, 0.12);
    --shadow-ember: 0 0 40px rgba(249, 115, 22, 0.08);
}

/* ── Reset & Base ── */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Ambient ember glow */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(ellipse 60% 50% at 0% 0%, rgba(249, 115, 22, 0.07), transparent 50%),
        radial-gradient(ellipse 50% 40% at 100% 100%, rgba(249, 115, 22, 0.05), transparent 50%),
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(249, 115, 22, 0.03), transparent 60%);
    pointer-events: none;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle 300px at 10% 15%, rgba(249, 115, 22, 0.04), transparent),
        radial-gradient(circle 200px at 90% 85%, rgba(249, 115, 22, 0.03), transparent);
    animation: orbFloat 25s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes orbFloat {
    0% { transform: translate(0, 0); }
    50% { transform: translate(15px, -20px); }
    100% { transform: translate(-10px, 15px); }
}

button, input, select, textarea {
    font: inherit;
    letter-spacing: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(168, 162, 158, 0.2);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(168, 162, 158, 0.35);
}

/* ── Typography ── */
h1, h2, h3, p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text);
}

h2 {
    margin-bottom: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ── Login ── */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(440px, 100%);
    background: var(--surface);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg), var(--shadow-ember);
    display: grid;
    gap: 20px;
    animation: panelAppear 0.5s ease-out both;
}

@keyframes panelAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-panel-wide { width: min(980px, 100%); }
.login-panel-narrow { width: min(400px, 100%); }

.login-grid,
.login-register-grid {
    display: grid;
    gap: 16px;
}

.login-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.login-form-card {
    padding: 22px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    display: grid;
    gap: 16px;
    transition: border-color var(--transition);
}

.login-form-card:hover {
    border-color: var(--border-hover);
}

.login-form-card-accent {
    align-content: center;
    background:
        linear-gradient(135deg, var(--primary-dim), transparent 70%),
        var(--surface-2);
    border-color: rgba(249, 115, 22, 0.2);
}

.form-feedback {
    margin: 0;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-feedback-danger {
    color: #ffd8df;
    border-color: rgba(251, 113, 133, 0.3);
    background: rgba(127, 29, 29, 0.2);
}

/* ── Brand ── */
.brand-mark,
.sidebar-brand,
.panel-head,
.topbar,
.topbar-actions,
.login-status {
    display: flex;
    align-items: center;
}

.brand-mark,
.sidebar-brand {
    gap: 14px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(251, 191, 36, 0.12));
    border: 1px solid rgba(249, 115, 22, 0.25);
    color: var(--primary);
    transition: transform var(--transition), box-shadow var(--transition);
}

.brand-icon:hover,
.sidebar-brand:hover .brand-icon {
    transform: scale(1.06);
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.15);
}

.brand-icon svg,
.icon-btn svg,
.nav-item svg,
.metric-card svg,
.panel-head svg,
.btn svg {
    width: 18px;
    height: 18px;
}

.login-status {
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-left: 6px;
    background: var(--green);
    box-shadow: 0 0 10px var(--green);
    animation: dotPulse 2.5s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--green); }
    50% { opacity: 0.6; box-shadow: 0 0 18px var(--green); }
}

/* ── Buttons ── */
.btn {
    min-height: 44px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition:
        transform var(--transition),
        box-shadow var(--transition),
        background var(--transition),
        border-color var(--transition);
}

.btn:active {
    transform: scale(0.97);
}

.btn-neon {
    background: linear-gradient(135deg, #ea580c, var(--primary), var(--primary-vivid));
    background-size: 200% 200%;
    color: white;
    box-shadow: 0 4px 24px rgba(249, 115, 22, 0.3);
}

.btn-neon:hover {
    box-shadow: 0 6px 32px rgba(249, 115, 22, 0.4), 0 0 0 1px rgba(249, 115, 22, 0.3);
    transform: translateY(-1px);
}

.btn-ghost {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border);
}

.btn-ghost:hover {
    border-color: var(--border-hover);
    background: var(--surface-solid);
}

.btn[disabled],
.btn[aria-disabled="true"] {
    pointer-events: none;
    opacity: 0.45;
}

.btn.compact {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.85rem;
}

/* ── Checkbox ── */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ── App Shell ── */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px 1fr;
}

/* ── Sidebar ── */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px 16px;
    border-left: 1px solid var(--border);
    background: #000000;
    overflow-y: auto;
}

.sidebar-brand {
    margin-bottom: 28px;
    padding-bottom: 0;
}

.sidebar-brand strong,
.sidebar-brand small {
    display: block;
}

.sidebar-brand strong {
    font-weight: 800;
    letter-spacing: -0.02em;
    font-size: 0.95rem;
}

.sidebar-brand small {
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 2px;
}

.side-nav {
    display: grid;
    gap: 2px;
}

.nav-item {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    text-align: right;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition:
        color var(--transition),
        background var(--transition);
}

.nav-item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(249, 115, 22, 0.08);
    font-weight: 600;
}

.nav-item.active svg {
    color: var(--primary);
}

/* Sidebar section label */
.sidebar-brand + nav::before {
    content: "Dashboard";
    display: block;
    padding: 0 12px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ── Dashboard Main ── */
.dashboard-main {
    min-width: 0;
    padding: 24px 28px;
}

/* ── Topbar ── */
.topbar {
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.topbar-actions {
    gap: 10px;
}

/* ── Icon Buttons ── */
.icon-btn {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
    transition:
        color var(--transition),
        background var(--transition),
        border-color var(--transition);
}

.icon-btn:hover {
    border-color: var(--border-hover);
    color: var(--primary);
    background: var(--primary-dim);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn.compact {
    width: 36px;
    height: 36px;
}

/* ── Content Sections ── */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: sectionFadeIn 0.3s ease-out both;
}

@keyframes sectionFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

/* ── Metric Card & Panel ── */
.metric-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

/* ── Metric Card ── */
.metric-card {
    min-height: 110px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    position: relative;
}

.metric-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm), var(--shadow-ember);
}

.metric-card svg {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 20px;
    height: 20px;
    padding: 8px;
    box-sizing: content-box;
    border-radius: var(--radius-sm);
    background: var(--primary-dim);
    color: var(--primary);
}

.metric-card span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.metric-card strong {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
}

.accent-purple svg { color: var(--primary); background: var(--primary-dim); }
.accent-cyan svg { color: var(--primary); background: var(--primary-dim); }
.accent-green svg { color: var(--primary); background: var(--primary-dim); }
.accent-rose svg { color: var(--primary); background: var(--primary-dim); }

/* ── Dashboard Grid ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
    gap: 16px;
    align-items: start;
}

/* ── Panel ── */
.panel {
    padding: 24px;
    min-width: 0;
}

.panel:hover {
    border-color: var(--border-hover);
}

.wide-panel {
    grid-column: span 1;
}

.panel-head {
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.panel-head > svg {
    color: var(--primary);
    opacity: 0.5;
}

/* ── Pills & Tags ── */
.pill,
.tag {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    background: var(--surface-2);
    font-size: 0.78rem;
    font-weight: 500;
    transition: border-color var(--transition);
}

/* Online status pill */
.pill {
    border-color: rgba(52, 211, 153, 0.3);
    color: var(--green);
    background: rgba(52, 211, 153, 0.08);
    font-weight: 600;
}

/* ── Role Badge ── */
.role-badge {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    color: var(--primary);
    background: var(--primary-dim);
    border: 1px solid rgba(249, 115, 22, 0.25);
    font-weight: 700;
    font-size: 0.85rem;
}

[hidden] {
    display: none !important;
}

/* ── Canvas ── */
canvas {
    width: 100%;
    max-height: 280px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* ── Lists ── */
.subscription-summary,
.performance-list,
.details-grid,
.rank-list,
.permission-list,
.feature-list,
.plan-list {
    display: grid;
    gap: 8px;
}

.permission-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.subscription-summary > div,
.performance-list > div,
.details-grid > div,
.rank-item,
.feature-item,
.plan-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: border-color var(--transition);
}

.subscription-summary > div:hover,
.performance-list > div:hover,
.details-grid > div:hover,
.rank-item:hover {
    border-color: var(--border-hover);
}

.subscription-summary span,
.performance-list span,
.details-grid span {
    color: var(--muted);
    font-weight: 500;
}

.feature-item,
.plan-item {
    display: grid;
    transition: border-color var(--transition);
}

.feature-item:hover,
.plan-item:hover {
    border-color: var(--border-hover);
}

.feature-item-head,
.feature-item-tags,
.bot-command-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.feature-item p,
.plan-item p,
.bot-command-description {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
    font-size: 0.9rem;
}

.feature-command-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
}

.app-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

.app-table th,
.app-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-align: right;
}

.app-table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.app-table tbody tr {
    transition: background var(--transition);
}

.app-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.status-executed,
.status-open,
.level-success {
    color: var(--green);
}

.status-failed,
.level-danger {
    color: var(--rose);
}

.status-queued,
.level-warning {
    color: var(--amber);
}

/* ── Forms ── */
.form-grid,
.stack-form {
    display: grid;
    gap: 16px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-span {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.88rem;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 14px;
    color: var(--text);
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: rgba(168, 162, 158, 0.4);
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ── Code Output ── */
.code-output {
    min-height: 82px;
    margin: 18px 0 0;
    padding: 16px;
    overflow: auto;
    color: var(--green);
    background: #0a0908;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    direction: ltr;
    text-align: left;
    font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
    font-size: 0.84rem;
    line-height: 1.7;
}

body.light-mode .code-output {
    background: #1c1917;
    color: var(--green);
}

/* ── Tickets / Polls / Messages ── */
.ticket-list,
.poll-list,
.message-log {
    display: grid;
    gap: 8px;
}

.ticket-item,
.poll-item,
.message-item {
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    transition:
        border-color var(--transition),
        background var(--transition);
}

.ticket-item {
    cursor: pointer;
}

.ticket-item:hover {
    border-color: var(--border-hover);
}

.ticket-item.active {
    border-color: var(--primary);
    background: var(--primary-dim);
}

.ticket-meta,
.poll-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.command-help {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── Bot Commands ── */
.bot-command-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.bot-command-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.bot-command-grid,
.bot-command-group,
.bot-command-cards {
    display: grid;
    gap: 12px;
}

.bot-command-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.bot-command-stat {
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    transition: border-color var(--transition);
}

.bot-command-stat:hover {
    border-color: var(--border-hover);
}

.bot-command-stat span {
    display: block;
    color: var(--muted);
    margin-bottom: 6px;
    font-size: 0.78rem;
    font-weight: 600;
}

.bot-command-stat strong {
    font-size: 1.05rem;
    font-weight: 700;
}

.bot-protection-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.protection-card {
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    display: grid;
    gap: 14px;
    transition: border-color var(--transition);
}

.protection-card:hover {
    border-color: var(--border-hover);
}

.protection-card-head,
.protection-toggle-row,
.protection-number-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.protection-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
    font-size: 0.88rem;
}

.protection-number-row input {
    width: 110px;
}

.protection-actions {
    display: flex;
    justify-content: flex-start;
}

.bot-command-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bot-command-group-title,
.bot-command-card-head,
.bot-command-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.bot-command-card {
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    transition:
        border-color var(--transition),
        background var(--transition);
}

.bot-command-card:hover {
    border-color: var(--border-hover);
}

.bot-command-card.is-locked {
    border-color: rgba(251, 191, 36, 0.25);
}

.bot-command-card-head {
    margin-bottom: 12px;
}

.bot-command-card-head strong,
.bot-command-card-head small {
    display: block;
}

.bot-command-card-head small {
    color: var(--muted);
    margin-top: 4px;
    direction: ltr;
    text-align: right;
    font-size: 0.8rem;
    font-family: "JetBrains Mono", monospace;
}

.role-choice-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.bot-command-meta {
    margin-bottom: 10px;
}

.bot-command-description {
    margin-bottom: 12px;
}

.role-choice {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    grid-template-columns: none;
    gap: 7px;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-solid);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color var(--transition);
}

.role-choice:hover {
    border-color: var(--border-hover);
}

.role-choice input {
    width: 14px;
    min-height: 14px;
    padding: 0;
    accent-color: var(--primary);
}

.role-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

.config-label {
    margin-bottom: 12px;
}

.bot-command-actions {
    justify-content: flex-start;
}

/* ── Switch ── */
.switch {
    position: relative;
    width: 48px;
    height: 26px;
    display: inline-block;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch span {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(68, 64, 60, 0.6);
    transition: background var(--transition), box-shadow var(--transition);
    cursor: pointer;
}

.switch span::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    right: 3px;
    top: 3px;
    border-radius: 50%;
    background: white;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.switch input:checked + span {
    background: var(--primary);
    box-shadow: 0 0 12px rgba(249, 115, 22, 0.25);
}

.switch input:checked + span::before {
    transform: translateX(-22px);
}

/* ── Roles ── */
.role-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.role-card {
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    transition: border-color var(--transition);
}

.role-card:hover {
    border-color: var(--border-hover);
}

.role-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.inline-role-select {
    min-width: 126px;
}

/* ── Message Log ── */
.message-log {
    max-height: 360px;
    overflow: auto;
    padding-left: 4px;
}

.message-item strong {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

.message-item p {
    margin-bottom: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.reply-form {
    display: grid;
    grid-template-columns: 1fr 46px;
    gap: 10px;
    margin-top: 16px;
}

/* ── Toasts ── */
.toast-stack {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    display: grid;
    gap: 8px;
    width: min(380px, calc(100vw - 32px));
}

.app-toast {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-solid);
    box-shadow: var(--shadow);
    opacity: 1;
    font-weight: 500;
    font-size: 0.92rem;
    transition: opacity 0.35s ease, transform 0.35s ease;
    animation: toastSlideIn 0.3s ease-out both;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast-fade-out {
    opacity: 0;
    transform: translateY(-8px);
}

.app-toast-success {
    border-color: rgba(52, 211, 153, 0.35);
    border-right: 3px solid var(--green);
}

.app-toast-warning {
    border-color: rgba(251, 191, 36, 0.35);
    border-right: 3px solid var(--amber);
}

.app-toast-danger {
    border-color: rgba(251, 113, 133, 0.35);
    border-right: 3px solid var(--rose);
}

/* ═══════════════════════════════════════════════════════
   Responsive Breakpoints
   ═══════════════════════════════════════════════════════ */

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 64px 1fr;
    }

    .sidebar {
        padding: 14px 8px;
    }

    .sidebar-brand div,
    .nav-item span {
        display: none;
    }

    .sidebar-brand + nav::before {
        display: none;
    }

    .sidebar-brand {
        justify-content: center;
    }

    .nav-item {
        justify-content: center;
        padding: 0;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .login-grid {
        grid-template-columns: 1fr;
    }

    .bot-command-summary,
    .bot-protection-grid,
    .bot-command-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        height: auto;
        border-left: 0;
        border-bottom: 1px solid var(--border);
        background: var(--surface-solid);
    }

    .sidebar-brand div,
    .nav-item span {
        display: block;
    }

    .sidebar-brand + nav::before {
        display: none;
    }

    .side-nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .nav-item {
        min-height: 54px;
        justify-content: center;
        flex-direction: column;
        gap: 4px;
        font-size: 0.78rem;
        text-align: center;
    }

    .dashboard-main {
        padding: 16px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats-grid,
    .form-grid,
    .role-grid,
    .bot-command-toolbar,
    .bot-command-cards {
        grid-template-columns: 1fr;
    }

    .bot-command-toolbar-actions {
        justify-content: stretch;
    }
}

/* ═══════════════════════════════════════════════════════
   Entrance Animations
   ═══════════════════════════════════════════════════════ */

.stats-grid .metric-card {
    animation: cardAppear 0.4s ease-out both;
}

.stats-grid .metric-card:nth-child(1) { animation-delay: 0.05s; }
.stats-grid .metric-card:nth-child(2) { animation-delay: 0.1s; }
.stats-grid .metric-card:nth-child(3) { animation-delay: 0.15s; }
.stats-grid .metric-card:nth-child(4) { animation-delay: 0.2s; }
.stats-grid .metric-card:nth-child(5) { animation-delay: 0.25s; }
.stats-grid .metric-card:nth-child(6) { animation-delay: 0.3s; }
.stats-grid .metric-card:nth-child(7) { animation-delay: 0.35s; }

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-grid .panel {
    animation: cardAppear 0.4s ease-out both;
}

.dashboard-grid .panel:nth-child(1) { animation-delay: 0.08s; }
.dashboard-grid .panel:nth-child(2) { animation-delay: 0.16s; }
.dashboard-grid .panel:nth-child(3) { animation-delay: 0.24s; }
.dashboard-grid .panel:nth-child(4) { animation-delay: 0.32s; }
.dashboard-grid .panel:nth-child(5) { animation-delay: 0.40s; }
.dashboard-grid .panel:nth-child(6) { animation-delay: 0.48s; }

/* ═══════════════════════════════════════════════════════
   Utility Classes
   ═══════════════════════════════════════════════════════ */

.btn-outline {
    color: var(--text);
    background: transparent;
    border: 1px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--border-hover);
    background: var(--surface-2);
}

.field-help {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.5;
}

.command-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.helper-field {
    display: grid;
    gap: 6px;
}

.admin-only {
    display: none; /* visibility controlled via JS data-permissions */
}
