:root {
  --bg: #0b0f1a;
  --bg-2: #101728;
  --panel: #141b2e;
  --panel-2: #1a2338;
  --border: #253049;
  --text: #e8edf7;
  --muted: #8b96ad;
  --accent: #6c7bff;
  --accent-2: #a06bff;
  --green: #2dd4a7;
  --amber: #f5b84b;
  --red: #ff5d73;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #16203c 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Splash ---------- */
.splash {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  animation: fadein 1s ease;
}
.logo-mark {
  width: 92px; height: 92px;
  border-radius: 24px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 0 60px rgba(108, 123, 255, .45), 0 18px 40px rgba(0, 0, 0, .5);
  margin-bottom: 26px;
}
.logo-mark svg { width: 46px; height: 46px; }
.logo-mark.small { width: 52px; height: 52px; border-radius: 14px; margin: 0 12px 0 0; }
.logo-mark.small svg { width: 26px; height: 26px; }

.splash-title { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.splash-sub { color: var(--accent); font-weight: 700; font-size: 1.15rem; margin-top: 4px; }

.loader { display: flex; gap: 8px; margin: 34px 0 18px; }
.loader span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.1s infinite ease-in-out;
}
.loader span:nth-child(2) { animation-delay: .15s; background: var(--accent-2); }
.loader span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-14px); opacity: 1; }
}
.splash-note { color: var(--muted); font-size: .92rem; }

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Background orbs ---------- */
.bg-orbs { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.bg-orbs span { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .35; }
.bg-orbs span:nth-child(1) { width: 420px; height: 420px; background: #4a5fd9; top: -120px; left: -80px; }
.bg-orbs span:nth-child(2) { width: 380px; height: 380px; background: #7a3dd4; bottom: -120px; right: -60px; }
.bg-orbs span:nth-child(3) { width: 300px; height: 300px; background: #2d8fa0; top: 40%; left: 55%; opacity: .2; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; z-index: 1;
}
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%; max-width: 430px;
  animation: rise .7s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }

.login-title { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.login-sub { color: var(--accent); font-weight: 600; font-size: .98rem; }
.login-hint {
  margin: 16px 0 22px;
  padding: 12px 14px;
  background: rgba(108, 123, 255, .1);
  border: 1px solid rgba(108, 123, 255, .28);
  border-radius: 10px;
  color: #c6cffd; font-size: .88rem; line-height: 1.5;
}
.login-foot { margin-top: 24px; color: var(--muted); font-size: .78rem; text-align: center; }

/* ---------- Forms ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field span { font-size: .8rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field.grow { flex: 1; }

input, textarea, select, .input, .select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
  outline: none;
  transition: border .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus, .input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 123, 255, .22);
}
textarea { resize: vertical; min-height: 90px; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > .field { min-width: 180px; }
.form-foot { display: flex; justify-content: flex-end; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: none; border-radius: 10px;
  font-family: inherit; font-size: .92rem; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s, box-shadow .15s, background .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 20px rgba(108, 123, 255, .35);
}
.btn-primary:hover { box-shadow: 0 8px 26px rgba(108, 123, 255, .5); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: rgba(255, 93, 115, .12); border: 1px solid rgba(255, 93, 115, .4); color: var(--red); }
.btn-danger:hover { background: rgba(255, 93, 115, .22); }
.btn-sm { padding: 7px 12px; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: 13px 26px; font-size: .98rem; }
.btn-block { width: 100%; }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: .9rem;
  border: 1px solid;
}
.alert-success { background: rgba(45, 212, 167, .1); border-color: rgba(45, 212, 167, .4); color: var(--green); }
.alert-error { background: rgba(255, 93, 115, .1); border-color: rgba(255, 93, 115, .4); color: var(--red); }
.alert-info { background: rgba(108, 123, 255, .1); border-color: rgba(108, 123, 255, .4); color: #c6cffd; }

/* ---------- App layout ---------- */
.app-body { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0;
  background: rgba(16, 23, 40, .92);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; padding: 0 8px 22px; }
.brand-name { font-weight: 800; font-size: 1.05rem; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none;
  font-weight: 600; font-size: .92rem;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(108,123,255,.18), rgba(160,107,255,.14));
  color: #c6cffd;
  border: 1px solid rgba(108,123,255,.25);
}
.nav-ico { font-size: 1.05rem; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.chip-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 1rem;
}
.chip-meta { display: flex; flex-direction: column; line-height: 1.3; }
.chip-meta span { color: var(--muted); font-size: .76rem; }

.main { flex: 1; padding: 32px 40px; max-width: 1200px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.page-sub { color: var(--muted); font-size: .92rem; margin-top: 4px; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-num { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.accent-nouveau .stat-num { color: var(--amber); }
.accent-cours .stat-num { color: var(--accent); }
.accent-resolu .stat-num { color: var(--green); }
.accent-users .stat-num { color: var(--accent-2); }

/* ---------- Panels & tables ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 22px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 16px; }
.panel-head .panel-title { margin-bottom: 0; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.table td { padding: 13px 12px; border-bottom: 1px solid rgba(37, 48, 73, .5); font-size: .9rem; vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: rgba(108, 123, 255, .05); }
.row-unseen { background: rgba(245, 184, 75, .06); }
.mono { font-family: ui-monospace, monospace; color: var(--muted); }
.muted { color: var(--muted); font-size: .84rem; }
.ta-r { text-align: right; }
.ta-c { text-align: center; }
.t-title { font-weight: 600; }
.row-actions { text-align: right; }
.row-actions .inline { display: inline-flex; gap: 6px; margin-left: 6px; }

.inline { display: inline-flex; gap: 8px; align-items: center; }
.inline .select { width: auto; }
.inline .btn { flex-shrink: 0; }

/* ---------- Chips & pills ---------- */
.chip {
  padding: 4px 10px; border-radius: 20px;
  font-size: .74rem; font-weight: 700; text-transform: capitalize;
}
.cat-film { background: rgba(108, 123, 255, .16); color: #aeb8ff; }
.cat-serie { background: rgba(160, 107, 255, .16); color: #d0b0ff; }
.cat-application { background: rgba(45, 212, 167, .14); color: #6fe8c6; }
.cat-autre { background: rgba(139, 150, 173, .16); color: var(--muted); }

.pill { padding: 4px 11px; border-radius: 20px; font-size: .74rem; font-weight: 700; }
.pill-new { background: rgba(245, 184, 75, .15); color: var(--amber); }
.pill-cours { background: rgba(108, 123, 255, .16); color: #aeb8ff; }
.pill-resolu { background: rgba(45, 212, 167, .15); color: var(--green); }

.badge {
  padding: 5px 12px; border-radius: 20px;
  font-size: .76rem; font-weight: 700;
}
.badge-new { background: rgba(245, 184, 75, .15); color: var(--amber); border: 1px solid rgba(245, 184, 75, .3); }

/* ---------- Ticket detail ---------- */
.back-link { color: var(--muted); text-decoration: none; font-size: .88rem; display: inline-block; margin-bottom: 16px; }
.back-link:hover { color: var(--accent); }
.ticket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.ticket-meta-line { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.ticket-actions { display: flex; gap: 10px; }
.ticket-desc {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  line-height: 1.65;
  white-space: pre-wrap;
}

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.bubble {
  max-width: 76%;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  align-self: flex-start;
}
.bubble-admin, .bubble-mine {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(108,123,255,.16), rgba(160,107,255,.12));
  border-color: rgba(108, 123, 255, .3);
}
.bubble-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 5px; font-size: .8rem; }
.bubble-body { line-height: 1.55; font-size: .92rem; white-space: pre-wrap; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; }
.chat-form textarea { flex: 1; }

/* ---------- Misc ---------- */
.empty {
  text-align: center; color: var(--muted);
  padding: 34px 16px; border: 1px dashed var(--border);
  border-radius: 10px; font-size: .92rem;
}
.error-code { font-size: 4rem; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-msg { color: var(--muted); margin: 8px 0 24px; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .app-body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 14px; }
  .sidebar-brand { padding: 0; }
  .sidebar-nav { flex-direction: row; justify-content: center; }
  .sidebar-foot { display: none; }
  .main { padding: 22px; }
  .form-row { flex-direction: column; }
  .bubble { max-width: 92%; }
}
