/* Ticket-Master Dashboard — theme sombre */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-darkest: #1e1f22;
  --bg-dark: #2b2d31;
  --bg-mid: #313338;
  --bg-light: #383a40;
  --bg-hover: #404249;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #23a559;
  --danger: #da373c;
  --warning: #f0b232;
  --text: #dbdee1;
  --text-muted: #949ba4;
  --text-bright: #ffffff;
  --border: #3f4147;
  --radius: 8px;
}

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-darkest);
  color: var(--text);
  min-height: 100vh;
}

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

.loading-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100vh; gap: 16px; color: var(--text-muted);
}
.spinner {
  width: 40px; height: 40px; border: 4px solid var(--bg-light);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; background: var(--bg-dark); padding: 16px 8px;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .server-name {
  padding: 8px 12px 16px; font-weight: 700; font-size: 1.05em; color: var(--text-bright);
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}
.sidebar .server-name img { width: 32px; height: 32px; border-radius: 50%; }
.nav-section { margin-bottom: 8px; }
.nav-section-title {
  padding: 8px 12px 4px; font-size: 0.72em; font-weight: 700;
  text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-radius: 6px; color: var(--text-muted); cursor: pointer;
  font-size: 0.95em; margin-bottom: 2px; user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--bg-light); color: var(--text-bright); }
.nav-item .icon { width: 20px; text-align: center; }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  font-size: 0.9em; color: var(--text-muted);
}
.user-chip img { width: 28px; height: 28px; border-radius: 50%; }
.user-chip .logout { margin-left: auto; cursor: pointer; color: var(--text-muted); font-size: 1.1em; }
.user-chip .logout:hover { color: var(--danger); }

.main { flex: 1; padding: 28px 36px; max-width: 1100px; }
.page-header { margin-bottom: 24px; }
.page-header h1 { color: var(--text-bright); font-size: 1.5em; margin-bottom: 4px; }
.page-header p { color: var(--text-muted); font-size: 0.95em; }

/* ---------- Login / selecteur ---------- */
.center-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 20px; padding: 24px;
}
.login-card {
  background: var(--bg-mid); border-radius: var(--radius); padding: 48px;
  text-align: center; max-width: 420px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.login-card h1 { color: var(--text-bright); margin-bottom: 8px; font-size: 1.6em; }
.login-card p { color: var(--text-muted); margin-bottom: 28px; }
.btn-discord {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--accent); color: #fff; padding: 12px 28px;
  border-radius: 6px; font-weight: 600; font-size: 1em; border: none; cursor: pointer;
}
.btn-discord:hover { background: var(--accent-hover); text-decoration: none; }

.server-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; width: 100%; max-width: 800px;
}
.server-card {
  background: var(--bg-mid); border-radius: var(--radius); padding: 24px;
  text-align: center; cursor: pointer; transition: background 0.15s, transform 0.1s;
  border: 1px solid transparent;
}
.server-card:hover { background: var(--bg-light); border-color: var(--accent); transform: translateY(-2px); }
.server-card img, .server-card .server-icon-placeholder {
  width: 64px; height: 64px; border-radius: 50%; margin-bottom: 12px;
}
.server-icon-placeholder {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-light); font-size: 1.5em; font-weight: 700; color: var(--text-bright);
}
.server-card h3 { color: var(--text-bright); font-size: 1em; }
.server-card-invite { cursor: default; opacity: 0.85; }
.server-card-invite:hover { transform: none; border-color: var(--bg-light); }
.server-card-invite .btn { margin-top: 4px; }

/* ---------- Cartes & tableaux ---------- */
.card {
  background: var(--bg-mid); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
}
.card h2 { color: var(--text-bright); font-size: 1.1em; margin-bottom: 4px; }
.card .card-sub { color: var(--text-muted); font-size: 0.88em; margin-bottom: 16px; }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-mid); border-radius: var(--radius); padding: 18px;
}
.stat-card .stat-value { font-size: 1.9em; font-weight: 700; color: var(--text-bright); }
.stat-card .stat-label { color: var(--text-muted); font-size: 0.85em; margin-top: 2px; }

table.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 8px 12px; font-size: 0.75em; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid var(--border); letter-spacing: 0.5px;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--bg-dark); font-size: 0.92em; }
.data-table tr:hover td { background: var(--bg-dark); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 2.5em; margin-bottom: 8px; }

