/* Shell applicatif global: variables, sidebar, topbar et structure de page. */

:root {
  --app-bg: #f4f6f2;
  --app-surface: #fcfdfb;
  --app-surface-strong: #ffffff;
  --app-border: #d8ddd4;
  --app-text: #1f2a24;
  --app-text-muted: #66736b;
  --app-accent: #2f6b4f;
  --app-accent-strong: #214c39;
  --app-danger: #a44949;
  --app-warning: #b98a2f;
  --app-info: #46627a;
  --app-radius-lg: 1.25rem;
  --app-radius-md: 0.9rem;
  --app-shadow: 0 12px 30px rgba(23, 33, 27, 0.06);
}

html,
body {
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--app-bg);
  color: var(--app-text);
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
  max-width: 100%;
  overflow: hidden;
}

.app-shell--guest {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell__overlay {
  display: none;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.25rem;
  background: #18211d;
  color: #eff4ef;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 18px 0 50px rgba(11, 19, 14, 0.12);
  z-index: 1040;
  overflow-x: hidden;
}

.app-sidebar__brand {
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(239, 244, 239, 0.12);
}

.app-sidebar__brand-link {
  color: inherit;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.app-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.app-sidebar__link {
  display: block;
  padding: 0.9rem 1rem;
  border-radius: 0.95rem;
  color: rgba(239, 244, 239, 0.82);
  text-decoration: none;
  font-weight: 600;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.app-sidebar__link:hover,
.app-sidebar__link:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(2px);
}

.app-sidebar__link.is-active {
  background: linear-gradient(135deg, rgba(47, 107, 79, 0.95), rgba(33, 76, 57, 0.95));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.app-sidebar__group {
  display: grid;
  gap: 0.35rem;
  padding-top: 0.95rem;
  border-top: 1px solid rgba(239, 244, 239, 0.1);
}

.app-sidebar__group-label {
  margin: 0;
  padding: 0 1rem;
  color: rgba(239, 244, 239, 0.58);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-sidebar__group.is-active .app-sidebar__group-label {
  color: rgba(255, 255, 255, 0.9);
}

.app-sidebar__sublink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.72rem 1rem 0.72rem 1.1rem;
  border-radius: 0.9rem;
  color: rgba(239, 244, 239, 0.78);
  text-decoration: none;
  font-weight: 600;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.app-sidebar__sublink:hover,
.app-sidebar__sublink:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(2px);
}

.app-sidebar__sublink.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.app-sidebar__count {
  flex: 0 0 auto;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  background: rgba(185, 138, 47, 0.22);
  color: #fff4d6;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.app-sidebar__dock {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(239, 244, 239, 0.12);
}

.app-sidebar__dock-link {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 0.9rem;
  border-radius: 1rem;
  color: rgba(239, 244, 239, 0.84);
  text-decoration: none;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.app-sidebar__dock-link:hover,
.app-sidebar__dock-link:focus-visible,
.app-sidebar__dock-link.is-active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  transform: translateX(2px);
}

.app-sidebar__dock-icon {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
}

.app-sidebar__dock-text {
  font-size: 0.95rem;
}

.app-main {
  min-width: 0;
  min-height: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.app-topbar,
.app-content,
.app-footer {
  width: min(100%, 1440px);
  margin: 0 auto;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 1rem;
  padding: 1.25rem 1rem 0;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.app-topbar__spacer {
  flex: 1 1 auto;
}

.app-topbar__actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.75rem;
  margin-left: auto;
  min-width: 0;
  max-width: 100%;
}

.app-topbar__notifications {
  position: relative;
  flex: 0 0 auto;
}

.app-topbar__icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.8rem;
  height: 2.8rem;
  flex: 0 0 auto;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--app-text);
  box-shadow: var(--app-shadow);
  line-height: 1;
  padding: 0;
}

.app-topbar__icon-button:hover,
.app-topbar__icon-button:focus-visible {
  background: #fff;
  color: var(--app-accent-strong);
}

.app-topbar__icon {
  width: 1.2rem;
  height: 1.2rem;
  display: block;
  flex: 0 0 auto;
}

.app-topbar__badge {
  position: absolute;
  top: -0.2rem;
  right: -0.2rem;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: var(--app-danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2rem;
  text-align: center;
}

.app-topbar__notifications-panel {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  width: min(24rem, calc(100vw - 2rem));
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  background: rgba(252, 253, 251, 0.98);
  box-shadow: 0 22px 40px rgba(23, 33, 27, 0.14);
  z-index: 1080;
  overflow: hidden;
}

.app-topbar__notifications-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--app-border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 246, 242, 0.96));
}

