/* ============================================================
   NolX Panel — thème sombre minimal (inspiré des dashboards OpenAI)
   ============================================================ */

:root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

    --bg-primary: #0a0a0a;
    --bg-secondary: #0d0d0d;
    --bg-card: #111111;
    --bg-tertiary: #1a1a1a;
    --bg-input: #0f0f0f;
    --bg-hover: #181818;
    --bg-elevated: #161616;

    --text-primary: #ececec;
    --text-secondary: #a3a3a3;
    --text-muted: #6f6f6f;

    --accent: #8b7cff;
    --accent-hover: #a094ff;
    --accent-soft: rgba(139, 124, 255, 0.14);
    --primary: var(--accent);
    --success: #10a37f;
    --danger: #ef4146;
    --warning: #f2a93b;
    --info: #8b7cff;

    --border: #232323;
    --border-strong: #303030;
    --sidebar-width: 248px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: none;
    --ring: 0 0 0 3px rgba(139, 124, 255, 0.22);
}

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

html { color-scheme: dark; }

body {
    font-family: var(--font);
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--text-primary); text-decoration: none; }
a:hover { color: #fff; }

::selection { background: rgba(139, 124, 255, 0.35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #262626; border-radius: 10px; border: 2px solid var(--bg-primary); }
::-webkit-scrollbar-thumb:hover { background: #333; }

code {
    font-family: var(--mono);
    font-size: 0.78rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 5px;
    color: var(--text-secondary);
}

kbd {
    font-family: var(--font);
    font-size: 0.68rem;
    font-weight: 500;
    padding: 2px 6px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    line-height: 1;
}

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

.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    padding: 36px 40px 64px;
    min-height: 100vh;
}

@media (min-width: 1700px) {
    .main-content { padding-left: 64px; padding-right: 64px; }
}

/* ======== Topbar (mobile) ======== */
.topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 90;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
}

.topbar-toggle {
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 95;
}
.sidebar-backdrop.active { display: block; }

/* ======== Sidebar ======== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    z-index: 100;
}

.sidebar-header { padding: 12px 12px 6px; }

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.logo i { font-size: 1rem; color: var(--text-secondary); }

/* Sélecteur de serveur (style "org switcher") */
.org-switcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
}
.org-switcher:hover { background: var(--bg-hover); }

.org-icon {
    width: 24px; height: 24px;
    border-radius: 7px;
    background: linear-gradient(135deg, #8b7cff, #4fd1c5);
    color: #000;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.org-icon img { width: 100%; height: 100%; object-fit: cover; }

.org-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.org-chevron { font-size: 0.65rem; color: var(--text-muted); }

.org-switcher select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    font-size: 16px;
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.84rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.12s, color 0.12s;
}
.sidebar-search:hover { border-color: var(--border-strong); color: var(--text-secondary); }
.sidebar-search i { font-size: 0.78rem; }
.sidebar-search kbd { margin-left: auto; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 6px 12px 12px;
}

.nav-section { margin-bottom: 12px; }

.nav-section-title {
    padding: 10px 10px 4px;
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.86rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: #1c1c1c; color: #fff; }

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: 0.84rem;
    color: var(--text-muted);
    transition: color 0.12s;
}
.nav-item.active i, .nav-item:hover i { color: var(--text-primary); }

.nav-badge {
    margin-left: auto;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.3;
}
.nav-badge.soft { background: var(--accent-soft); color: var(--accent); }

.sidebar-footer { padding: 10px 12px 12px; border-top: 1px solid var(--border); }

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
}

.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: #262626;
    border: 1px solid var(--border-strong);
    color: #fff;
    font-weight: 600;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-details { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-size: 0.84rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 0.72rem; color: var(--text-muted); }

.user-logout {
    width: 30px; height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.user-logout:hover { background: var(--bg-hover); color: var(--danger); }

/* ======== Page Header ======== */
.page-header {
    margin-bottom: 28px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.page-header h1 {
    font-size: 1.85rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 12px;
    line-height: 1.2;
}

.page-header h1 i {
    font-size: 1rem;
    color: var(--text-secondary);
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.92rem;
    max-width: 780px;
    line-height: 1.5;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 6px 0 14px;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ======== Cards ======== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-header h2 i { color: var(--text-muted); font-size: 0.9rem; }
.card-header h3 { font-size: 0.95rem; font-weight: 600; }

.info-box {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.84rem;
    line-height: 1.5;
    margin-bottom: 18px;
}
.info-box i { color: var(--accent); margin-top: 2px; }
.info-box.warning i { color: var(--warning); }
.info-box.danger { border-color: rgba(239, 65, 70, 0.35); }
.info-box.danger i { color: var(--danger); }

/* ======== Hero (dashboard) ======== */
.hero {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 36px 40px;
    margin-bottom: 24px;
    background:
        radial-gradient(900px 360px at 85% -30%, rgba(139, 124, 255, 0.35), transparent 60%),
        radial-gradient(700px 300px at 60% 130%, rgba(16, 163, 127, 0.16), transparent 60%),
        linear-gradient(180deg, #141414, #0c0c0c);
}
.hero::after {
    content: '';
    position: absolute;
    right: -140px;
    top: -160px;
    width: 460px; height: 460px;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 32%, #2b2b2b, #0a0a0a 66%);
    box-shadow: -30px 30px 90px rgba(139, 124, 255, 0.28);
    opacity: 0.95;
    pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero-eyebrow {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 10px;
}
.hero h2 { font-size: 1.45rem; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 8px; }
.hero p { color: var(--text-secondary); font-size: 0.92rem; max-width: 640px; line-height: 1.55; margin-bottom: 20px; }
.hero .btn-group { gap: 10px; }

/* ======== Metric tiles ======== */
.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
    margin-bottom: 24px;
}
.metric {
    padding: 18px 22px;
    border-right: 1px solid var(--border);
    min-height: 136px;
    display: flex;
    flex-direction: column;
}
.metric:last-child { border-right: none; }
.metric-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.metric-label a { color: inherit; display: inline-flex; align-items: center; gap: 6px; }
.metric-label i { font-size: 0.6rem; opacity: 0.7; }
.metric-value {
    font-size: 1.55rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.1;
}
.metric-sub { font-size: 0.76rem; color: var(--text-muted); margin-top: 6px; }
.metric-chart {
    margin-top: auto;
    padding-top: 12px;
    height: 48px;
    display: flex;
    align-items: flex-end;
    gap: 5px;
}
.metric-chart .bar {
    flex: 1;
    border-radius: 3px 3px 0 0;
    background: var(--accent);
    opacity: 0.9;
    min-height: 3px;
    position: relative;
}
.metric-chart .bar.green { background: var(--success); }
.metric-chart .bar.amber { background: var(--warning); }
.metric-chart .bar.dim { background: #2a2a2a; }
.metric-legend { display: flex; gap: 12px; font-size: 0.7rem; color: var(--text-muted); margin-top: 6px; flex-wrap: wrap; }
.metric-legend span::before {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 2px;
    margin-right: 5px;
    background: var(--accent);
    vertical-align: middle;
}
.metric-legend span.green::before { background: var(--success); }
.metric-legend span.amber::before { background: var(--warning); }
.metric-line { width: 100%; height: 44px; margin-top: auto; padding-top: 10px; }
.metric-line svg { width: 100%; height: 100%; display: block; overflow: visible; }

.status-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--danger);
    display: inline-block;
    box-shadow: 0 0 0 4px rgba(239, 65, 70, 0.18);
}
.status-dot.online { background: var(--success); box-shadow: 0 0 0 4px rgba(16, 163, 127, 0.18); }

.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 28px;
    align-items: start;
}

/* ======== Module cards (grille "modèles recommandés") ======== */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
    gap: 12px;
}
.module-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.15s, transform 0.15s, background 0.15s;
    min-height: 128px;
}
.module-card:hover { border-color: var(--border-strong); transform: translateY(-1px); background: #131313; }
.module-card.featured {
    background:
        radial-gradient(360px 180px at 100% 0%, rgba(139, 124, 255, 0.28), transparent 60%),
        var(--bg-card);
}
.module-icon {
    width: 36px; height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-primary);
}
.module-card h4 { font-size: 0.9rem; font-weight: 600; }
.module-card p { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.45; }
.module-card .nav-badge { position: absolute; top: 12px; right: 12px; margin: 0; }

/* ======== Updates list ======== */
.updates-list { display: flex; flex-direction: column; gap: 18px; }
.update-item { display: flex; gap: 12px; }
.update-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 0.78rem;
    flex-shrink: 0;
}
.update-date { font-size: 0.74rem; color: var(--text-muted); }
.update-title { font-weight: 600; font-size: 0.88rem; margin: 2px 0 3px; }
.update-desc { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.45; }

