@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap");
@import url("./tokens.css");

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--suite-canvas);
  color: var(--suite-ink);
  font-family: var(--suite-font-sans);
}

body {
  background:
    linear-gradient(180deg, #e8eef1 0%, var(--suite-canvas) 180px),
    var(--suite-canvas);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

/* ——— Shell ——— */

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--suite-border);
}

.shell-header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--suite-brand);
  color: var(--suite-on-brand);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand-text {
  min-width: 0;
}

.brand-text strong {
  display: block;
  font-family: var(--suite-font-display);
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-text span {
  display: block;
  font-size: 0.78rem;
  color: var(--suite-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.org-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--suite-border);
  border-radius: 999px;
  background: var(--suite-surface);
  color: var(--suite-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.suite-nav {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}
.suite-nav a {
  padding: 8px 12px;
  border-radius: var(--suite-radius-md, 8px);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--suite-muted);
}
.suite-nav a:hover {
  color: var(--suite-ink);
  background: #eef2f6;
}
.suite-nav a[aria-current="page"] {
  color: var(--suite-brand);
  background: color-mix(in srgb, var(--suite-brand) 10%, white);
}

.org-chip svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.shell-spacer {
  flex: 1;
  min-width: 8px;
}

.search-wrap {
  position: relative;
  width: min(100%, 280px);
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--suite-muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-md);
  background: var(--suite-canvas);
  color: var(--suite-ink);
}

.search-wrap input:focus {
  outline: 2px solid color-mix(in srgb, var(--suite-brand) 35%, transparent);
  outline-offset: 1px;
  border-color: var(--suite-brand);
  background: var(--suite-surface);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--suite-border);
  border-radius: 999px;
  background: var(--suite-surface);
  font-size: 0.8rem;
  color: var(--suite-ink);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--suite-accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-chip .email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip.guest {
  color: var(--suite-muted);
}

.user-chip.guest .user-avatar {
  background: #8a94a3;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--suite-space-2);
  min-height: var(--suite-touch);
  padding: 0 var(--suite-space-4);
  border-radius: var(--suite-radius-md);
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--suite-brand);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--suite-brand);
  color: var(--suite-on-brand);
}

.btn-primary:hover {
  background: var(--suite-brand-pressed);
}

.btn-ghost {
  background: transparent;
  border-color: var(--suite-border);
  color: var(--suite-ink);
}

.btn-ghost:hover {
  background: #eef2f5;
}

.btn-sm {
  min-height: 36px;
  padding: 0 var(--suite-space-3);
  font-size: 0.8rem;
}

.btn-danger {
  background: var(--suite-danger);
  color: var(--suite-on-brand);
}

/* ——— Main ——— */

.main {
  flex: 1;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: var(--suite-space-5) var(--suite-space-5) var(--suite-space-6);
}

.hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.hero-row h1 {
  margin: 0;
  font-family: var(--suite-font-display);
  font-size: clamp(1.35rem, 2vw, 1.65rem);
  letter-spacing: -0.02em;
}

