:root{
  --bg: #0b1020;
  --panel: rgba(255,255,255,.06);
  --panel2: rgba(255,255,255,.10);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --border: rgba(255,255,255,.14);
  --shadow: 0 18px 60px rgba(0,0,0,.45);
  --radius: 18px;

  --accent: #7c5cff;
  --accent2: #22c55e;

  --danger: #ff4d6d;
  --dangerBg: rgba(255, 77, 109, .12);
  --success: #22c55e;
  --successBg: rgba(34, 197, 94, .12);

  --sidebar-width: 220px;
  --sidebar-bg: rgba(12, 14, 28, 0.92);
}

*{ box-sizing: border-box; }
html,body{ height: 100%; overflow: hidden; }

body{
  margin: 0;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background:
    radial-gradient(1200px 700px at 10% 10%, rgba(124,92,255,.35), transparent 55%),
    radial-gradient(900px 600px at 90% 20%, rgba(34,197,94,.22), transparent 55%),
    radial-gradient(800px 600px at 55% 95%, rgba(255,77,109,.18), transparent 50%),
    linear-gradient(180deg, #070a14, var(--bg));
}

a{
  color: inherit;
  text-decoration: none;
  opacity: .92;
}
a:hover{ opacity: 1; }

/* ===== APP LAYOUT (sidebar + main) ===== */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(16px);
  z-index: 100;
  transition: width 0.2s ease, min-width 0.2s ease;
  overflow: hidden;
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.sidebar-logo {
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.sidebar-logo img {
  height: 40px;
  width: auto;
}

/* Toggle row (above logo) */
.sidebar-toggle-row {
  padding: 8px 12px 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.sidebar-toggle:hover {
  color: #a78bfa;
}
.sidebar-toggle svg {
  transition: transform 0.2s;
}
.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* No transition on initial page load */
.sidebar.no-transition {
  transition: none !important;
}

/* Tooltip on collapsed sidebar links */
.sidebar.collapsed .sidebar-link {
  position: relative;
}
.sidebar.collapsed .sidebar-link::after {
  content: attr(data-label);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 8px;
  background: #1e1f2e;
  color: #e2e8f0;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid rgba(139,92,246,.3);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 200;
}
.sidebar.collapsed .sidebar-link:hover::after {
  opacity: 1;
}

/* Sidebar collapsed */
.sidebar.collapsed {
  width: 52px;
  min-width: 52px;
  overflow: visible;
}
.sidebar.collapsed .sidebar-logo {
  width: 32px;
  height: 32px;
  overflow: hidden;
}
.sidebar.collapsed .sidebar-logo img {
  height: 32px;
  width: auto;
  object-fit: cover;
  object-position: left center;
}
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-section-label {
  display: none;
}
.sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 10px 8px;
}
.sidebar.collapsed .sidebar-toggle-row {
  justify-content: center;
  padding: 8px 4px 0;
}
.sidebar.collapsed .sidebar-nav {
  padding: 8px 4px;
  overflow: visible;
}
.sidebar.collapsed .sidebar-footer {
  padding: 8px 4px;
  overflow: visible;
}

/* Tenant badge */
.tenant-badge {
  position: relative;
  padding: 6px 14px;
  margin: 4px 8px;
  background: rgba(139,92,246,.15);
  border-radius: 8px;
  font-size: 11px;
  color: #8b5cf6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tenant-badge-letter {
  display: none;
}
.tenant-badge-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #8b5cf6;
  padding: 0;
  display: flex;
  align-items: center;
}

/* Collapsed: show only letter icon + tooltip on hover */
.sidebar.collapsed .tenant-badge {
  position: relative;
  padding: 0;
  margin: 4px auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  overflow: visible;
  display: grid;
  place-items: center;
}
.sidebar.collapsed .tenant-badge-letter {
  display: block;
  grid-area: 1 / 1;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  line-height: 32px;
  text-align: center;
}
.sidebar.collapsed .tenant-badge-name,
.sidebar.collapsed .tenant-badge-close {
  display: none;
}
.sidebar.collapsed .tenant-badge::after {
  content: attr(data-label);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 8px;
  background: #1e1f2e;
  color: #e2e8f0;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid rgba(139,92,246,.3);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 200;
}
.sidebar.collapsed .tenant-badge:hover::after {
  opacity: 1;
}

/* Abonnement alert: full vs icon in collapsed mode */
.sidebar.collapsed .abo-alert-full {
  display: none !important;
}
.sidebar.collapsed .abo-alert-icon {
  display: block !important;
}
.abo-alert-icon::after {
  content: attr(data-label);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 10px;
  padding: 6px 10px;
  background: #1e1e2e;
  color: #fbbf24;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 200;
}
.abo-alert-icon:hover::after {
  opacity: 1;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  opacity: 1;
}
.sidebar-link:hover {
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-color: rgba(255,255,255,.08);
  opacity: 1;
}
.sidebar-link svg {
  flex-shrink: 0;
}

/* Active link */
.sidebar-link.active {
  background: rgba(139,92,246,.15);
  color: #a78bfa;
  border-color: rgba(139,92,246,.3);
}
.sidebar-link.active svg {
  color: #8b5cf6;
}

.sidebar-separator {
  height: 1px;
  background: var(--border);
  margin: 8px 4px;
}

.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,.35);
  padding: 6px 12px 4px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-logout {
  color: rgba(239, 68, 68, 0.7);
}
.sidebar-logout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  min-width: 0;
}

