/*
 * Coque de l'application SYS-GED (templates/base.html) : barre latérale,
 * barre du haut, pied de page, messages et pastilles d'initiales.
 */

:root {
  --ged-primary: #072853;
  --ged-primary-dark: #041833;
  --ged-primary-soft: #e7eef6;
  --ged-accent: #e7c66a;
  --ged-bg: #f3f4f6;
  --ged-text: #1f2937;
  --ged-text-muted: #6b7280;
  --ged-border: #d1d5db;
  --ged-danger: #dc3545;
  --ged-sidebar-width: 256px;
  --ged-topbar-height: 64px;
}

/* ------------------------------------------------------------------ */

.app-app {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  width: var(--ged-sidebar-width);
  overflow-y: auto;
  color: rgba(255, 255, 255, .8);
  background: var(--ged-primary);
  transition: transform .25s ease;
}

.app-sidebar a {
  text-decoration: none;
}

.app-sidebar__header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: .75rem;
  height: var(--ged-topbar-height);
  padding: 0 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.app-sidebar__logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: .875rem;
}

.app-sidebar__brand,
.app-sidebar__brand:hover {
  color: #fff;
  font-size: 1.125rem;
  font-weight: 700;
}

.app-sidebar__profile {
  flex-shrink: 0;
  padding: 1.5rem;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.app-sidebar__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border: 2px solid rgba(255, 255, 255, .2);
  border-radius: 50%;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
}

.app-sidebar__name {
  margin-top: .75rem;
  color: #fff;
  font-size: .875rem;
  font-weight: 600;
}

.app-sidebar__role {
  margin-top: .25rem;
  color: rgba(255, 255, 255, .7);
  font-size: .75rem;
}

.app-sidebar__guide {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: .75rem;
  padding: .35rem 1rem;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
}

.app-sidebar__guide:hover {
  color: #fff;
  background: rgba(255, 255, 255, .24);
}

.app-sidebar__nav {
  flex: 1;
  padding: 1rem .75rem;
}

.app-sidebar__link {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  margin-bottom: .25rem;
  padding: .6rem .75rem;
  border: 0;
  border-radius: .5rem;
  background: none;
  color: rgba(255, 255, 255, .8);
  font-size: .9375rem;
  font-weight: 500;
  text-align: left;
}

.app-sidebar__link:hover,
.app-sidebar__link:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, .08);
}

.app-sidebar__link i {
  width: 20px;
  text-align: center;
}

.app-sidebar__link--active,
.app-sidebar__link--active:hover {
  color: #4b5563;
  background: var(--ged-accent);
  font-weight: 700;
}

.app-sidebar__chevron {
  margin-left: auto;
  font-size: .75rem;
  transition: transform .2s;
}

.app-sidebar__toggle[aria-expanded="true"] .app-sidebar__chevron {
  transform: rotate(180deg);
}

.app-sidebar__submenu {
  margin: 0 0 .25rem;
  padding: .15rem 0 .4rem;
  list-style: none;
  border-radius: 0 0 .5rem .5rem;
  background: rgba(255, 255, 255, .06);
}

.app-sidebar__submenu-link {
  display: block;
  margin: 1px .5rem;
  padding: .4rem .75rem .4rem 2.75rem;
  border-radius: .375rem;
  color: rgba(255, 255, 255, .7);
  font-size: .875rem;
}

.app-sidebar__submenu-link:hover,
.app-sidebar__submenu-link--active {
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

.app-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1029;
  background: rgba(0, 0, 0, .4);
}

.app-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--ged-sidebar-width);
  transition: margin-left .25s ease;
  /* Même règle que la liste minière : centrée, sans répétition, 40 % de la largeur, hauteur automatique. */
  background-color: var(--ged-bg);
  background-image: var(--ged-armoirie);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 40%;
}

.ged-armoirie-apercu {
  height: 280px;
  border: 1px solid var(--ged-border);
  border-radius: 12px;
  background-color: #fff;
  background-image: var(--apercu, var(--ged-armoirie));
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 40%;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--ged-topbar-height);
  padding: 0 2rem;
  border-bottom: 1px solid var(--ged-border);
  background: #fff;
}

.app-mobile-toggle {
  padding: .5rem;
  border: 0;
  background: none;
  color: var(--ged-text);
  font-size: 1.5rem;
}

.app-topbar__search-wrap {
  flex: 1;
  max-width: 448px;
}

.app-topbar__search {
  position: relative;
}

