/*
 * Portail ILC SaaS (index.html) — charte ILC Pro.
 * Chargé après design-system/ilc-unified.css et design-system/ilc-pro.css :
 * mêmes jetons --ux-* (clair / sombre) que les applications.
 * Remplace ilc-ecosystem.css (halos, orbites, néons), qui n'est plus chargé.
 */

html:has(body.ilc-pro-portal) {
  background: var(--ux-bg) !important;
  color-scheme: dark;
  scroll-behavior: smooth;
}
html[data-theme="light"]:has(body.ilc-pro-portal) { color-scheme: light; }

:root:not(#ilc-a):not(#ilc-b) body.ilc-pro-portal {
  --portal-w: 1180px;

  margin: 0;
  padding: var(--ilc-corporate-bar-height) 0 0 !important;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 520px at 50% -160px, var(--ux-brand-soft), transparent 70%),
    var(--ux-bg) !important;
  color: var(--ux-text) !important;
  font-family: var(--ux-font) !important;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;

  &::before { display: none !important; }
  &::after {
    height: var(--ilc-corporate-bar-height) !important;
    background: #04450a !important;
    color: rgba(255, 255, 255, .86) !important;
    font: 600 11.5px/1 var(--ux-font) !important;
    letter-spacing: .02em !important;
    box-shadow: none !important;
  }
  & .portal-background { display: none !important; }
  & :focus-visible { outline: 2px solid var(--ux-brand) !important; outline-offset: 3px !important; }
  & ::selection { background: var(--ux-brand); color: var(--ux-brand-ink); }
  & :is(h1, h2, h3) { font-family: var(--ux-font) !important; }

  /* ---------- En-tête ---------- */
  & .portal-header {
    position: sticky;
    top: var(--ilc-corporate-bar-height);
    z-index: 50;
    border-bottom: 1px solid var(--ux-border);
    background: color-mix(in srgb, var(--ux-bg) 82%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  & .portal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: min(var(--portal-w), 100% - 40px);
    min-height: 64px;
    margin: 0 auto;
  }
  & .portal-brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: inherit; text-decoration: none; }
  & .portal-brand img {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    padding: 4px;
    border: 1px solid var(--ux-border);
    border-radius: 10px;
    background: #fff;
    object-fit: contain;
  }
  & .portal-brand-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
  & .portal-brand-copy strong { color: var(--ux-text); font-size: 15px; font-weight: 700; line-height: 1.2; }
  & .portal-brand-copy small { color: var(--ux-muted); font-size: 12px; font-weight: 500; }

  & .portal-tools { display: flex; align-items: center; gap: 10px; }
  & .portal-availability {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--ux-border);
    border-radius: 999px;
    background: var(--ux-surface);
    color: var(--ux-text-2);
    font-size: 12.5px;
    font-weight: 600;
  }
  & .availability-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ux-brand); box-shadow: 0 0 0 3px var(--ux-brand-soft); }

  & .themeToggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--ux-border-strong);
    border-radius: var(--ux-r) !important;
    background: var(--ux-surface);
    color: var(--ux-text);
    font: 500 13px/1 var(--ux-font) !important;
    transform: none !important;
    box-shadow: var(--ux-shadow-sm);
    cursor: pointer;
    transition: background-color .15s var(--ux-ease);
  }
  & .themeToggle:hover { background: var(--ux-surface-3); }
  & .themeToggle svg { width: 16px; height: 16px; color: var(--ux-brand-text); }
  & .themeToggle .icoMoon { display: none; }

  /* ---------- Contenu ---------- */
  & .portal-main { flex: 1 0 auto; width: min(var(--portal-w), 100% - 40px); margin: 0 auto; padding: 56px 0 64px; }

  & .portal-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
    gap: 32px;
    align-items: center;
    margin-bottom: 56px;
  }
  & .hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    color: var(--ux-brand-text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
  }
  & .eyebrow-line { width: 28px; height: 2px; border-radius: 2px; background: var(--ux-brand); }
  & .portal-hero h1 {
    margin: 0 0 18px;
    color: var(--ux-text);
    font-size: clamp(32px, 4.4vw, 50px);
    font-weight: 750;
    line-height: 1.08;
    letter-spacing: -.03em;
  }
  & .portal-hero h1 span { color: var(--ux-brand-text); }
  & .hero-intro { max-width: 560px; margin: 0; color: var(--ux-text-2); font-size: 16.5px; line-height: 1.6; }

  & .hero-panel {
    position: relative;
    padding: 22px;
    border: 1px solid var(--ux-border);
    border-radius: var(--ux-r-xl);
    background: var(--ux-surface);
    box-shadow: var(--ux-shadow-md);
    overflow: hidden;
  }
  & .hero-panel::before, & .hero-panel::after { display: none !important; }
  & .hero-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
  & .panel-label { color: var(--ux-muted); font-size: 11.5px; font-weight: 700; letter-spacing: .08em; }
  & .panel-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--ux-green-bd);
    border-radius: 999px;
    background: var(--ux-green-bg);
    color: var(--ux-green);
    font-size: 12px;
    font-weight: 600;
  }
  & .panel-status i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: none; }
  & .hero-panel-title { margin-bottom: 16px; color: var(--ux-text); font-size: 17px; font-weight: 650; line-height: 1.35; }
  & .hero-stat-list { display: grid; gap: 8px; }
  & .hero-stat {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--ux-border);
    border-radius: var(--ux-r-lg);
    background: var(--ux-surface-2);
  }
  & .hero-stat strong { min-width: 56px; color: var(--ux-text); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
  & .hero-stat span { color: var(--ux-text-2); font-size: 14px; }

  /* ---------- Applications ---------- */
  & .section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
  & .section-kicker { display: block; margin-bottom: 6px; color: var(--ux-brand-text); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
  & .section-heading h2 { margin: 0; color: var(--ux-text); font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
  & .section-heading p { margin: 0; color: var(--ux-muted); font-size: 14.5px; }

  & .application-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
  & .application-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 236px;
    padding: 20px;
    border: 1px solid var(--ux-border);
    border-radius: var(--ux-r-xl);
    background: var(--ux-surface);
    box-shadow: var(--ux-shadow-sm);
    color: inherit;
    text-decoration: none;
    transition: border-color .18s var(--ux-ease), box-shadow .18s var(--ux-ease), transform .18s var(--ux-ease);
  }
  & .application-card::before, & .application-card::after { display: none !important; }
  & .application-card:not(.is-soon):hover {
    border-color: var(--ux-brand-ring);
    box-shadow: var(--ux-shadow-md);
    transform: translateY(-2px);
  }
  & .card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
  & .app-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 12px;
    background: var(--ux-brand-soft);
    color: var(--ux-brand-text);
    box-shadow: none;
  }
  & .app-icon svg { width: 24px; height: 24px; }
  & .app-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--ux-border-strong);
    border-radius: 999px;
    background: var(--ux-surface-2);
    color: var(--ux-text-2);
    font-size: 12px;
    font-weight: 600;
  }
  & .app-state.is-online { border-color: var(--ux-green-bd); background: var(--ux-green-bg); color: var(--ux-green); }
  & .app-state i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: none; }
  & .app-number {
    position: absolute;
    top: 20px;
    right: 20px;
    display: none;
  }
  & .application-card h3 { margin: 0 0 6px; color: var(--ux-text); font-size: 17.5px; font-weight: 700; letter-spacing: -.01em; }
  & .application-card p { margin: 0 0 18px; color: var(--ux-text-2); font-size: 14px; line-height: 1.55; }
  & .card-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--ux-border);
    color: var(--ux-brand-text);
    font-size: 13.5px;
    font-weight: 600;
  }
  & .card-action b { transition: transform .18s var(--ux-ease); }
  & .application-card:hover .card-action b { transform: translateX(3px); }

  & .application-card.is-soon { border-style: dashed; background: transparent; box-shadow: none; cursor: default; }
  & .application-card.is-soon .app-icon { background: var(--ux-surface-3); color: var(--ux-muted); }
  & .application-card.is-soon :is(h3, p) { color: var(--ux-muted); }
  & .application-card.is-soon .card-action { color: var(--ux-muted); }

  /* ---------- Pied de page ---------- */
  & .portal-footer { flex-shrink: 0; border-top: 1px solid var(--ux-border); background: var(--ux-surface); }
  & .footer-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    width: min(var(--portal-w), 100% - 40px);
    margin: 0 auto;
    padding: 18px 0 calc(18px + env(safe-area-inset-bottom, 0px));
    color: var(--ux-muted);
    font-size: 13px;
  }
  & .footer-inner img { width: auto; height: 30px; }
  & .footer-inner .logoLight { display: none; }
  & .footer-inner p { margin: 0; margin-right: auto; }
}

