/* ╔══════════════════════════════════════════╗
   ║   Chaily Bot Panel — Design System       ║
   ║   Тёмная тема, gaming dashboard          ║
   ╚══════════════════════════════════════════╝ */

/* ─────────────────────────────────────────
   CSS Custom Properties (Design Tokens)
   ───────────────────────────────────────── */
:root {
    /* Фон */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-hover: #1c2a4a;
    --bg-input: #0a0a15;

    /* Текст */
    --text-primary: #e8e8f0;
    --text-secondary: #9b9bb0;
    --text-muted: #6b6b80;

    /* Twitch-палитра */
    --twitch: #9146FF;
    --twitch-light: #bf94ff;
    --twitch-dark: #6a30c3;

    /* Акценты */
    --accent: #9146FF;
    --accent-glow: rgba(145, 70, 255, 0.3);
    --success: #00ffae;
    --success-bg: rgba(0, 255, 174, 0.1);
    --warning: #ffc107;
    --warning-bg: rgba(255, 193, 7, 0.1);
    --danger: #ff4d6a;
    --danger-bg: rgba(255, 77, 106, 0.1);
    --info: #38bdf8;

    /* Геометрия */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Тени */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Анимации */
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Sidebar */
    --sidebar-width: 240px;
    --sidebar-collapsed: 60px;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

a {
    color: var(--twitch-light);
    text-decoration: none;
}

a:hover {
    color: var(--twitch);
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 3px;
}

/* ─────────────────────────────────────────
   Login Screen
   ───────────────────────────────────────── */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at top, var(--bg-secondary) 0%, var(--bg-primary) 70%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid rgba(145, 70, 255, 0.15);
    border-radius: var(--radius-lg);
    padding: 3rem 2.5rem;
    text-align: center;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    max-width: 400px;
    width: 90%;
    animation: fadeInUp 0.5s ease;
}

.login-logo {
    color: var(--twitch);
    margin-bottom: 1rem;
}

.login-card h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* ─────────────────────────────────────────
   Layout
   ───────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.overlay-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr);
    gap: 1rem;
    align-items: start;
}

.overlay-layout.overlay-layout-fullscreen {
    grid-template-columns: 1fr;
    min-height: 100vh;
    padding: 1rem;
    background:
        radial-gradient(circle at top, rgba(72, 182, 255, 0.18), transparent 45%),
        linear-gradient(180deg, #09111d, #050913);
}

.overlay-main-panel,
.overlay-sidebar {
    display: grid;
    gap: 1rem;
}

.overlay-layout.overlay-layout-fullscreen .overlay-main-panel {
    min-height: calc(100vh - 2rem);
}

.overlay-layout.overlay-layout-fullscreen .overlay-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: min(420px, 92vw);
    height: 100vh;
    padding: 1rem;
    overflow-y: auto;
    background: rgba(6, 10, 18, 0.96);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: -24px 0 48px rgba(0, 0, 0, 0.42);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 50;
}

.overlay-layout.overlay-layout-fullscreen.overlay-drawer-open .overlay-sidebar {
    transform: translateX(0);
}

.overlay-layout.overlay-layout-fullscreen #overlay-audio-sidebar-card {
    display: grid;
}

.overlay-layout.overlay-layout-fullscreen #overlay-audio-inline-card {
    display: none;
}

.overlay-layout.overlay-layout-fullscreen #overlay-item-sidebar-card {
    display: grid;
}

.overlay-layout.overlay-layout-fullscreen #overlay-item-inline-card {
    display: none;
}

.overlay-sidebar-card {
    overflow: hidden;
}

#overlay-audio-sidebar-card {
    display: none;
}

#overlay-item-sidebar-card {
    display: none;
}

.overlay-workspace-stack {
    display: grid;
    gap: 0.75rem;
    padding: 0 1.25rem 1.25rem;
}

.overlay-editor-shell {
    display: grid;
    gap: 0.75rem;
    position: relative;
    z-index: 0;
    isolation: isolate;
}

.overlay-audio-panel {
    display: grid;
    gap: 0.75rem;
}

.overlay-item-panel {
    display: grid;
    gap: 0.75rem;
}

.overlay-audio-controls {
    display: grid;
    gap: 0.75rem;
}

.overlay-item-controls {
    display: grid;
    gap: 0.75rem;
}

