/* =========================================================================
   style-layout.css — STRUCTURE DE L'APP : SIDEBAR, TOPBAR, GRILLE
   ========================================================================= */

/* ---------- GRILLE GLOBALE ---------- */
.comvia-app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.comvia-app-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
}

.comvia-app-main {
  display: flex;
  flex-direction: column;
  min-width: 0; /* permet aux enfants de shrink */
}

.comvia-app-view {
  flex: 1;
  padding: var(--space-7) var(--space-7);
  overflow-y: auto;
  max-width: 1400px;
  width: 100%;
}

/* ---------- SIDEBAR ---------- */
.comvia-sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-5) var(--space-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--r-md);
  color: var(--text);
  text-decoration: none;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  transition: background var(--duration-fast) var(--ease-out);
  cursor: pointer;
  position: relative;
}
.sidebar-item:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.sidebar-item--active {
  background: var(--comvia-blue);
  color: white;
  font-weight: var(--weight-semibold);
}
.sidebar-item--active:hover {
  background: var(--comvia-blue-deep);
}
.sidebar-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-label { flex: 1; min-width: 0; }
.sidebar-badge {
  font-size: var(--text-xs);
  font-weight: var(--weight-extra);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text);
}
.sidebar-item--active .sidebar-badge {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}
.sidebar-badge--urgent {
  background: var(--signal-urgent);
  color: white;
  animation: pulse-urgent 2s infinite;
}
@keyframes pulse-urgent {
  0%, 100% { box-shadow: 0 0 0 0 oklch(0.62 0.18 65 / 0.5); }
  50%      { box-shadow: 0 0 0 6px oklch(0.62 0.18 65 / 0); }
}

.sidebar-locked {
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--border);
}
.sidebar-locked-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}
.sidebar-item--locked {
  opacity: 0.4;
  cursor: not-allowed;
}
.sidebar-item--locked:hover { background: transparent; }
.sidebar-lock { font-size: 0.85rem; }

.sidebar-footer {
  padding: var(--space-3) var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
}
.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--r-md);
  cursor: pointer;
  user-select: none;
}
.sidebar-toggle:hover { background: var(--surface-2); }
.sidebar-toggle input { display: none; }
.sidebar-toggle-track {
  width: 36px;
  height: 20px;
  background: var(--border-strong);
  border-radius: var(--r-pill);
  position: relative;
  transition: background var(--duration-base) var(--ease-out);
  flex-shrink: 0;
}
.sidebar-toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform var(--duration-base) var(--ease-out);
  box-shadow: var(--shadow-raised);
}
.sidebar-toggle input:checked + .sidebar-toggle-track {
  background: var(--comvia-blue);
}
.sidebar-toggle input:checked + .sidebar-toggle-track .sidebar-toggle-thumb {
  transform: translateX(16px);
}
.sidebar-toggle-label { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-toggle-label strong { font-size: var(--text-sm); }
.sidebar-toggle-label small { font-size: var(--text-xs); color: var(--text-muted); }

/* ---------- TOPBAR ---------- */
.comvia-topbar {
  display: grid;
  grid-template-columns: 200px 1fr auto;
  align-items: center;
  gap: var(--space-5);
  height: 56px;
  padding: 0 var(--space-7);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
}
.topbar-left { display: flex; align-items: center; }
.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-strong);
  font-weight: var(--weight-bold);
}
.topbar-brand:hover { text-decoration: none; }
.topbar-brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--comvia-blue);
}
.topbar-brand-name {
  font-size: var(--text-base);
  letter-spacing: 0.02em;
}

.topbar-center {
  display: flex;
  justify-content: center;
  min-width: 0;
}
.topbar-objectif {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--surface-2);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  max-width: 540px;
  width: 100%;
}
.topbar-objectif--empty { color: var(--text-muted); font-style: italic; }
.topbar-objectif-icon { font-size: 1rem; }
.topbar-objectif-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: var(--weight-medium);
}
.topbar-objectif-bar {
  width: 120px;
  height: 6px;
  background: var(--border);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.topbar-objectif-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--comvia-blue-soft), var(--comvia-gold));
  border-radius: var(--r-pill);
  transition: width var(--duration-slow) var(--ease-out);
}
.topbar-objectif-pct {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-strong);
  min-width: 32px;
  text-align: right;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: all var(--duration-fast) var(--ease-out);
}
.topbar-btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.topbar-btn--idea {
  color: white;
  background: var(--comvia-blue);
  border-color: var(--comvia-blue);
}
.topbar-btn--idea:hover {
  background: var(--comvia-blue-deep);
  border-color: var(--comvia-blue-deep);
}
.topbar-btn-label { font-size: var(--text-xs); }

.topbar-health {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-md);
}
.topbar-health-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
}
.topbar-health.is-online .topbar-health-dot {
  background: var(--signal-success);
  box-shadow: 0 0 0 3px oklch(0.60 0.14 155 / 0.18);
}
.topbar-health.is-offline .topbar-health-dot {
  background: var(--signal-error);
}
.topbar-breadcrumb {
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-family: var(--font-mono);
  padding: var(--space-2);
}

/* ---------- FOCUS MODE ---------- */
body.focus-mode .comvia-app-sidebar,
body.focus-mode #topbar-mount {
  display: none;
}
body.focus-mode .comvia-app {
  grid-template-columns: 1fr;
}
body.focus-mode .comvia-app-view {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-5);
}

/* ---------- RESPONSIVE LÉGER ---------- */
@media (max-width: 1024px) {
  .comvia-app { grid-template-columns: 64px 1fr; }
  .sidebar-label, .sidebar-badge, .sidebar-toggle-label, .sidebar-locked-title { display: none; }
  .sidebar-item { justify-content: center; padding: var(--space-3); }
  .sidebar-icon { width: auto; }
  .topbar-btn-label { display: none; }
}