/* Mode clair : logo du pied de page en version foncée, icône lune sur le bouton */
:root[data-theme="light"]:not(#ilc-a):not(#ilc-b) body.ilc-pro-portal {
  & .footer-inner .logoDark { display: none; }
  & .footer-inner .logoLight { display: block; }
  & .themeToggle .icoSun { display: none; }
  & .themeToggle .icoMoon { display: inline; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  :root:not(#ilc-a):not(#ilc-b) body.ilc-pro-portal {
    & .portal-main { padding: 36px 0 48px; }
    & .portal-hero { grid-template-columns: 1fr; gap: 24px; margin-bottom: 40px; }
  }
}
@media (max-width: 600px) {
  :root:not(#ilc-a):not(#ilc-b) body.ilc-pro-portal {
    & .portal-nav, & .portal-main, & .footer-inner { width: calc(100% - 28px); }
    & .portal-availability { display: none; }
    & .themeLabel { display: none; }
    & .themeToggle { width: 40px; justify-content: center; padding: 0; }
    & .hero-intro { font-size: 15.5px; }
    & .application-grid { grid-template-columns: 1fr; }
    & .application-card { min-height: 0; }
    & .footer-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  }
}

@media (prefers-reduced-motion: reduce) {
  :root:not(#ilc-a):not(#ilc-b) body.ilc-pro-portal * { transition: none !important; }
}
