@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Discord-inspired palette */
    --bg:               #1e1f22;
    --surface:          #2b2d31;
    --surface-raised:   #313338;
    --surface-elevated: #383a40;
    --surface-hover:    #40444b;
    --border:           rgba(255,255,255,0.06);
    --border-hover:     rgba(255,255,255,0.12);

    /* Brand */
    --accent:           #5865f2;
    --accent-hover:     #4752c4;
    --accent-glow:      rgba(88,101,242,0.35);
    --accent-subtle:    rgba(88,101,242,0.12);
    --brand:            #7c3aed;
    --brand-light:      #a855f7;
    --brand-subtle:     rgba(124,58,237,0.12);

    /* Text */
    --text:             #dbdee1;
    --text-secondary:   #b5bac1;
    --text-muted:       #80848e;

    /* Status */
    --success:          #23a55a;
    --success-subtle:   rgba(35,165,90,0.12);
    --error:            #f23f43;
    --error-subtle:     rgba(242,63,67,0.12);
    --warning:          #f0b232;
    --warning-subtle:   rgba(240,178,50,0.12);
    --online:           #23a55a;

    /* Discord */
    --discord:          #5865f2;
    --discord-hover:    #4752c4;

    /* Layout */
    --radius:           8px;
    --radius-sm:        6px;
    --radius-lg:        12px;
    --transition:       0.15s ease;
    --sidebar-width:    232px;
    --topbar-height:    48px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--surface-raised);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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


/* ── Scrollbar */
::-webkit-scrollbar { width: 6px; height: 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.16); }

/* ── Utilities */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }

/* ── Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-discord {
    background: var(--discord);
    color: #fff;
    font-size: 15px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 600;
}
.btn-discord:hover:not(:disabled) {
    background: var(--discord-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(88,101,242,0.4);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border-hover);
}

.btn-danger {
    background: var(--error-subtle);
    color: var(--error);
    border: 1px solid transparent;
}
.btn-danger:hover:not(:disabled) {
    background: var(--error);
    color: #fff;
}

.btn-brand {
    background: var(--brand);
    color: #fff;
}
.btn-brand:hover:not(:disabled) {
    background: #6d28d9;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 13px;
}

.btn-xs {
    padding: 3px 8px;
    font-size: 12px;
}

.btn-icon {
    padding: 6px;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    font-size: 15px;
}

/* ── Cards */
.card {
    background: var(--surface-elevated);
    border-radius: var(--radius-lg);
    padding: 20px;
}

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

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Inputs */
.input, .select, textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input::placeholder, textarea::placeholder { color: var(--text-muted); }
.input:focus, .select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}
.select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2380848e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.select option { background: var(--surface-elevated); }

.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

/* ── Toggle switch */
.toggle-wrapper { display: flex; align-items: center; justify-content: space-between; }
.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
    position: absolute; inset: 0;
    background: var(--surface-hover);
    border-radius: 11px;
    cursor: pointer;
    transition: background var(--transition);
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* ── Badge / Tag */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-success { background: var(--success-subtle); color: var(--success); }
.badge-error   { background: var(--error-subtle);   color: var(--error);   }
.badge-accent  { background: var(--accent-subtle);  color: var(--accent);  }
.badge-brand   { background: var(--brand-subtle);   color: var(--brand-light); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); }

/* ── Toast notifications */
#toast-container {
    position: fixed;
    bottom: 104px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.25s ease;
    max-width: 300px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    pointer-events: all;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast-success { background: #1a4731; border: 1px solid var(--success); color: #4ade80; }
.toast-error   { background: #3d1a1c; border: 1px solid var(--error);   color: #f87171; }
.toast-info    { background: #1e2547; border: 1px solid var(--accent);  color: #93c5fd; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0);    }
}
@keyframes slideOut {
    from { opacity: 1; transform: translateX(0);    }
    to   { opacity: 0; transform: translateX(16px); }
}

/* ── Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-brand img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}
.topbar-brand .brand-name { color: var(--text); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    background: var(--surface-elevated);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: default;
}
.user-pill img { width: 24px; height: 24px; border-radius: 50%; }
.user-pill span { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Avatar */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; }
.avatar-md { width: 36px; height: 36px; }

/* ── Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.empty-state p { font-size: 14px; }

/* ── Loading spinner */
.spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--border-hover);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tag list (blocked words, roles) */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    background: var(--surface-hover);
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}
.tag-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 0;
    transition: color var(--transition);
    display: flex;
}
.tag-remove:hover { color: var(--error); }