/* ======== Pills ======== */
.pill-group {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px;
    background: var(--bg-card);
    gap: 2px;
}
.pill {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
    background: transparent;
    border: none;
    font-family: inherit;
}
.pill.active, .pill:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* ======== Stats Grid (legacy) ======== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color 0.15s, transform 0.15s;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.stat-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    border: 1px solid var(--border);
    overflow: hidden;
}
.stat-icon img { width: 100%; height: 100%; object-fit: cover; }
.stat-icon.blue { background: rgba(139, 124, 255, 0.12); color: var(--accent); }
.stat-icon.green { background: rgba(16, 163, 127, 0.14); color: #2fd4a7; }
.stat-icon.orange { background: rgba(242, 169, 59, 0.14); color: var(--warning); }
.stat-icon.red { background: rgba(239, 65, 70, 0.14); color: #ff7377; }

.stat-info { min-width: 0; }
.stat-info h3 { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; }
.stat-info p { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }

/* ======== Forms ======== */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea,
.input {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 34px;
    cursor: pointer;
}
.form-group select[multiple] { background-image: none; padding-right: 12px; cursor: default; }
.form-group select option { background: #141414; color: var(--text-primary); }

.form-group input[readonly] { color: var(--text-secondary); background: var(--bg-card); cursor: default; }
.form-group input[readonly]:focus { border-color: var(--border-strong); box-shadow: none; }

.form-group input[type="file"] {
    padding: 8px;
    border-style: dashed;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
}
.form-group input[type="file"]::file-selector-button {
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 5px 10px;
    margin-right: 10px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
}

.form-group textarea { min-height: 100px; resize: vertical; line-height: 1.5; }

.form-group .hint, .hint {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 5px;
    line-height: 1.45;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }

.inline-form { display: inline; }

/* ======== Toggle Switch ======== */
.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.toggle-group:last-child { border-bottom: none; }

.toggle-label { display: flex; flex-direction: column; gap: 2px; }
.toggle-label span:first-child { font-weight: 500; font-size: 0.88rem; }
.toggle-label span:last-child:not(:first-child) { font-size: 0.78rem; color: var(--text-muted); }

.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }

.toggle .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #2a2a2a;
    border: 1px solid var(--border-strong);
    border-radius: 22px;
    transition: 0.2s;
}
.toggle .slider:before {
    content: '';
    position: absolute;
    height: 16px; width: 16px;
    left: 2px; bottom: 2px;
    background: #9a9a9a;
    border-radius: 50%;
    transition: 0.2s;
}
.toggle input:checked + .slider { background: var(--success); border-color: var(--success); }
.toggle input:checked + .slider:before { transform: translateX(18px); background: #fff; }
.toggle input:focus-visible + .slider { box-shadow: var(--ring); }

/* ======== Buttons ======== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.25;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
    font-family: inherit;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn i { font-size: 0.8em; }

.btn-primary { background: #fff; color: #000; border-color: #fff; }
.btn-primary:hover { background: #e4e4e4; border-color: #e4e4e4; color: #000; }

.btn-secondary { background: transparent; color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-hover); border-color: #3a3a3a; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #0e8f6f; border-color: #0e8f6f; }

.btn-danger { background: rgba(239, 65, 70, 0.12); color: #ff6b6f; border-color: rgba(239, 65, 70, 0.35); }
.btn-danger:hover { background: rgba(239, 65, 70, 0.22); border-color: rgba(239, 65, 70, 0.5); color: #ff8285; }

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

.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-icon { width: 30px; height: 30px; padding: 0; justify-content: center; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ======== Tables ======== */
.table-container { overflow-x: auto; }

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

table thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    vertical-align: middle;
}
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.cell-main { font-weight: 500; }
.cell-sub { font-size: 0.74rem; color: var(--text-muted); margin-top: 2px; }

/* ======== Badges ======== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid transparent;
    line-height: 1.5;
    white-space: nowrap;
}
.badge-success { background: rgba(16, 163, 127, 0.12); color: #2fd4a7; border-color: rgba(16, 163, 127, 0.3); }
.badge-danger { background: rgba(239, 65, 70, 0.12); color: #ff7377; border-color: rgba(239, 65, 70, 0.3); }
.badge-warning { background: rgba(242, 169, 59, 0.12); color: #f5b955; border-color: rgba(242, 169, 59, 0.3); }
.badge-info, .badge-primary { background: var(--accent-soft); color: #b3a8ff; border-color: rgba(139, 124, 255, 0.35); }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); border-color: var(--border-strong); }

/* ======== Chips (membres, tags) ======== */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 10px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-strong);
    font-size: 0.76rem;
    color: var(--text-primary);
}
.chip form { display: inline; }
.chip button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.72rem;
    padding: 0 2px;
    line-height: 1;
}
.chip button:hover { color: var(--danger); }