.app-topbar__search-icon {
  position: absolute;
  top: 50%;
  left: .75rem;
  transform: translateY(-50%);
  color: var(--ged-text-muted);
  pointer-events: none;
}

.app-topbar__search input {
  padding-left: 2.25rem;
  background-color: var(--ged-bg);
}

.app-topbar__actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.app-topbar__notif-btn {
  position: relative;
  padding: .5rem;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ged-text-muted);
  font-size: 1.125rem;
}

.app-topbar__notif-badge {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  overflow: hidden;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--ged-danger);
  font-size: 0;
}

.app-topbar__notif-badge.is-active {
  display: block;
}

.app-topbar__divider {
  width: 1px;
  height: 32px;
  margin: 0 .5rem;
  background: var(--ged-border);
}

.app-topbar__user {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .25rem .5rem .25rem .25rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--ged-text);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
}

.app-topbar__user:hover,
.app-topbar__user[aria-expanded="true"] {
  color: var(--ged-text);
  border-color: var(--ged-border);
  background: var(--ged-bg);
}

.app-topbar__user-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-topbar__user-chevron {
  color: var(--ged-text-muted);
  font-size: .7rem;
}

.app-user-menu {
  min-width: 260px;
}

.app-user-menu__header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem .5rem;
}

.app-user-menu__identity {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-user-menu__name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-user-menu__role {
  color: var(--ged-text-muted);
  font-size: .75rem;
}

.app-user-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 1rem;
}

.app-user-menu .dropdown-item i {
  width: 16px;
  color: var(--ged-text-muted);
  text-align: center;
}

.app-user-menu__logout,
.app-user-menu__logout i {
  color: var(--ged-danger) !important;
}

.notif-menu {
  width: 360px;
  max-width: calc(100vw - 24px);
  padding: 0;
  overflow: hidden;
}

.app-notif-menu__header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--ged-border);
  font-weight: 600;
}

.app-notif-empty {
  padding: 1.5rem 1rem;
  color: var(--ged-text-muted);
  font-size: .8125rem;
  text-align: center;
}

.app-notif-item-wrap {
  border-bottom: 1px solid var(--ged-border);
}

.app-notif-item {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .75rem 1rem;
  color: var(--ged-text);
  font-size: .8125rem;
  line-height: 1.45;
  text-decoration: none;
  white-space: normal;
}

.app-notif-item:hover {
  color: var(--ged-text);
  background: var(--ged-bg);
}

.app-notif-item__dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--ged-primary);
}

.app-notif-item__actor,
.app-notif-item__highlight {
  font-weight: 600;
}

.app-notif-item__author,
.app-notif-item__time {
  color: var(--ged-text-muted);
  font-size: .75rem;
}

.app-notif-item__time {
  display: block;
  margin-top: .25rem;
}

.notif-footer a {
  display: block;
  padding: .6rem 1rem;
  color: #fff;
  background: var(--ged-primary);
  font-size: .8125rem;
  text-align: center;
  text-decoration: none;
}

.notif-footer a:hover {
  color: #fff;
  background: var(--ged-primary-dark);
}

.app-content {
  flex: 1;
  min-width: 0;
  padding: 2rem;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .25rem 2rem;
  padding: .75rem 1rem;
  color: #fff;
  background: var(--ged-primary);
  font-size: .875rem;
}

.app-footer a {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.app-footer .app-footer__author a {
  color: #bf8a5f;
}

.app-messages {
  position: fixed;
  top: calc(var(--ged-topbar-height) + .75rem);
  right: 1rem;
  z-index: 1090;
  width: min(480px, calc(100vw - 2rem));
}

/* Barre latérale réduite (desktop) ou en tiroir (mobile) */
@media (min-width: 1054px) {
  body.app-nav-collapsed .app-sidebar { transform: translateX(-100%); }
  body.app-nav-collapsed .app-main { margin-left: 0; }
}

@media (max-width: 1053.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar--open { transform: translateX(0); }
  .app-sidebar-overlay--visible { display: block; }
  .app-main { margin-left: 0; }
}

@media (max-width: 640px) {
  .app-content { padding: 1rem; }
  .app-topbar { padding: 0 1rem; }
  .app-topbar__user-name { display: none; }
}

/* Initiales d'un utilisateur dans une pastille */
.avatar {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--ged-primary);
  color: #fff;
  font-size: .8125rem;
  font-weight: 600;
  text-transform: uppercase;
}

.avatar-sm { width: 2rem; height: 2rem; font-size: .75rem; }
.avatar-lg { width: 4.5rem; height: 4.5rem; font-size: 1.5rem; }
