/* Design system aligné sur le CRM La Warroom (shadcn/ui, thème slate).
   Les tokens ci-dessous sont ceux de app/globals.css du CRM. */

@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;
    --primary: 222.2 47.4% 11.2%;
    --primary-foreground: 210 40% 98%;
    --secondary: 210 40% 96.1%;
    --secondary-foreground: 222.2 47.4% 11.2%;
    --muted: 210 40% 96.1%;
    --muted-foreground: 215.4 16.3% 46.9%;
    --accent: 210 40% 96.1%;
    --accent-foreground: 222.2 47.4% 11.2%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 210 40% 98%;
    --success: 142.1 76.2% 36.3%;
    --warning: 32.1 94.6% 43.7%;
    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 222.2 84% 4.9%;
    --radius: 0.5rem;
  }

  .dark {
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;
    --card: 222.2 84% 4.9%;
    --card-foreground: 210 40% 98%;
    --primary: 210 40% 98%;
    --primary-foreground: 222.2 47.4% 11.2%;
    --secondary: 217.2 32.6% 17.5%;
    --secondary-foreground: 210 40% 98%;
    --muted: 217.2 32.6% 17.5%;
    --muted-foreground: 215 20.2% 65.1%;
    --accent: 217.2 32.6% 17.5%;
    --accent-foreground: 210 40% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 210 40% 98%;
    --success: 142.1 70.6% 45.3%;
    --warning: 32.1 94.6% 43.7%;
    --border: 217.2 32.6% 17.5%;
    --input: 217.2 32.6% 17.5%;
    --ring: 212.7 26.8% 83.9%;
  }
}

* {
  box-sizing: border-box;
  border-color: hsl(var(--border));
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'rlig' 1, 'calt' 1;
}

.hidden {
  display: none !important;
}

svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* ------------------------------- login ---------------------------------- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: hsl(var(--muted) / 0.2);
}

.auth .card {
  width: 100%;
  max-width: 24rem;
}

/* En-tête de connexion : logo centré au-dessus du titre. */
.auth-header {
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.auth-header .logo {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: calc(var(--radius) + 2px);
  margin-bottom: 0.25rem;
}

/* -------------------------------- shell --------------------------------- */

.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: none;
  width: 15rem;
  flex-direction: column;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--background));
}

@media (min-width: 768px) {
  .sidebar {
    display: flex;
  }
}

.sidebar-head {
  display: flex;
  height: 4rem;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid hsl(var(--border));
  padding: 0 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}

.nav-group {
  padding: 0 0.75rem 0.25rem;
  margin-top: 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
}

.nav-group:first-child {
  margin-top: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  user-select: none;
}

.nav-link:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.nav-link.active {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.sidebar-foot {
  border-top: 1px solid hsl(var(--border));
  padding: 0.625rem 1rem;
  font-size: 10px;
  line-height: 1.3;
  color: hsl(var(--muted-foreground));
}

.content {
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  height: 4rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  padding: 0 1.5rem;
}

.topbar .who {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.875rem;
}

.avatar {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 600;
}

main {
  flex: 1;
  overflow: auto;
  background: hsl(var(--muted) / 0.2);
  padding: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
}

/* -------------------------------- card ---------------------------------- */

.card {
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 1.5rem;
}

.card-header.row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  margin: 0;
}

.card-desc {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin: 0;
}

.card-content {
  padding: 1.5rem;
  padding-top: 0;
}

.card-content.tight {
  padding: 1rem;
}

/* -------------------------------- grid ---------------------------------- */

.grid {
  display: grid;
  gap: 1rem;
}