/* ======== Modals ======== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    padding: 26px 28px;
    max-width: 600px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    animation: modalIn 0.15s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(6px) scale(0.99); } to { opacity: 1; transform: none; } }

.modal h2 { margin-bottom: 18px; font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ======== Command palette (Ctrl+K) ======== */
.palette-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    z-index: 1500;
    justify-content: center;
    padding-top: 12vh;
}
.palette-overlay.active { display: flex; }

.palette {
    width: 580px;
    max-width: 92%;
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
    animation: modalIn 0.12s ease;
}
.palette-input {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}
.palette-input input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
}
.palette-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    cursor: pointer;
}
.palette-item i { width: 18px; text-align: center; color: var(--text-muted); font-size: 0.84rem; }
.palette-item.active, .palette-item:hover { background: var(--bg-hover); color: #fff; }
.palette-item .palette-section {
    margin-left: auto;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.palette-empty { padding: 22px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* ======== Toast ======== */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 16px;
    border-radius: 10px;
    background: #161616;
    border: 1px solid var(--border-strong);
    border-left-width: 3px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: toastIn 0.2s ease;
    max-width: 400px;
    line-height: 1.4;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--accent); }

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

/* ======== Login Page ======== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(900px 500px at 50% -10%, rgba(139, 124, 255, 0.18), transparent 60%),
        var(--bg-primary);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 400px;
    max-width: 100%;
}

.login-card .logo { justify-content: center; margin-bottom: 28px; font-size: 1.2rem; gap: 10px; }
.login-card .logo i { font-size: 1.2rem; }

.login-card h2 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.5;
}

.login-error {
    background: rgba(239, 65, 70, 0.12);
    border: 1px solid rgba(239, 65, 70, 0.4);
    color: #ff7377;
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.85rem;
}

.login-card .btn { width: 100%; justify-content: center; padding: 11px; font-size: 0.9rem; margin-top: 6px; }

/* ======== Color Preview ======== */
.color-input-group { display: flex; gap: 10px; align-items: center; }
.color-input-group input[type="color"] {
    width: 40px; height: 40px;
    padding: 3px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--bg-input);
    flex-shrink: 0;
}
.color-input-group input[type="text"] { flex: 1; }