/* Scrollbars uniformes sur toute l'app (Firefox + WebKit) */
* { scrollbar-width: thin; scrollbar-color: rgba(139,92,246,.5) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(139,92,246,.4);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,.7); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-corner { background: transparent; }

.page-title {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: -0.5px;
}

.main-card {
  overflow: visible;
}

/* Legacy container (kept for pages not yet migrated) */
.container{
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

/* Topbar (legacy - kept for backward compat) */
.topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}

.brand{
  display:flex;
  align-items:center;
  gap: 12px;
  min-width: 0;
}

.brand-text{
  display:flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}
.brand-text strong{
  font-size: 16px;
  letter-spacing: 0.4px;
}
.brand-text .badge{
  margin-top: 6px;
}

.nav{
  display:flex;
  align-items:center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}
.nav a{
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 14px;
}
.nav a:hover{
  border-color: rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
}

/* Logout button (legacy) */
.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 10px;
  color: rgba(239, 68, 68, 0.8);
  cursor: pointer;
  transition: all 0.15s;
}
.logout-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
  transform: translateY(-1px);
}

/* Main card */
.card{
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

h1{
  margin: 0 0 10px;
  font-size: 26px;
  letter-spacing: -0.6px;
}

.subtitle{
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

/* Badges */
.badge{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.85);
  font-size: 12px;
  white-space: nowrap;
}

/* Alerts */
.alert{
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  margin-bottom: 14px;
}
.alert.error{
  border-color: rgba(255, 77, 109, .35);
  background: var(--dangerBg);
}
.alert.success{
  border-color: rgba(34, 197, 94, .35);
  background: var(--successBg);
}

/* Forms */
.form{
  display: grid;
}

.row{ display:block; }

.label{
  display:block;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}

.input{
  width: 100%;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color: var(--text);
  outline: none;
}
.input:focus{
  border-color: rgba(124,92,255,.55);
  box-shadow: 0 0 0 4px rgba(124,92,255,.12);
}

.actions{
  display:flex;
  gap: 10px;
  align-items:center;
  justify-content: flex-end;
  margin-top: 6px;
}

/* bouton principal */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 10px 18px;
  border-radius: 999px;

  background: linear-gradient(135deg, #7c5cff, #6a4cff);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;

  border: none;
  cursor: pointer;
  white-space: nowrap;

  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.35);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 3px 10px rgba(124, 92, 255, 0.25);
}

.btn:disabled,
.btn.disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Bouton creation uniforme */
.btn-create {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: #e5e7eb;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.14);
  box-shadow: none;
}


/* Tables */
table{
  width: 100%;
  border-collapse: collapse;
}
th{
  text-align:left;
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,.14);
  font-size: 13px;
  color: rgba(255,255,255,.85);
}
td{
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 14px;
}

/* Login page layout */
.login-grid{
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  align-items: center;
  margin-top: 10px;
}

.login-left{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height: 280px;
}

.login-right{
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.03);
  border-radius: 18px;
  padding: 18px;
}

/* Logos (UNIFORMISES) */
.logo-header{
  height: 36px;
  width: auto;
  display:block;
}

.logo-hero{
  height: 210px;
  width: auto;
  max-width: 85%;
  display:block;
}

/* Responsive */
@media (max-width: 900px){
  body{ padding: 0; }
  .sidebar { display: none; }
  .main-content { padding: 10px; }
  .login-grid{ grid-template-columns: 1fr; }
  .login-left{ min-height: unset; padding-top: 6px; }
  .login-right{ padding: 16px; }
  .logo-hero{ height: 140px; }
}

@media (max-width: 520px){
  .logo-header{ height: 34px; }
  .nav a{ padding: 7px 9px; }
}

/* OTP / 2FA */
.otp{
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 0 2px;
}

.otp-box{
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.92);
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  outline: none;
}

.otp-box:focus{
  border-color: rgba(124,92,255,.55);
  box-shadow: 0 0 0 4px rgba(124,92,255,.12);
}

@media (max-width: 520px){
  .otp-box{
    width: 44px;
    height: 48px;
    font-size: 20px;
  }
}

.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: grid;
  place-items: center;
  z-index: 999;
  padding: 18px;
}

.modal{
  width: 100%;
  max-width: 520px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(18, 22, 40, .96);
  box-shadow: 0 22px 70px rgba(0,0,0,.6);
  padding: 16px;
}

/* === Select / options (theme sombre) === */
select.input {
  background: rgba(255,255,255,0.06);
  color: #e6e6eb;
}

/* options du menu deroulant */
select.input option {
  background: #1a1d2b;
  color: #e6e6eb;
}

/* option selectionnee / hover */
select.input option:checked,
select.input option:hover {
  background: #5b4cc4;
  color: #fff;
}

/* input utilise comme select */
.input[list] {
  background: rgba(255,255,255,0.06);
  color: #e6e6eb;
  cursor: text;
}

/* datalist (Chrome/Edge) */
datalist option {
  background: #1a1d2b;
  color: #e6e6eb;
}

/* ===== DASHBOARD ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.dashboard-card {
  border: 1px solid var(--border);
  background: #1e1f2e;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dashboard-card h3 {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.dashboard-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
}
.dashboard-table th {
  font-size: 12px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
}
.dashboard-table td {
  font-size: 13px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

/* ===== Recap table opaque columns ===== */
.tableau-recap th,
.tableau-recap td {
  background-color: #1e1f2e;
}
.tableau-recap thead th {
  background-color: #2a2548;
}
.tableau-recap tfoot td {
  background-color: #1e1f2e;
}
.tableau-recap tbody tr:hover td {
  background-color: rgba(139, 92, 246, 0.15);
}