/* ---------- Formulaires ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 0.85em; font-weight: 600; color: var(--text);
  margin-bottom: 6px;
}
.field .hint { font-size: 0.78em; color: var(--text-muted); margin-top: 4px; }
input[type="text"], input[type="number"], input[type="url"], input[type="time"], select, textarea {
  width: 100%; padding: 9px 12px; background: var(--bg-darkest);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text);
  font-size: 0.92em; font-family: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
input[type="color"] {
  width: 48px; height: 34px; padding: 2px; background: var(--bg-darkest);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.checkbox-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px;
  border-radius: 6px; font-weight: 600; font-size: 0.9em; border: none;
  cursor: pointer; color: #fff; background: var(--accent);
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--bg-light); color: var(--text); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 5px 12px; font-size: 0.82em; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 0.78em; font-weight: 600;
}
.badge-open { background: rgba(35,165,89,0.2); color: var(--success); }
.badge-closed { background: rgba(218,55,60,0.15); color: var(--danger); }
.badge-claimed { background: rgba(88,101,242,0.2); color: var(--accent); }
.badge-muted { background: var(--bg-light); color: var(--text-muted); }
.stars { color: var(--warning); }

/* ---------- Onglets panel editor ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; cursor: pointer; color: var(--text-muted); font-size: 0.92em;
  border-bottom: 2px solid transparent; user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text-bright); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Preview embed Discord ---------- */
.discord-preview {
  background: var(--bg-darkest); border-radius: var(--radius); padding: 16px;
}
.discord-embed {
  background: var(--bg-dark); border-radius: 4px; padding: 14px 16px;
  border-left: 4px solid var(--accent); max-width: 460px;
}
.discord-embed .embed-title { color: var(--text-bright); font-weight: 700; margin-bottom: 6px; }
.discord-embed .embed-desc { color: var(--text); font-size: 0.9em; white-space: pre-wrap; }
.discord-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  padding: 8px 16px; border-radius: 4px; color: #fff; font-size: 0.88em; font-weight: 500;
}
.preview-label { font-size: 0.75em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.5px; }

/* ---------- Graphique barres ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding: 8px 0; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-chart .bar {
  width: 100%; max-width: 48px; background: var(--accent); border-radius: 4px 4px 0 0;
  min-height: 2px; transition: height 0.3s;
}
.bar-chart .bar-label { font-size: 0.7em; color: var(--text-muted); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--bg-mid); border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.modal h2 { color: var(--text-bright); margin-bottom: 16px; font-size: 1.15em; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Toast ---------- */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-dark); border-left: 4px solid var(--success); border-radius: 6px;
  padding: 12px 20px; color: var(--text); box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: slide-in 0.2s ease-out; max-width: 360px; font-size: 0.92em;
}
.toast.error { border-left-color: var(--danger); }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Divers ---------- */
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--bg-light);
  border-radius: 6px; padding: 4px 10px; margin: 3px; font-size: 0.85em;
}
.tag-chip .remove { cursor: pointer; color: var(--text-muted); font-weight: 700; }
.tag-chip .remove:hover { color: var(--danger); }
.multi-select-box {
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg-darkest);
  max-height: 180px; overflow-y: auto; padding: 4px;
}
.multi-select-box .ms-option {
  padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 0.9em;
  display: flex; align-items: center; gap: 8px;
}
.multi-select-box .ms-option:hover { background: var(--bg-hover); }
.multi-select-box .ms-option.selected { background: rgba(88,101,242,0.25); }
.ms-option input { accent-color: var(--accent); }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.hour-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.hour-day { background: var(--bg-darkest); border-radius: 6px; padding: 10px; }
.hour-day .day-name { font-size: 0.8em; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; }
.hour-day input[type="time"] { padding: 4px 6px; font-size: 0.85em; margin-bottom: 4px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.text-muted { color: var(--text-muted); }
.mt { margin-top: 16px; }
.code { font-family: monospace; background: var(--bg-darkest); padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }

/* ---------- Administration ---------- */
.guild-icon-sm { width: 28px; height: 28px; border-radius: 8px; object-fit: cover; font-size: 0.7em; }
.guild-cell { display: flex; align-items: center; gap: 10px; }
.user-row:hover td { background: var(--bg-dark); }
.premium-badge { color: #f5c518; }
.badge-premium { background: rgba(245, 197, 24, 0.15); color: #f5c518; padding: 2px 8px; border-radius: 10px; font-size: 0.8em; font-weight: 600; white-space: nowrap; }
.badge-expired { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); padding: 2px 8px; border-radius: 10px; font-size: 0.8em; white-space: nowrap; }

/* ---------- Menu départements ---------- */
.dept-card { background: var(--bg-darkest); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.dept-row-head { display: grid; grid-template-columns: 1fr 110px auto; gap: 12px; align-items: end; }
.dept-row-sub { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 12px; }
.dept-actions { display: flex; gap: 6px; }
.discord-select {
  background: var(--bg-dark); border: 1px solid var(--border); border-radius: 4px;
  padding: 9px 12px; margin-top: 10px; color: var(--text-muted); font-size: 0.88em;
  display: flex; justify-content: space-between; max-width: 460px;
}

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .main { padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .dept-row-head, .dept-row-sub { grid-template-columns: 1fr; }
}

/* Banniere d'avertissement permissions du bot */
.perm-banner {
  background: rgba(240, 178, 50, 0.12);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.92em;
  line-height: 1.5;
}
.perm-banner strong { color: var(--warning); }
.perm-banner .perm-list { font-weight: 600; color: var(--text-bright); }