/* ======== Avatar / image previews ======== */
.avatar-preview {
    width: 96px; height: 96px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--bg-tertiary);
    object-fit: cover;
    display: block;
}
.avatar-preview.square { border-radius: 16px; }

.profile-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.profile-box {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
}
.profile-box .avatar-preview { width: 64px; height: 64px; flex-shrink: 0; }
.profile-box h4 { font-size: 0.92rem; font-weight: 600; margin-bottom: 2px; }
.profile-box p { font-size: 0.78rem; color: var(--text-muted); }

.image-preview {
    max-width: 100%;
    max-height: 260px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    display: block;
    margin-top: 10px;
    background: var(--bg-tertiary);
}

/* ======== Discord-like previews ======== */
.embed-preview {
    background: #2b2d31;
    border-radius: 6px;
    padding: 14px 16px;
    border-left: 4px solid var(--accent);
    margin-top: 15px;
    color: #dbdee1;
    max-width: 520px;
}
.embed-preview .embed-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; color: #fff; }
.embed-preview .embed-description { font-size: 0.86rem; color: #dbdee1; line-height: 1.5; white-space: pre-wrap; }
.embed-preview .embed-image { margin-top: 12px; max-width: 100%; border-radius: 6px; display: block; }
.embed-preview .embed-footer { margin-top: 10px; font-size: 0.72rem; color: #949ba4; }

.discord-message { display: flex; gap: 14px; padding: 6px 0; }
.discord-message .discord-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--bg-tertiary); }
.discord-message .discord-name { font-weight: 600; font-size: 0.92rem; color: #fff; display: flex; align-items: center; gap: 6px; }
.discord-message .discord-tag { font-size: 0.6rem; background: #5865f2; color: #fff; padding: 1px 5px; border-radius: 3px; font-weight: 600; }
.discord-message .discord-text { color: #dbdee1; font-size: 0.88rem; margin-top: 2px; }

/* ======== Transcript ======== */
.transcript-messages { background: var(--bg-primary); border-radius: var(--radius); border: 1px solid var(--border); }
.transcript-msg { transition: background 0.15s; }
.transcript-msg:hover { background: rgba(255, 255, 255, 0.02); }
.transcript-bot { background: rgba(139, 124, 255, 0.04); }

/* ======== Permission Grid ======== */
.perm-category { margin-bottom: 25px; }
.perm-category h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.perm-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.perm-item-info { display: flex; flex-direction: column; }
.perm-item-info .perm-name { font-weight: 500; font-size: 0.84rem; }
.perm-item-info .perm-desc { font-size: 0.74rem; color: var(--text-muted); }

/* ======== Tag/Chip List (legacy) ======== */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: var(--accent-soft);
    border: 1px solid rgba(139, 124, 255, 0.4);
    border-radius: 999px;
    font-size: 0.78rem;
    color: #b3a8ff;
}
.tag .remove { cursor: pointer; font-size: 0.7rem; opacity: 0.7; }
.tag .remove:hover { opacity: 1; }

/* ======== Empty State ======== */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 1.6rem; margin-bottom: 12px; opacity: 0.6; display: block; }
.empty-state p { font-size: 0.9rem; margin-bottom: 16px; color: var(--text-secondary); }

/* ======== Tabs ======== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 22px;
    overflow-x: auto;
}
.tab {
    padding: 9px 14px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color 0.12s;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: #fff; border-bottom-color: #fff; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ======== Loading ======== */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; }