.app-topbar__notifications-body {
  max-height: min(26rem, calc(100vh - 8rem));
  overflow: auto;
}

.app-topbar__notifications-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-topbar__notifications-item + .app-topbar__notifications-item {
  border-top: 1px solid rgba(216, 221, 212, 0.9);
}

.app-topbar__notifications-item.is-unread {
  background: rgba(47, 107, 79, 0.08);
}

.app-topbar__notification-link {
  display: grid;
  gap: 0.2rem;
  padding: 0.95rem 1rem;
  color: inherit;
  text-decoration: none;
}

.app-topbar__notification-link:hover,
.app-topbar__notification-link:focus-visible {
  background: rgba(47, 107, 79, 0.08);
}

.app-topbar__notification-date {
  color: var(--app-text-muted);
  font-size: 0.8rem;
}

.app-topbar__user {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--app-shadow);
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
  min-width: 0;
  max-width: min(26rem, 42vw);
}

.app-topbar__user span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-content {
  flex: 1 1 auto;
  width: min(100%, 1440px);
}

.app-content__inner {
  padding: 1rem;
}

.app-mobile-restriction {
  display: none;
  margin: 1rem;
  padding: clamp(1.4rem, 8vw, 2.4rem);
  text-align: center;
}

.app-mobile-restriction__eyebrow {
  margin-bottom: 0.75rem;
  color: var(--app-accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-mobile-restriction__title {
  margin: 0;
  font-size: clamp(1.45rem, 8vw, 2rem);
  line-height: 1.12;
}

.app-mobile-restriction__text {
  margin: 1rem auto 0;
  max-width: 28rem;
  color: var(--app-text-muted);
}

.app-mobile-restriction__actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.4rem;
}

.app-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.app-page-header__copy {
  min-width: 0;
}

.app-page-header__title {
  margin: 0;
  font-size: clamp(1.75rem, 2vw, 2.4rem);
  line-height: 1.1;
}

.app-page-header__title--ghost {
  min-height: 2.6rem;
}

.app-footer {
  padding: 1rem;
}

@media (max-width: 991.98px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-shell:not(.app-shell--guest) .app-shell__overlay {
    position: fixed;
    inset: 0;
    display: block;
    background: rgba(16, 25, 19, 0.36);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    z-index: 1030;
  }

  .app-shell[data-sidebar-open="true"] .app-shell__overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(20rem, calc(100vw - 2rem));
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  .app-shell[data-sidebar-open="true"] .app-sidebar {
    transform: translateX(0);
  }

  .app-topbar {
    padding: 1rem 1rem 0;
  }

  .app-topbar__actions {
    gap: 0.5rem;
    max-width: calc(100vw - 6rem);
  }

  .app-content__inner,
  .app-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

@media (max-width: 767.98px) {
  .app-sidebar [data-mobile-nav-supported="false"],
  .app-sidebar__dock {
    display: none !important;
  }

  .app-shell[data-mobile-supported="false"] [data-mobile-gated-content],
  .app-shell[data-mobile-supported="false"] .app-footer {
    display: none !important;
  }

  .app-shell[data-mobile-supported="false"] .app-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 1rem;
  }

  .app-shell[data-mobile-supported="false"] [data-mobile-restricted-message] {
    display: block;
    width: min(100%, 28rem);
  }

  .app-mobile-restriction__actions {
    flex-direction: column;
  }
}