/* ── Divider */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── Section header */
.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ── Role picker (Discord-style multi-role selector) */
.role-picker { position: relative; }
.role-picker-box {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
    min-height: 40px;
    padding: 6px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: border-color var(--transition), box-shadow var(--transition);
    cursor: text;
}
.role-picker-box:hover { border-color: var(--border-hover); }
.role-picker.open .role-picker-box {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}
.role-picker-empty {
    color: var(--text-muted);
    font-size: 13px;
    padding: 4px 4px;
    user-select: none;
}
.role-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 4px 3px 9px;
    background: var(--role-color-soft, var(--surface-hover));
    border: 1px solid var(--role-color, var(--border));
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
    max-width: 220px;
}
.role-chip .role-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--role-color, var(--text-muted));
    flex-shrink: 0;
}
.role-chip .role-name {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.role-chip-remove {
    background: rgba(0,0,0,0.25);
    color: var(--text-secondary);
    border: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 11px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}
.role-chip-remove:hover { background: var(--error); color: #fff; }
.role-picker-add {
    background: transparent;
    border: 1px dashed var(--border-hover);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12.5px;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.role-picker-add:hover { color: var(--text); border-color: var(--accent); background: var(--accent-subtle); }
.role-picker-dropdown {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px);
    z-index: 30;
    background: var(--surface-raised);
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    overflow: hidden;
    display: flex; flex-direction: column;
    max-height: 280px;
}
.role-picker-dropdown[hidden] { display: none; }
.role-picker-search {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    color: var(--text);
    font-size: 13px;
    outline: none;
}
.role-picker-search::placeholder { color: var(--text-muted); }
.role-picker-list {
    overflow-y: auto;
    padding: 4px;
    flex: 1;
}
.role-option {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    background: transparent;
    border: none;
    padding: 7px 10px;
    border-radius: 4px;
    color: var(--text);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition);
}
.role-option:hover { background: var(--surface-hover); }
.role-option .role-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.role-option .role-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-option .role-check {
    width: 16px; height: 16px;
    border-radius: 4px;
    border: 1.5px solid var(--border-hover);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; color: transparent;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    flex-shrink: 0;
}
.role-option.selected .role-check {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.role-option.selected { background: var(--accent-subtle); }
.role-picker-empty-list {
    padding: 18px 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12.5px;
}

/* ── Inline edit panel for notification subscription rows */
.sub-edit {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.sub-edit[hidden] { display: none; }

/* ── Hamburger + overlay: hidden by default (desktop) */
.sidebar-toggle { display: none; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--topbar-height);
    background: rgba(0,0,0,0.6);
    z-index: 299;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.sidebar-overlay.visible { opacity: 1; pointer-events: all; }

/* ── Responsive */
@media (max-width: 768px) {
    .topbar { padding: 0 12px; }
    .card { padding: 14px; }

    /* Show overlay on mobile (visibility controlled by .visible class) */
    .sidebar-overlay { display: block; }

    /* Sidebar slides off-canvas by default */
    .sidebar {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        height: calc(100vh - var(--topbar-height));
        z-index: 300;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }
    .sidebar.open { transform: translateX(0); }

    /* Hamburger: en el topbar, siempre visible */
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: transparent;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text-secondary);
        cursor: pointer;
        flex-shrink: 0;
        transition: background var(--transition), color var(--transition), border-color var(--transition);
    }
    .sidebar-toggle:hover { background: var(--surface-elevated); color: var(--text); border-color: var(--border-hover); }

    /* Main takes full width */
    .layout { overflow: visible; }
    .main { overflow-y: auto; min-height: calc(100vh - var(--topbar-height)); }

    /* Reduce main padding on small screens */
    .main-padded { padding: 16px; }

    /* User pill — hide username, keep avatar */
    .user-pill span { display: none; }
    .user-pill { padding: 4px; }

    /* Toast anchored to bottom */
    #toast-container { right: 12px; bottom: 16px; }
    .toast { max-width: calc(100vw - 24px); }

    /* Music table: hide artist & duration columns */
    .results-header,
    .result-row {
        grid-template-columns: 28px 1fr 56px;
    }
    .result-row > *:nth-child(3),
    .results-header > *:nth-child(3),
    .result-row > *:nth-child(4),
    .results-header > *:nth-child(4) { display: none; }
    .result-actions { opacity: 1; }
}


/* ── Discord-styled select (auto-enhanced for channel/role pickers) */
.dc-select { position: relative; width: 100%; }
.dc-select-trigger {
    width: 100%; display: flex; align-items: center; gap: 8px;
    padding: 9px 12px; padding-right: 32px;
    background: var(--bg); border: 1px solid transparent;
    border-radius: var(--radius-sm); color: var(--text);
    font-family: inherit; font-size: 14px; cursor: pointer;
    text-align: left; outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    position: relative;
}
.dc-select-trigger:hover { background: var(--surface-elevated); }
.dc-select.open .dc-select-trigger,
.dc-select-trigger:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}
.dc-select-chev {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    color: #80848e; font-size: 10px; pointer-events: none;
    transition: transform var(--transition);
}
.dc-select.open .dc-select-chev { transform: translateY(-50%) rotate(180deg); }
.dc-select-val { display: flex; align-items: center; gap: 8px; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.dc-select-val.dim { color: var(--text-muted); }
.dc-select-menu {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    max-height: 260px; overflow-y: auto;
    background: var(--surface-elevated, #2b2d31);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    border-radius: 8px; padding: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 200;
}
.dc-select-menu[hidden] { display: none; }
.dc-select-search {
    width: 100%; box-sizing: border-box;
    padding: 7px 10px; margin-bottom: 4px;
    background: var(--bg, #1e1f22); border: 1px solid transparent;
    border-radius: 4px; color: var(--text); font-size: 13px; outline: none;
}
.dc-select-search:focus { border-color: var(--accent); }
.dc-select-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 4px;
    color: var(--text); font-size: 14px; cursor: pointer;
    user-select: none;
}
.dc-select-item:hover { background: rgba(88, 101, 242, 0.16); color: #fff; }
.dc-select-item.active { background: rgba(88, 101, 242, 0.24); color: #fff; }
.dc-select-item.empty { color: var(--text-muted); font-style: italic; }
.dc-role-swatch {
    width: 12px; height: 12px; border-radius: 50%;
    flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18);
}
.dc-ch-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; flex-shrink: 0;
    color: #80848e; font-size: 16px; font-weight: 600;
}
.dc-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dc-select-empty { padding: 10px; color: var(--text-muted); font-size: 13px; text-align: center; }