.spinner {
    width: 28px; height: 28px;
    border: 2px solid var(--border-strong);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ======== Utilities ======== */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: #ff7377; }
.text-success { color: #2fd4a7; }
.text-sm { font-size: 0.8rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

/* ======== Responsive ======== */
@media (max-width: 1100px) {
    .dash-grid { grid-template-columns: 1fr; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric:nth-child(2) { border-right: none; }
    .metric:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}

@media (max-width: 900px) {
    .topbar { display: flex; }
    .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
    .sidebar.open { transform: none; }
    .main-content { margin-left: 0; padding: 72px 18px 40px; }
    .page-header h1 { font-size: 1.5rem; }
    .form-row, .form-row.three { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .hero { padding: 26px 22px; }
    .hero::after { display: none; }
    .card { padding: 18px; }
    .modal { padding: 20px; }
}

@media (max-width: 560px) {
    .metrics { grid-template-columns: 1fr; }
    .metric { border-right: none; border-bottom: 1px solid var(--border); }
    .stats-grid { grid-template-columns: 1fr; }
}

/* Logs : salon dédié par type d'événement */
.toggle-group .log-channel { margin: 0 0 0 auto; width: 240px; flex-shrink: 0; }
.toggle-group .log-channel select { padding-top: 6px; padding-bottom: 6px; font-size: 0.82rem; }
@media (max-width: 640px) {
    .toggle-group.has-channel { flex-wrap: wrap; }
    .toggle-group .log-channel { order: 3; width: 100%; }
}

/* Serveurs : bouton "quitter" (admins) dans le coin de la carte */
.server-tile { position: relative; }
.server-tile > .stat-card { height: 100%; }
.server-tile .server-leave { position: absolute; top: 10px; right: 10px; margin: 0; opacity: 0; transition: opacity 0.15s; }
.server-tile:hover .server-leave, .server-tile .server-leave:focus-within { opacity: 1; }
@media (hover: none) { .server-tile .server-leave { opacity: 1; } }

/* Candidatures : éditeur de questions (texte, cases à cocher, choix unique) */
.q-list { display: flex; flex-direction: column; gap: 10px; }
.q-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--bg-secondary); }
.q-item-head { display: grid; grid-template-columns: 26px 1fr 220px auto auto; gap: 10px; align-items: center; }
.q-item-num { color: var(--text-muted); font-size: 0.8rem; font-weight: 600; text-align: center; }
.q-item-head label.q-required { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 0.82rem; white-space: nowrap; color: var(--text-secondary); }
.q-choices { margin: 10px 0 0 36px; display: grid; grid-template-columns: 1fr 180px; gap: 12px; }
.q-choices textarea { min-height: 96px; }
.q-choices .q-limits { display: flex; flex-direction: column; gap: 8px; }
.q-choices .q-limits input { width: 100%; }
.q-footer { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.answer-box { background: var(--bg-input); padding: 10px 14px; border-radius: var(--radius); margin-top: 4px; color: var(--text-secondary); white-space: pre-wrap; }
@media (max-width: 760px) {
    .q-item-head { grid-template-columns: 26px 1fr; }
    .q-item-head select, .q-item-head .q-required, .q-item-head .q-remove { grid-column: 2; }
    .q-choices { margin-left: 0; grid-template-columns: 1fr; }
}
