@layer tokens, base, layout, components, views;

@layer views {
  .g-row-flex { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .g-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .g-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .g-grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
  .g-grid-today { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
  .g-grid-time { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 16px; align-items: start; }
  .g-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
  .g-stack--tight { gap: 10px; }
  @media (max-width: 1100px) { .g-grid-today { grid-template-columns: minmax(0, 1fr); } .g-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-grid-main, .g-grid-time { grid-template-columns: minmax(0, 1fr); } }
  @media (max-width: 767px) { .g-grid-3, .g-grid-2 { grid-template-columns: minmax(0, 1fr); gap: 12px; } .g-stack { gap: 12px; } }

  /* Carte enfant */
  .g-kid-card { display: flex; flex-direction: column; gap: 14px; }
  .g-kid-card__head { display: flex; align-items: center; gap: 12px; }
  .g-kid-card__head a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
  .g-kid-card__name { font-size: 17px; font-weight: 650; }
  .g-kid-card__actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .g-kid-card__actions .g-btn { flex: 1 1 auto; min-width: 0; white-space: nowrap; }
  .g-kid-card__sub { font-size: 13px; color: var(--g-muted); font-weight: 500; }

  /* En-tête enfant */
  .g-kid-head { background: var(--g-bg); padding: 24px 32px 0; border-bottom: 1px solid var(--g-line); display: flex; flex-direction: column; gap: 16px; }
  .g-kid-head__row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
  .g-kid-head__id { flex: 1; min-width: 240px; display: flex; align-items: center; gap: 16px; }
  .g-kid-head__title { display: flex; align-items: center; gap: 12px; }
  .g-kid-head__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .g-hwswitch { display: inline-flex; align-items: center; gap: 10px; height: 36px; padding: 0 4px 0 8px; font-size: 13px; font-weight: 600; color: var(--g-ink-2); background: transparent; border: 0; }
  @media (max-width: 1023px) { .g-kid-head { padding: 20px 24px 0; } }
  @media (max-width: 767px) { .g-kid-head { padding: 0; background: transparent; border: 0; gap: 12px; } .g-kid-head__id { display: none; } .g-kid-head__actions { width: 100%; } .g-kid-head__actions .g-btn { flex: 1; } .g-kid-head__actions .g-btn--icon { flex: none; } .g-hwswitch { flex: 1; justify-content: space-between; border: 1px solid var(--g-line); border-radius: var(--g-r-md); height: 44px; padding: 0 12px; background: var(--g-surface); } }
  .g-subpage { display: flex; flex-direction: column; gap: 16px; padding: 24px 32px 40px; max-width: 1280px; }
  @media (max-width: 1023px) { .g-subpage { padding: 20px 24px 32px; } }
  @media (max-width: 767px) { .g-subpage { padding: 0 16px 24px; gap: 12px; } }

  .g-today { display: flex; align-items: center; gap: 20px; }
  .g-today__text { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--g-muted); font-weight: 500; }

  /* Appareils */
  .g-device { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
  .g-device__ico { width: 44px; height: 44px; border-radius: 12px; background: var(--g-surface-2); color: var(--g-ink-2); display: grid; place-items: center; }
  .g-device__main { flex: 1; min-width: 160px; }
  .g-device__name { font-size: 15px; font-weight: 650; }

  /* Captures */
  .g-shots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .g-shot { overflow: hidden; padding: 0; }
  .g-shot img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--g-surface-2); }
  .g-shot__meta { padding: 10px 12px; font-size: 13px; font-weight: 600; }
  @media (max-width: 1100px) { .g-shots { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
  @media (max-width: 767px) { .g-shots { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }

  /* Réglages */
  .g-settings { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
  .g-settings__nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; }
  @media (max-width: 1023px) { .g-settings { grid-template-columns: minmax(0, 1fr); } .g-settings__nav { position: static; flex-direction: row; overflow-x: auto; } .g-settings__nav .g-nav__item { width: auto; flex: none; } }

  /* Connexion */
  .g-login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
  .g-login__box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; text-align: center; align-items: center; }
  .g-login__mark { width: 56px; height: 56px; border-radius: 16px; background: var(--g-brand); color: var(--g-on-brand); display: grid; place-items: center; }
  .g-login form { width: 100%; display: flex; flex-direction: column; gap: 12px; text-align: left; }
  .g-error { color: var(--g-danger-ink); font-size: 13px; font-weight: 600; }

  .g-pillrow { display: flex; flex-wrap: wrap; gap: 8px; }
  .g-note { padding: 12px 16px; border-radius: 12px; background: var(--g-info-soft); color: var(--g-brand-ink); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
  .g-muted { color: var(--g-muted); }
  .g-right { margin-left: auto; }

  .g-mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
  .g-pre { margin: 6px 0 0; padding: 10px 12px; border-radius: var(--g-r-sm); background: var(--g-surface-2); font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
  .g-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .g-row--btn { width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; font: inherit; color: inherit; cursor: pointer; }
  .g-row--btn:hover { background: var(--g-surface-2); }

  /* Téléphone : fil de conversation */
  .g-convo { display: flex; flex-direction: column; gap: 8px; }
  .g-bubble { max-width: 82%; padding: 8px 12px; border-radius: 14px; background: var(--g-surface-2); font-size: 14px; white-space: pre-wrap; word-break: break-word; align-self: flex-start; }
  .g-bubble[data-dir="out"] { align-self: flex-end; background: var(--g-brand-soft); color: var(--g-brand-ink); }
  .g-bubble small { display: block; margin-top: 2px; font-size: 11px; color: var(--g-muted); }
  .g-convo__call { align-self: center; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--g-muted); }

  /* Terminal : console à distance */
  .g-console { min-height: 160px; max-height: 480px; overflow: auto; padding: 12px; border-radius: var(--g-r-md); background: #0f172a; color: #e2e8f0; font: 12px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; display: flex; flex-direction: column; gap: 12px; }
  .g-console__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #93c5fd; font-weight: 600; }
  .g-console pre { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; }
  .g-console pre.is-error { color: #fca5a5; }
  .g-console__hint { color: #94a3b8; }
}