.grid.gap-6 {
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .grid.md-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid.md-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid.lg-2 {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* -------------------------------- stat ---------------------------------- */

.stat {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius);
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

.stat-label {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin: 0;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0.125rem 0 0;
}

/* ------------------------------- meter ---------------------------------- */

.meter {
  height: 0.5rem;
  width: 100%;
  overflow: hidden;
  border-radius: 9999px;
  background: hsl(var(--secondary));
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: 9999px;
  background: hsl(var(--primary));
  transition: width 0.3s;
}

.meter > span.warn {
  background: hsl(var(--warning));
}

.meter > span.over {
  background: hsl(var(--destructive));
}

/* ------------------------------- forms ---------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label.lbl,
.field > span {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
}

input,
select {
  display: flex;
  height: 2.5rem;
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
}

input::placeholder {
  color: hsl(var(--muted-foreground));
}

input:focus-visible,
select:focus-visible {
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}

input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .form-grid.cols-4 {
    grid-template-columns: 2fr 1.4fr 1fr auto;
    align-items: end;
  }
}

.help {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.help b {
  color: hsl(var(--foreground));
  font-weight: 600;
}

.help.danger {
  color: hsl(var(--destructive));
}

/* ------------------------------ buttons --------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  height: 2.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, opacity 0.15s;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn:hover {
  opacity: 0.9;
}

.btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.btn.outline {
  border-color: hsl(var(--input));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}

.btn.outline:hover,
.btn.ghost:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  opacity: 1;
}

.btn.ghost {
  background: transparent;
  color: hsl(var(--foreground));
}

.btn.destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn.sm {
  height: 2.25rem;
  padding: 0 0.75rem;
}

.btn.icon {
  height: 2.25rem;
  width: 2.25rem;
  padding: 0;
}

.btn.full {
  width: 100%;
}

/* --------------------- sélecteur de service (bulles) --------------------- */

.service-picker {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
}

.service-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.service-bubble:hover {
  background: hsl(var(--accent));
}

.service-bubble.selected {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 1px hsl(var(--primary));
}

.service-bubble .bubble-logo {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  background: hsl(var(--muted));
  transition: background-color 0.15s;
}

.service-bubble.selected .bubble-logo {
  background: hsl(var(--secondary));
}

.service-bubble .bubble-logo svg {
  width: 1.375rem;
  height: 1.375rem;
}

.bubble-label {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
}

.bubble-price {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* ------------------------------- table ---------------------------------- */

.table-wrap {
  position: relative;
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead tr {
  border-bottom: 1px solid hsl(var(--border));
}

th {
  height: 2.75rem;
  padding: 0.5rem;
  text-align: left;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid hsl(var(--border));
  transition: background-color 0.15s;
}

tbody tr:last-child {
  border-bottom: 0;
}

tbody tr:hover {
  background: hsl(var(--muted) / 0.5);
}

td {
  padding: 0.5rem;
  vertical-align: middle;
}

td.nowrap,
th.nowrap {
  white-space: nowrap;
}

.num {
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 2rem 0.5rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
}

.link {
  color: hsl(var(--foreground));
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link:hover {
  color: hsl(var(--muted-foreground));
}

/* ------------------------------- badge ---------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  border: 1px solid transparent;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.default {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.badge.secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.badge.destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.badge.success {
  background: hsl(var(--success));
  color: hsl(0 0% 100%);
}

.badge.warning {
  background: hsl(var(--warning));
  color: hsl(0 0% 100%);
}

.badge.outline {
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

/* ------------------------------- toaster -------------------------------- */

.toaster {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(24rem, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
  animation: toast-in 0.15s ease-out;
}

.toast.success {
  border-color: hsl(var(--success) / 0.5);
  color: hsl(var(--success));
}

.toast.error {
  border-color: hsl(var(--destructive) / 0.5);
  color: hsl(var(--destructive));
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(0.5rem);
  }
}

/* ------------------------------- dialog --------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgb(0 0 0 / 0.5);
}

.dialog {
  width: 100%;
  max-width: 26rem;
}

/* Pastille de logo dans le tableau des services (admin). */
.row-brand {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: hsl(var(--muted));
}

.row-brand svg {
  width: 1rem;
  height: 1rem;
}