.hero-row p {
  margin: 6px 0 0;
  color: var(--suite-muted);
  font-size: 0.95rem;
  max-width: 40rem;
  line-height: 1.45;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.filter-chip {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--suite-border);
  background: var(--suite-surface);
  color: var(--suite-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-chip:hover {
  border-color: #b8c2ce;
  color: var(--suite-ink);
}

.filter-chip[aria-pressed="true"] {
  background: var(--suite-brand);
  border-color: var(--suite-brand);
  color: var(--suite-on-brand);
}

.filter-chip:focus-visible {
  outline: 2px solid var(--suite-brand);
  outline-offset: 2px;
}

/* ——— Auth panel ——— */

.auth-panel {
  margin-bottom: 24px;
  background: var(--suite-surface);
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-lg);
  padding: var(--suite-space-4);
  box-shadow: var(--suite-shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 24px;
  align-items: end;
}

.auth-panel[hidden] {
  display: none !important;
}

.auth-panel .auth-copy h2 {
  margin: 0;
  font-size: 1rem;
  font-family: var(--suite-font-display);
}

.auth-panel .auth-copy p {
  margin: 4px 0 0;
  color: var(--suite-muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.auth-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.auth-fields label {
  display: block;
  font-size: 0.72rem;
  color: var(--suite-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.auth-fields input {
  min-height: 40px;
  min-width: 180px;
  padding: 0 12px;
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-md);
  background: var(--suite-canvas);
}

.auth-fields input:focus {
  outline: 2px solid color-mix(in srgb, var(--suite-brand) 35%, transparent);
  outline-offset: 1px;
  border-color: var(--suite-brand);
}

.auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.err {
  color: var(--suite-danger);
  font-size: 0.85rem;
  margin: 0;
  grid-column: 1 / -1;
}

.hint {
  margin: 0 0 20px;
  padding: 10px 14px;
  background: #e8f1f3;
  border-radius: var(--suite-radius-md);
  color: var(--suite-brand);
  font-size: 0.88rem;
  line-height: 1.4;
}

.hint .mono {
  font-family: var(--suite-font-mono);
  font-size: 0.9em;
}

/* ——— App grid / cards ——— */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.grid-empty {
  grid-column: 1 / -1;
  padding: 40px 16px;
  text-align: center;
  color: var(--suite-muted);
  border: 1px dashed var(--suite-border);
  border-radius: var(--suite-radius-lg);
  background: rgba(255, 255, 255, 0.5);
}

.app-card {
  /* chrome (icone / badge / CTA) = brand module ; rail gauche = accent signature */
  --accent: var(--suite-brand);
  --rail: var(--accent);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, white);
  position: relative;
  display: flex;
  flex-direction: column;
  /* Grille égale : pad space-4 + hauteur mini commune (POS/GED inclus) */
  min-height: 248px;
  padding: var(--suite-space-4);
  background: var(--suite-surface);
  border: 1px solid var(--suite-border);
  /* DS Tile / DESIGN.md : bordure gauche = accent module (pas le border générique) */
  border-left: 4px solid var(--rail);
  border-radius: var(--suite-radius-md);
  box-shadow: var(--suite-shadow);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
  overflow: hidden;
}

.app-card:hover,
.app-card:focus-within {
  transform: translateY(-2px);
  /* Ombre uniquement token — interdit 10px/24px hors DS */
  box-shadow: var(--suite-shadow);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--suite-border));
  border-left-color: var(--rail);
}

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

.app-card[data-accent="crm"] {
  --accent: var(--suite-mod-crm); /* Teal */
  --rail: var(--suite-mod-crm);
}
.app-card[data-accent="pos"] {
  --accent: var(--suite-mod-pos); /* Braise */
  --rail: var(--suite-mod-pos);
}
.app-card[data-accent="stock"] {
  --accent: var(--suite-mod-stock);
  --rail: var(--suite-mod-stock-accent); /* Menthe */
}
.app-card[data-accent="rh"] {
  --accent: var(--suite-mod-rh);
  --rail: var(--suite-mod-rh-accent); /* Acier-sauge */
}
.app-card[data-accent="ged"] {
  --accent: var(--suite-mod-ged);
  --rail: var(--suite-mod-ged-accent); /* Encre / liasse */
}
.app-card[data-accent="ged"] .app-icon {
  color: var(--suite-mod-ged);
  background: color-mix(in srgb, var(--suite-mod-ged-accent) 22%, white);
}
.app-card[data-accent="gmao"] {
  --accent: var(--suite-mod-gmao);
  --rail: var(--suite-mod-gmao-accent); /* Atelier (ambre) */
}
.app-card[data-accent="gmao"] .app-icon {
  color: var(--suite-mod-gmao);
  background: color-mix(in srgb, var(--suite-mod-gmao-accent) 22%, white);
}
.app-card[data-accent="chat"] {
  --accent: var(--suite-mod-chat);
  --rail: var(--suite-mod-chat-accent); /* Fil & relais */
}
.app-card[data-accent="chat"] .app-icon {
  color: var(--suite-mod-chat);
  background: color-mix(in srgb, var(--suite-mod-chat-accent) 22%, white);
}

.app-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.app-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.app-icon svg {
  width: 26px;
  height: 26px;
  stroke-width: 1.75;
}

.app-card[data-accent="pos"] .app-icon {
  background: var(--suite-mod-pos-soft);
}

.app-card[data-accent="stock"] .app-icon {
  color: var(--suite-mod-stock);
  background: color-mix(in srgb, var(--suite-mod-stock-accent) 22%, white);
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 6px;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-card h2 {
  margin: 0 0 6px;
  font-size: 1.12rem;
  font-family: var(--suite-font-display);
  letter-spacing: -0.01em;
}

.app-card .desc {
  margin: 0;
  flex: 1;
  color: var(--suite-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  /* Hauteurs homogènes → CTA Ouvrir/Fiche alignés dans la grille */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  min-height: calc(1.45em * 3);
}

.surface-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.surface-chip {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--suite-border));
}

.surface-chip svg {
  width: 14px;
  height: 14px;
}

.app-card-actions {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.app-card-actions a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--suite-radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.app-card-actions a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-card-actions .open {
  background: var(--accent);
  color: #fff;
}

.app-card-actions .open:hover {
  filter: brightness(0.92);
}

.app-card-actions .meta {
  border: 1px solid var(--suite-border);
  color: var(--suite-ink);
  background: transparent;
  font-weight: 500;
  opacity: 0.9;
}

.app-card-actions .meta:hover {
  background: #eef2f5;
}

.app-card-actions .open svg,
.app-card-actions .meta svg {
  width: 14px;
  height: 14px;
}

/* ——— Footer ——— */

.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px 32px;
  font-size: 0.8rem;
  color: var(--suite-muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.mono {
  font-family: var(--suite-font-mono);
  font-size: 0.85em;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--suite-muted);
  font-size: 0.85rem;
}

.back-link:hover {
  color: var(--suite-brand);
}

.back-link svg {
  width: 14px;
  height: 14px;
}

@media (max-width: 720px) {
  .shell-header-inner {
    padding: 12px 16px;
  }

  .main {
    padding: 20px 16px 40px;
  }

  .search-wrap {
    width: 100%;
    order: 5;
  }

  .auth-panel {
    grid-template-columns: 1fr;
  }

  .auth-fields input {
    min-width: 0;
    width: 100%;
  }

  .auth-fields > div {
    flex: 1 1 100%;
  }
}

/* ——— CGU / legal ——— */

.legal-main {
  max-width: 720px;
}

.legal-doc {
  background: var(--suite-surface);
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-lg, 12px);
  padding: 28px 32px 36px;
  box-shadow: var(--suite-shadow);
}

.legal-eyebrow {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--suite-muted);
}

.legal-doc h1 {
  margin: 0 0 12px;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.legal-lead {
  margin: 0 0 28px;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--suite-ink);
}

.legal-doc h2 {
  margin: 24px 0 8px;
  font-size: 1.05rem;
}

.legal-doc p,
.legal-doc li {
  margin: 0 0 10px;
  line-height: 1.55;
  color: var(--suite-ink);
  font-size: 0.95rem;
}

.legal-doc ul {
  margin: 0 0 12px;
  padding-left: 1.25rem;
}

.legal-doc a {
  color: var(--suite-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer a {
  color: var(--suite-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.legal-meta {
  margin-top: 28px !important;
  padding-top: 16px;
  border-top: 1px solid var(--suite-border);
  font-size: 0.8rem !important;
  color: var(--suite-muted) !important;
}

.demo-reset-hint {
  margin: 10px 0 0;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--suite-muted);
}

.demo-reset-hint a {
  color: var(--suite-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.demo-cgu-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 90;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--suite-border);
  border-left: 4px solid var(--suite-brand);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
  font-size: 0.82rem;
  color: var(--suite-ink);
}

.demo-cgu-banner-text {
  flex: 1 1 240px;
  margin: 0;
  line-height: 1.45;
  color: var(--suite-muted);
}

.demo-cgu-banner-text strong {
  color: var(--suite-ink);
  font-weight: 600;
}

.demo-cgu-banner-text a {
  color: var(--suite-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.demo-cgu-banner-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.demo-cgu-banner-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--suite-brand);
}

.demo-cgu-login {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--suite-muted);
  cursor: pointer;
}

.demo-cgu-login input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--suite-brand);
  flex-shrink: 0;
}

.demo-cgu-login a {
  color: var(--suite-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}
