/* ==========================================================================
   app-header.css — Header d'application + navigation (#6.2)
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--c-bg-elev-1);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-1);
}

.app-header__inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
  max-width: 1440px;
  margin: 0 auto;
  min-height: 60px;
}

/* Logo tenant (+ co-branding OFOORNO) */
.app-header__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
}
.app-header__brand a { color: inherit; text-decoration: none; }

.tenant-logo {
  height: 32px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  flex-shrink: 0;
}

.tenant-logo-fallback {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--c-primary);
  color: var(--c-primary-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
}

.tenant-name {
  font-weight: var(--fw-semibold);
  color: var(--c-text);
  font-size: var(--fs-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.cobrand {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  padding-left: var(--s-3);
  margin-left: var(--s-3);
  border-left: 1px solid var(--c-divider);
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  white-space: nowrap;
}
.cobrand__logo {
  height: 14px;
  opacity: 0.85;
}

/* Navigation centre */
.app-nav {
  display: flex;
  gap: var(--s-1);
  justify-self: start;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.app-nav a {
  padding: 8px 14px;
  border-radius: var(--r-sm);
  color: var(--c-text-muted);
  font-weight: var(--fw-medium);
  font-size: var(--fs-md);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  transition: background var(--t-fast), color var(--t-fast);
  text-decoration: none;
}
.app-nav a:hover { background: var(--c-bg-elev-2); color: var(--c-text); }
.app-nav a.active {
  color: var(--c-primary);
  background: color-mix(in srgb, var(--c-primary) 10%, transparent);
}
.app-nav a .icon { width: 16px; height: 16px; }

/* Actions droite (toggle dark, user menu) */
.app-header__actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--c-text-muted);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.theme-toggle:hover { background: var(--c-bg-elev-2); }

.user-menu {
  position: relative;
}
.user-menu__button {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 10px 4px 4px;
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  cursor: pointer;
  color: var(--c-text);
  font: inherit;
}
.user-menu__button:hover { background: var(--c-bg-elev-2); }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  background: var(--c-accent);
  color: var(--c-accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
}
.user-menu__label {
  font-size: var(--fs-sm);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--c-bg-elev-1);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  padding: var(--s-2);
  display: none;
  animation: slide-down .14s ease-out;
}
.user-menu.open .user-menu__dropdown { display: block; }
.user-menu__dropdown a, .user-menu__dropdown button {
  display: flex; align-items: center; gap: var(--s-2);
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--c-text);
  text-decoration: none;
  font-size: var(--fs-md);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}
.user-menu__dropdown a:hover, .user-menu__dropdown button:hover {
  background: var(--c-bg-elev-2);
  text-decoration: none;
}
.user-menu__dropdown hr { margin: var(--s-2) 0; }

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bottom-bar mobile (#6.5) */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: var(--z-header);
  background: var(--c-bg-elev-1);
  border-top: 1px solid var(--c-border);
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0));
}
.mobile-nav__list {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  max-width: 640px;
  margin: 0 auto;
}
.mobile-nav__item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  padding: 6px 4px;
  color: var(--c-text-muted);
  font-size: 10.5px;
  text-decoration: none;
  min-height: 50px;
}
.mobile-nav__item .icon { width: 22px; height: 22px; }
.mobile-nav__item.active { color: var(--c-primary); font-weight: var(--fw-semibold); }

/* Bascules desktop ↔ mobile */
@media (max-width: 768px) {
  .app-header__inner { grid-template-columns: auto 1fr auto; padding: var(--s-2) var(--s-3); }
  .app-nav { display: none; }
  .cobrand { display: none; }
  .user-menu__label { display: none; }
  .tenant-name { max-width: 140px; font-size: var(--fs-sm); }
  .mobile-nav { display: block; }
  body { padding-bottom: 64px; }
}


/* === BRANDING-V2 === */
/* Renforce la presence d'OFOORNO et du logo tenant. */
.app-header {
  background: linear-gradient(180deg, var(--ofoorno-cream) 0%, var(--c-bg-elev-1) 100%);
  border-bottom: 2px solid var(--ofoorno-ember);
}

.app-header__brand {
  gap: var(--s-4);
  padding: var(--s-1) var(--s-2);
}

.tenant-logo {
  height: 40px;
  max-width: 180px;
}

.tenant-logo-fallback {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--ofoorno-ember) 0%, var(--ofoorno-bronze) 100%);
  color: #FFFFFF;
  font-size: var(--fs-md);
  box-shadow: 0 2px 6px rgba(232, 130, 58, 0.25);
}

.tenant-name {
  color: var(--ofoorno-stone);
  font-weight: var(--fw-bold, 700);
  font-size: var(--fs-lg, 17px);
}

.cobrand {
  border-left: 2px solid var(--ofoorno-ember);
  padding-left: var(--s-3);
  margin-left: var(--s-3);
  color: var(--ofoorno-bronze);
  font-weight: var(--fw-medium, 500);
}

.cobrand__logo {
  height: 22px;
  opacity: 1;
}

/* Dark mode : on adoucit, mais on garde la baseline Ember */
:root[data-theme="dark"] .app-header,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .app-header {
    background: linear-gradient(180deg, #1A130C 0%, #251B11 100%);
    border-bottom-color: var(--ofoorno-ember);
  }
}

/* Mobile : on garde le co-brand visible (au lieu de le cacher) */
@media (max-width: 720px) {
  .cobrand { display: flex; }
  .cobrand span { display: none; }
  .cobrand__logo { height: 18px; }
  .tenant-logo { height: 32px; max-width: 120px; }
  .tenant-name { font-size: var(--fs-md); }
}