.overlay-audio-card {
    display: grid;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.overlay-item-card {
    display: grid;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.overlay-item-card-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
}

.overlay-audio-card-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
}

.overlay-audio-card-header small,
.overlay-audio-empty,
.overlay-item-empty {
    color: var(--text-muted);
}

.overlay-audio-note {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.overlay-audio-button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.overlay-item-button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.overlay-audio-range {
    display: grid;
    gap: 0.35rem;
}

.overlay-audio-range span {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.overlay-stage-heading {
    align-items: start;
    flex-wrap: wrap;
}

.overlay-stage-heading-copy {
    display: grid;
    gap: 0.35rem;
}

.overlay-stage-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.overlay-stage-control {
    display: grid;
    gap: 0.35rem;
    min-width: 190px;
}

.overlay-stage-control span {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.overlay-stage-control input[type="range"] {
    width: 100%;
}

.overlay-section-heading {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    color: var(--text-secondary);
}

.overlay-section-heading small {
    color: var(--text-muted);
}



.overlay-buffer-zone {
    position: relative;
    min-height: 420px;
    border-radius: var(--radius);
    overflow: hidden;
    background:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        radial-gradient(circle at top, rgba(72, 182, 255, 0.18), transparent 48%),
        linear-gradient(180deg, rgba(18, 31, 56, 0.98), rgba(10, 10, 21, 0.98));
    background-size: 40px 40px, 40px 40px, cover;
    border: 1px solid rgba(101, 186, 255, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.overlay-editor-stage {
    position: absolute;
    left: var(--overlay-stage-left, 10%);
    top: var(--overlay-stage-top, 10%);
    width: var(--overlay-stage-width, 80%);
    height: var(--overlay-stage-height, 80%);
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
    background: rgba(7, 12, 24, 0.92);
}

.overlay-runtime-layer {
    position: absolute;
    inset: 0;
    z-index: 2;
}

#overlay-preview-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(10, 10, 21, 0.9);
    pointer-events: none;
}

.overlay-editor-canvas {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(180deg, rgba(8, 11, 18, 0.05), rgba(8, 11, 18, 0.32));
    background-size: 36px 36px, 36px 36px, cover;
}

.overlay-stage-badge,
.overlay-buffer-badge {
    position: absolute;
    color: var(--text-muted);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: rgba(7, 12, 24, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    backdrop-filter: blur(8px);
}

.overlay-stage-badge {
    left: calc(var(--overlay-stage-left, 10%) + 0.75rem);
    top: calc(var(--overlay-stage-top, 10%) + 0.75rem);
}

.overlay-buffer-badge {
    right: 0.9rem;
    top: 0.9rem;
}

.overlay-editor-item {
    position: absolute;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    box-shadow: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: grab;
    user-select: none;
    overflow: visible;
}

.overlay-editor-item:hover {
    border-color: rgba(101, 186, 255, 0.7);
    box-shadow: 0 0 0 1px rgba(101, 186, 255, 0.2);
}

.overlay-editor-item.is-selected {
    border-color: rgba(101, 186, 255, 0.95);
    box-shadow: 0 0 0 2px rgba(101, 186, 255, 0.28);
}

.overlay-editor-item.is-hidden {
    opacity: 0.45;
}

.overlay-editor-item.is-buffered {
    border-style: dashed;
}

.overlay-editor-item-media-shell {
    position: absolute;
    inset: 0;
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
    opacity: 1;
    pointer-events: none;
    transform-origin: center center;
}

.overlay-editor-item-media {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: 0;
    pointer-events: none;
}

.overlay-editor-item-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 1rem;
    background:
        linear-gradient(135deg, rgba(101, 186, 255, 0.18), rgba(145, 70, 255, 0.12)),
        rgba(10, 14, 24, 0.88);
    color: var(--text-secondary);
    font-weight: 700;
}

.overlay-editor-item-placeholder-audio {
    gap: 0.35rem;
}

.overlay-editor-item-placeholder-audio small {
    color: var(--text-muted);
    font-weight: 500;
}

.overlay-editor-item-remove {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 999px;
    background: rgba(220, 38, 38, 0.95);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.overlay-editor-item:hover .overlay-editor-item-remove {
    display: inline-flex;
}

.overlay-editor-item-rotate {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 24px;
    height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    background: rgba(7, 12, 24, 0.95);
    cursor: grab;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.overlay-editor-item-rotate::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(101, 186, 255, 0.95);
}

.overlay-editor-item:hover .overlay-editor-item-rotate,
.overlay-editor-item.is-selected .overlay-editor-item-rotate {
    display: inline-flex;
}

.overlay-editor-item-resize {
    position: absolute;
    right: 0.35rem;
    bottom: 0.35rem;
    width: 18px;
    height: 18px;
    border: 0;
    border-right: 2px solid rgba(255, 255, 255, 0.82);
    border-bottom: 2px solid rgba(255, 255, 255, 0.82);
    background: transparent;
    cursor: nwse-resize;
    z-index: 3;
}

.overlay-editor-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
}

.overlay-editor-empty-stage {
    inset: 10%;
}

body.is-overlay-gesturing,
body.is-overlay-gesturing * {
    cursor: grabbing !important;
}

.overlay-list-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    padding: 0.9rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    align-items: center;
}

.overlay-list-card.active {
    background: rgba(145, 70, 255, 0.08);
}

.overlay-list-title {
    font-weight: 700;
    color: var(--text-primary);
}

.overlay-list-meta {
    display: none;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.overlay-list-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.overlay-token-box {
    padding: 0 1.25rem 1.25rem;
}

.overlay-token-box code {
    display: block;
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--twitch-light);
    word-break: break-all;
}

.overlay-settings-grid {
    padding: 0 1.25rem 1.25rem;
    display: grid;
    gap: 0.75rem;
}

@media (max-width: 1200px) {
    .overlay-layout {
        grid-template-columns: 1fr;
    }

    .overlay-stage-controls {
        width: 100%;
        justify-content: stretch;
    }

    .overlay-stage-control {
        min-width: 0;
        flex: 1 1 220px;
    }
}

/* ─────────────────────────────────────────
   Sidebar
   ───────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width var(--transition-slow);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.5rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(145, 70, 255, 0.08);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(145, 70, 255, 0.15);
    color: var(--twitch-light);
    box-shadow: inset 3px 0 0 var(--twitch);
}

.nav-divider {
    height: 1px;
    margin: 0.65rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
}

.nav-section-title {
    margin: 0.2rem 1rem 0.35rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    border: 2px solid var(--twitch);
}

.user-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─────────────────────────────────────────
   Main Content
   ───────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

/* ─────────────────────────────────────────
   Page Header
   ───────────────────────────────────────── */
.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ─────────────────────────────────────────
   Cards
   ───────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all var(--transition);
}

.card:hover {
    border-color: rgba(145, 70, 255, 0.15);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.purple {
    background: rgba(145, 70, 255, 0.15);
    color: var(--twitch-light);
}

.stat-icon.green {
    background: var(--success-bg);
    color: var(--success);
}

.stat-icon.yellow {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-icon.red {
    background: var(--danger-bg);
    color: var(--danger);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ─────────────────────────────────────────
   Buttons
   ───────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--twitch);
    color: #fff;
    border-color: var(--twitch);
}

.btn-primary:hover {
    background: var(--twitch-dark);
    box-shadow: var(--shadow-glow);
}

.btn-success {
    background: rgba(0, 255, 174, 0.15);
    color: var(--success);
    border-color: rgba(0, 255, 174, 0.3);
}

.btn-success:hover {
    background: rgba(0, 255, 174, 0.25);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(255, 77, 106, 0.3);
}

.btn-danger:hover {
    background: rgba(255, 77, 106, 0.25);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-twitch {
    background: var(--twitch);
    color: #fff;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-glow);
}

.btn-twitch:hover {
    background: var(--twitch-dark);
    transform: translateY(-1px);
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

/* ─────────────────────────────────────────
   Inputs
   ───────────────────────────────────────── */
.input,
.select,
textarea {
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color var(--transition);
    width: 100%;
}

.input:focus,
.select:focus,
textarea:focus {
    outline: none;
    border-color: var(--twitch);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input::placeholder {
    color: var(--text-muted);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Checkbox / Toggle */
.toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.toggle input[type="checkbox"] {
    appearance: none;
    width: 36px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: background var(--transition);
}

.toggle input[type="checkbox"]::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-secondary);
    top: 2px;
    left: 2px;
    transition: all var(--transition);
}

.toggle input[type="checkbox"]:checked {
    background: var(--twitch);
}

.toggle input[type="checkbox"]:checked::after {
    background: #fff;
    left: 18px;
}

/* ─────────────────────────────────────────
   Tables
   ───────────────────────────────────────── */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--bg-secondary);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sortable:focus-visible {
    outline: 1px solid var(--twitch);
    outline-offset: -1px;
}

th.sortable .sort-indicator {
    margin-left: 0.35rem;
    color: var(--text-muted);
}

th.sortable.is-active .sort-indicator {
    color: var(--twitch-light);
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

tr:hover td {
    background: rgba(145, 70, 255, 0.03);
}

/* ─────────────────────────────────────────
   Badges
   ───────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: rgba(56, 189, 248, 0.1);
    color: var(--info);
}

.badge-default {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.role-icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 4px;
}

/* ─────────────────────────────────────────
   Modal
   ───────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-card);
    border: 1px solid rgba(145, 70, 255, 0.15);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ─────────────────────────────────────────
   Toast
   ───────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 250px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--info);
}

/* ─────────────────────────────────────────
   Search bar / Toolbar
   ───────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box .input {
    padding-left: 2.5rem;
}

.search-box svg {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* ─────────────────────────────────────────
   Skeleton loader
   ───────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s ease infinite;
    border-radius: var(--radius-sm);
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-row {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.skeleton-cell {
    flex: 1;
}

/* ─────────────────────────────────────────
   Empty state
   ───────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.95rem;
}

/* ─────────────────────────────────────────
   Pagination
   ───────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.records-count-row {
    display: flex;
    justify-content: flex-end;
    padding: 0.75rem 1rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.records-count-row strong {
    color: var(--text-primary);
}

/* Badges & Roles */
.role-icon {
    margin-right: 4px;
    font-size: 1.1em;
    cursor: help;
}

.custom-role {
    font-size: 0.8em;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    display: inline-block;
}

.custom-role.badge-info {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-loading {
    opacity: 0.5;
    animation: pulse 1.5s infinite;
}

/* Autocomplete */
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.autocomplete-item:hover {
    background: var(--bg-hover);
}

@keyframes pulse {
    0% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 0.3;
    }
}

.pagination button {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.pagination button:hover:not(:disabled) {
    background: rgba(145, 70, 255, 0.1);
    color: var(--twitch-light);
}

.pagination button:disabled {
    opacity: 0.3;
    cursor: default;
}

.pagination span {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.quote-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.quote-table th:first-child,
.quote-table td:first-child {
    width: 44px;
    text-align: center;
}

.quote-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--twitch);
}

.quote-text-cell {
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 560px;
}

/* ─────────────────────────────────────────
   Animations
   ───────────────────────────────────────── */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes skeleton {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ─────────────────────────────────────────
   Responsive
   ───────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        z-index: 200;
    }

    .sidebar-header,
    .sidebar-footer {
        display: none;
    }

    .sidebar-nav {
        display: flex;
        justify-content: space-around;
        padding: 0.5rem;
        overflow: hidden;
    }

    .nav-item {
        flex-direction: column;
        gap: 0.2rem;
        padding: 0.5rem;
        font-size: 0.7rem;
    }

    .nav-divider,
    .nav-section-title {
        display: none;
    }

    .nav-item.active {
        box-shadow: none;
        border-top: 2px solid var(--twitch);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-bottom: 5rem;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .event-settings-grid,
    .event-sections-grid {
        grid-template-columns: 1fr;
    }

    .event-threshold-list-header,
    .event-threshold-row {
        grid-template-columns: 1fr;
    }
}

/* ─────────────────────────────────────────
   Highlighting
   ───────────────────────────────────────── */
.highlight-cheg {
    color: var(--twitch-light);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(191, 148, 255, 0.4);
}

/* ─────────────────────────────────────────
   Tabs
   ───────────────────────────────────────── */
/* ─────────────────────────────────────────
   Tabs
   ───────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1.5rem;
    padding-bottom: 0px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.8rem 1.2rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
    opacity: 0.7;
    border-bottom: 2px solid transparent;
    /* Reserve space for border */
    margin-bottom: -2px;
    /* Pull down to overlap container border */
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
    opacity: 1;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn.active {
    color: var(--twitch-light);
    opacity: 1;
    border-bottom: 2px solid var(--twitch);
    background: linear-gradient(to top, rgba(145, 70, 255, 0.1), transparent);
}

/* Specific colors for tabs */
.tab-btn[data-tab="errors"] {
    color: var(--danger);
}

.tab-btn[data-tab="errors"].active {
    border-bottom-color: var(--danger);
    background: linear-gradient(to top, rgba(255, 77, 106, 0.1), transparent);
}

.tab-btn[data-tab="warnings"] {
    color: var(--warning);
}

.tab-btn[data-tab="warnings"].active {
    border-bottom-color: var(--warning);
    background: linear-gradient(to top, rgba(255, 193, 7, 0.1), transparent);
}

/* ─────────────────────────────────────────
   Premium Dashboard Selects
   ───────────────────────────────────────── */
.select-premium {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239b9bb0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.2rem;
    border: none;
    color: var(--text-primary);
    padding: 0.5rem 2.2rem 0.5rem 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
}

.select-premium:hover {
    color: var(--twitch-light);
}

.dashboard-control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    padding: 0 0.75rem;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all var(--transition);
}

.dashboard-control-group:focus-within {
    border-color: var(--twitch);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.control-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    padding-right: 0.5rem;
    display: flex;
    align-items: center;
    height: 1.5rem;
}

.overlay-system-card.is-off {
    opacity: 0.72;
}

.overlay-editor-item.is-system .overlay-editor-item-remove,
.overlay-editor-item.is-system .overlay-editor-item-rotate,
.overlay-editor-item.is-system .overlay-editor-item-resize {
    display: none;
}

.overlay-editor-system-preview {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    color: #f8f0c6;
    background: linear-gradient(135deg, rgba(28, 34, 76, 0.92), rgba(12, 16, 42, 0.9));
    border: 1px solid rgba(255, 221, 104, 0.28);
    box-sizing: border-box;
    text-align: center;
}

.overlay-editor-system-preview strong {
    font-size: 1rem;
}

.overlay-editor-system-preview small {
    color: rgba(255, 255, 255, 0.72);
}

.overlay-editor-system-preview-toast {
    justify-content: flex-end;
    background: linear-gradient(180deg, rgba(35, 39, 86, 0.32), rgba(35, 39, 86, 0));
    border-style: dashed;
}

.overlay-editor-system-toast-chip {
    align-self: center;
    padding: 0.6rem 1rem;
    border-radius: 999px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.overlay-editor-system-toast-chip.is-testing {
    animation: overlayEditorChegToast 1.8s ease;
}

.overlay-system-settings {
    display: grid;
    gap: 0.85rem;
}

.overlay-system-settings-note {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.83rem;
    line-height: 1.45;
}

.overlay-system-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.overlay-system-color-input {
    min-height: 44px;
    padding: 0.35rem;
}

.overlay-editor-text-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    padding: 0.5rem;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.1;
    overflow: hidden;
}

.overlay-editor-text-empty {
    color: rgba(255, 255, 255, 0.45);
    -webkit-text-stroke: 0;
}

.overlay-text-settings {
    display: grid;
    gap: 0.85rem;
}

.overlay-text-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.overlay-text-phrases {
    display: grid;
    gap: 0.5rem;
}

.overlay-text-phrase-list {
    display: grid;
    gap: 0.5rem;
}

.overlay-text-phrase-row {
    display: grid;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.overlay-text-phrase-info {
    display: grid;
    gap: 0.2rem;
}

.overlay-text-phrase-info small {
    color: var(--text-muted);
}

.overlay-text-card-body {
    display: grid;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem 0.75rem;
}

.event-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    align-items: start;
}

.event-settings-card,
.event-config-card {
    overflow: hidden;
}

.event-settings-card-header,
.event-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.event-threshold-list {
    display: grid;
    gap: 0.75rem;
}

.event-threshold-list-header,
.event-threshold-row {
    display: grid;
    grid-template-columns: minmax(110px, 140px) minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
}

.event-threshold-list-header {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.event-sections-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.event-config-body {
    display: grid;
    gap: 1rem;
    padding: 1rem 1.25rem 1.25rem;
}

.event-config-note {
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
}

.event-config-block {
    display: grid;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

@keyframes overlayEditorChegToast {
    0% {
        opacity: 0;
        transform: translateY(42px);
    }
    18% {
        opacity: 1;
        transform: translateY(-10px);
    }
    72% {
        opacity: 1;
        transform: translateY(-38px);
    }
    100% {
        opacity: 0;
        transform: translateY(-74px);
    }
}
