/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary:   #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card:      #16161f;
    --bg-hover:     #1e1e2a;
    --bg-input:     #1a1a25;
    --border:       rgba(255,255,255,0.06);
    --border-focus: rgba(108,92,231,0.5);

    --text-primary:   #e8e8f0;
    --text-secondary: #8888a0;
    --text-muted:     #55556a;

    --accent:       #6c5ce7;
    --accent-hover: #7d6ff0;
    --green:        #00b894;
    --green-bg:     rgba(0,184,148,0.12);
    --red:          #ff6b6b;
    --red-bg:       rgba(255,107,107,0.12);
    --blue:         #0984e3;
    --blue-bg:      rgba(9,132,227,0.12);
    --yellow:       #fdcb6e;
    --yellow-bg:    rgba(253,203,110,0.12);

    --radius:     12px;
    --radius-sm:  8px;
    --radius-xs:  6px;
    --shadow:     0 4px 24px rgba(0,0,0,0.3);
    --transition: 0.2s cubic-bezier(0.4,0,0.2,1);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────────────────── */
.header {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; height: 60px;
    background: rgba(10,10,15,0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
.header__left { display: flex; align-items: center; gap: 16px; }
.logo {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: 1.15rem; color: var(--text-primary);
}
.logo svg { color: var(--accent); }

.status-badge {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 14px; border-radius: 20px;
    font-size: 0.8rem; font-weight: 500;
    background: var(--bg-card); border: 1px solid var(--border);
}
.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition);
}
.status-badge.connected .status-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-badge.error .status-dot { background: var(--red); box-shadow: 0 0 8px var(--red); }

/* ── Main ────────────────────────────────────────────────────────── */
.main { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ── Stats ────────────────────────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 20px;
    background: var(--bg-card); border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: border-color var(--transition), transform var(--transition);
}
.stat-card:hover { border-color: rgba(255,255,255,0.1); transform: translateY(-2px); }
.stat-card__icon {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
}
.stat-card__info { display: flex; flex-direction: column; }
.stat-card__value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-card__label { font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px; }

/* ── Grid ─────────────────────────────────────────────────────────── */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 860px) { .grid-2col { grid-template-columns: 1fr; } }

/* ── Panel ────────────────────────────────────────────────────────── */
.panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.panel__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.panel__header h2 { font-size: 1rem; font-weight: 600; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 0.82rem; font-weight: 500;
    border: none; cursor: pointer;
    transition: all var(--transition);
}
.btn--primary {
    background: var(--accent); color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn--ghost {
    background: transparent; color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn--ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn--sm { padding: 6px 12px; font-size: 0.78rem; }
.btn--danger { background: var(--red-bg); color: var(--red); }
.btn--danger:hover { background: rgba(255,107,107,0.2); }
.btn--toggle { padding: 4px 10px; font-size: 0.75rem; border-radius: 12px; }
.btn--toggle.on { background: var(--green-bg); color: var(--green); }
.btn--toggle.off { background: rgba(255,255,255,0.05); color: var(--text-muted); }

/* ── Trigger Form ─────────────────────────────────────────────────── */
.trigger-form {
    padding: 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    animation: slideDown 0.25s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; margin-bottom: 6px;
    font-size: 0.78rem; font-weight: 500; color: var(--text-secondary);
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%; padding: 10px 14px;
    background: var(--bg-input); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    font-family: var(--font); font-size: 0.88rem;
    transition: border-color var(--transition);
    resize: vertical;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none; border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}
.form-row { display: flex; align-items: flex-end; gap: 12px; }
.form-row .form-group { flex: 1; margin-bottom: 0; }
.form-actions { display: flex; gap: 8px; }

/* ── Triggers List ────────────────────────────────────────────────── */
.triggers-list { max-height: 520px; overflow-y: auto; }
.trigger-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.trigger-item:hover { background: var(--bg-hover); }
.trigger-item:last-child { border-bottom: none; }
.trigger-item__body { flex: 1; min-width: 0; }
.trigger-item__phrase {
    font-weight: 600; font-size: 0.9rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.trigger-item__response {
    font-size: 0.8rem; color: var(--text-secondary);
    margin-top: 3px;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}
.trigger-item__meta {
    font-size: 0.7rem; color: var(--text-muted); margin-top: 4px;
}
.trigger-item__actions { display: flex; gap: 6px; white-space: nowrap; }

.badge {
    display: inline-block; padding: 2px 8px;
    border-radius: 10px; font-size: 0.68rem; font-weight: 500;
}
.badge--contains { background: var(--blue-bg); color: var(--blue); }
.badge--exact    { background: var(--yellow-bg); color: var(--yellow); }

/* ── Log List ─────────────────────────────────────────────────────── */
.log-list { max-height: 520px; overflow-y: auto; }
.log-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    transition: background var(--transition);
}
.log-item:hover { background: var(--bg-hover); }
.log-item:last-child { border-bottom: none; }
.log-item__time { color: var(--text-muted); font-size: 0.72rem; }
.log-item__message { margin-top: 3px; color: var(--text-secondary); }
.log-item__reply {
    margin-top: 4px; padding: 6px 10px;
    background: rgba(108,92,231,0.08); border-radius: var(--radius-xs);
    color: var(--accent); font-size: 0.78rem;
    border-left: 2px solid var(--accent);
}
.log-item__trigger {
    display: inline-block; margin-top: 4px;
    font-size: 0.7rem; color: var(--text-muted);
}
.log-item--no-match { border-left: 3px solid transparent; }
.log-item--matched { border-left: 3px solid var(--green); }

/* ── Empty State ──────────────────────────────────────────────────── */
.empty-state {
    display: flex; flex-direction: column; align-items: center;
    padding: 48px 20px; text-align: center;
}
.empty-state p { color: var(--text-secondary); margin-top: 12px; font-size: 0.9rem; }
.empty-state__sub { font-size: 0.78rem !important; color: var(--text-muted) !important; margin-top: 4px !important; }

/* ── Toast ─────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed; bottom: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 9999;
}
.toast {
    padding: 12px 20px; border-radius: var(--radius-sm);
    font-size: 0.82rem; font-weight: 500;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    box-shadow: var(--shadow);
}
.toast--success { background: var(--green); color: #fff; }
.toast--error   { background: var(--red); color: #fff; }
.toast--info    { background: var(--accent); color: #fff; }

@keyframes toastIn  { from { opacity:0; transform: translateY(16px); } to { opacity:1; transform: translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform: translateY(-8px); } }

/* ── Scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
