/*
 * Quebeecoo shared app shell — M3 Expressive left navigation drawer.
 * Requires m3-tokens.css to be loaded first.
 *
 * Canonical source. Copied into each product's frontend/ as m3-shell.css.
 * Every product uses the same structure:
 *
 *   <div class="m3-app">
 *     <aside class="m3-nav">
 *       <div class="m3-nav__brand">...</div>
 *       <nav class="m3-nav__items">
 *         <a class="m3-nav__item [m3-nav__item--active]">
 *           <span class="m3-nav__icon">...</span>
 *           <span class="m3-nav__label">...</span>
 *         </a>
 *       </nav>
 *       <div class="m3-nav__footer">...</div>
 *     </aside>
 *     <div class="m3-main">
 *       <header class="m3-topbar">...</header>
 *       <main class="m3-content">...</main>
 *     </div>
 *   </div>
 */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--md-ref-typeface-plain);
  background:
    linear-gradient(140deg, var(--md-sys-color-surface-container-lowest), var(--md-sys-color-surface) 48%, var(--md-sys-color-surface-container-low));
  color: var(--md-sys-color-on-surface);
}

.m3-app {
  display: flex;
  min-height: 100vh;
  gap: var(--md-sys-spacing-sm);
  padding: var(--md-sys-spacing-sm);
  background:
    linear-gradient(140deg, var(--md-sys-color-surface-container-lowest), var(--md-sys-color-surface) 48%, var(--md-sys-color-surface-container-low));
  color: var(--md-sys-color-on-surface);
}

/* ---------------- Left navigation drawer (persistent, standard) ---------------- */

.m3-nav {
  position: relative;
  width: 304px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, var(--md-sys-color-surface-container-high), var(--md-sys-color-surface-container));
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: var(--md-sys-elevation-1);
  padding: var(--md-sys-spacing-md);
  gap: var(--md-sys-spacing-xs);
  overflow: hidden;
}

.m3-nav::before,
.m3-main::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--qbc-grain-texture);
  opacity: 0.025;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.m3-nav__brand {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-sm);
  min-height: 64px;
  padding: var(--md-sys-spacing-xs) var(--md-sys-spacing-sm) var(--md-sys-spacing-md);
  font: var(--md-sys-typescale-title-medium-weight) var(--md-sys-typescale-title-medium-size)/var(--md-sys-typescale-title-medium-line-height) var(--md-ref-typeface-brand);
  letter-spacing: var(--md-sys-typescale-title-medium-tracking);
  color: var(--md-sys-color-on-surface);
}

.m3-nav__brand img,
.m3-nav__brand svg {
  width: 44px;
  height: 44px;
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: var(--md-sys-elevation-1);
}

.m3-nav__items {
  display: flex;
  flex-direction: column;
  gap: var(--md-sys-spacing-xs);
  flex: 1;
  overflow-y: auto;
}

.m3-nav__section-label {
  padding: var(--md-sys-spacing-md) var(--md-sys-spacing-sm) var(--md-sys-spacing-xxs);
  font: var(--md-sys-typescale-label-medium-weight) var(--md-sys-typescale-label-medium-size)/var(--md-sys-typescale-label-medium-line-height) var(--md-sys-typescale-label-medium-font);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
  text-transform: uppercase;
}

.m3-nav__item {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-sm);
  min-height: 56px;
  padding: 0 var(--md-sys-spacing-md);
  border-radius: var(--md-sys-shape-corner-large);
  text-decoration: none;
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-label-large-weight) var(--md-sys-typescale-label-large-size)/var(--md-sys-typescale-label-large-line-height) var(--md-sys-typescale-label-large-font);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  transition:
    background var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
    color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
    transform var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard),
    box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

.m3-nav__item:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary) 10%, transparent);
  color: var(--md-sys-color-on-surface);
  transform: translateX(2px);
}

.m3-nav__item--active {
  background: linear-gradient(135deg, var(--md-sys-color-primary-container), color-mix(in srgb, var(--md-sys-color-secondary-container) 74%, var(--md-sys-color-primary-container)));
  color: var(--md-sys-color-on-primary-container);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-sys-color-primary) 20%, transparent);
}

.m3-nav__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.m3-nav__footer {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-sm);
  padding: var(--md-sys-spacing-sm);
  border-radius: var(--md-sys-shape-corner-large);
  border-top: 1px solid var(--md-sys-color-outline-variant);
  margin-top: var(--md-sys-spacing-xs);
  background: color-mix(in srgb, var(--md-sys-color-surface-container-highest) 44%, transparent);
}

/* ---------------- Main area ---------------- */

.m3-main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: calc(100vh - 24px);
  overflow: hidden;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-extra-large);
  background: var(--md-sys-color-surface-container-lowest);
  box-shadow: var(--md-sys-elevation-1);
}

.m3-topbar {
  min-height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-sm);
  padding: var(--md-sys-spacing-sm) var(--md-sys-spacing-lg);
  background:
    linear-gradient(135deg, var(--md-sys-color-surface-container-lowest), var(--md-sys-color-surface-container-low));
  color: var(--md-sys-color-on-surface);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.m3-topbar__title {
  flex: 1;
  margin: 0;
  font: var(--md-sys-typescale-title-large-weight) var(--md-sys-typescale-title-large-size)/var(--md-sys-typescale-title-large-line-height) var(--md-ref-typeface-brand);
  letter-spacing: var(--md-sys-typescale-title-large-tracking);
}

.m3-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--md-sys-spacing-lg);
  background: var(--md-sys-color-surface-container-lowest);
}

/* ---------------- Shared components ---------------- */

.m3-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--md-sys-spacing-xs);
  min-height: 44px;
  padding: 0 var(--md-sys-spacing-lg);
  border-radius: var(--md-sys-shape-corner-full);
  border: none;
  cursor: pointer;
  font: var(--md-sys-typescale-label-large-weight) var(--md-sys-typescale-label-large-size)/var(--md-sys-typescale-label-large-line-height) var(--md-sys-typescale-label-large-font);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  transition:
    background var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
    box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
    transform var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.m3-btn--filled {
  background: linear-gradient(135deg, var(--md-sys-color-primary), color-mix(in srgb, var(--md-sys-color-secondary) 34%, var(--md-sys-color-primary)));
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-1);
}

.m3-btn--filled:hover {
  box-shadow: var(--md-sys-elevation-2);
  transform: translateY(-1px);
}

.m3-btn--tonal {
  background: color-mix(in srgb, var(--md-sys-color-secondary-container) 84%, var(--md-sys-color-surface-container-high));
  color: var(--md-sys-color-on-secondary-container);
}

.m3-btn--outlined {
  background: transparent;
  border: 1px solid var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface);
}

.m3-btn--text {
  background: transparent;
  color: var(--md-sys-color-primary);
  padding: 0 var(--md-sys-spacing-md);
}

.m3-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: background var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

.m3-icon-btn:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary) 12%, transparent);
  color: var(--md-sys-color-on-surface);
}

.m3-card {
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-surface-container-low);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 74%, transparent);
}

.m3-card--outlined {
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.m3-card--elevated {
  box-shadow: var(--md-sys-elevation-1);
}

/* ---------------- Responsive: collapse drawer to rail/bar on small screens ---------------- */

@media (max-width: 839px) {
  .m3-nav {
    width: 80px;
    align-items: center;
  }
  .m3-nav__brand span:not(.m3-nav__brand-mark),
  .m3-nav__label,
  .m3-nav__section-label {
    display: none;
  }
  .m3-nav__item {
    width: 56px;
    justify-content: center;
    padding: 0;
  }
}

@media (max-width: 599px) {
  .m3-app {
    flex-direction: column;
    padding: 0;
    gap: 0;
  }
  .m3-nav {
    width: 100%;
    flex-direction: row;
    align-items: center;
    height: 64px;
    padding: 0 var(--md-sys-spacing-xs);
    border-right: none;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 0;
    overflow-x: auto;
  }
  .m3-main {
    min-height: calc(100vh - 64px);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .m3-nav__brand,
  .m3-nav__footer {
    display: none;
  }
  .m3-nav__items {
    flex-direction: row;
    overflow: visible;
  }
  .m3-nav__item {
    height: 48px;
    width: 48px;
  }
}

/* ---------------- frontend-design: Industrial anchor ---------------- */

body,
.m3-app,
.m3-main,
.m3-nav,
.m3-topbar,
.m3-content,
.m3-card,
.m3-btn,
.m3-icon-btn {
  background-image: none;
  box-shadow: none;
  font-variant-numeric: tabular-nums;
}

.m3-app {
  gap: 0;
  padding: 0;
  background: var(--md-sys-color-surface-container-lowest);
}

.m3-nav {
  width: 280px;
  border: 0;
  border-right: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  padding: 12px;
}

.m3-nav__brand {
  min-height: 56px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.m3-nav__brand img,
.m3-nav__brand svg {
  box-shadow: none;
}

.m3-nav__items {
  gap: 2px;
}

.m3-nav__section-label {
  padding: 18px 0 6px;
  letter-spacing: 0;
}

.m3-nav__item {
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid transparent;
  transition: none;
}

.m3-nav__item:hover {
  transform: none;
  border-color: var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-high);
}

.m3-nav__item--active,
.m3-nav__item.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
  box-shadow: none;
}

.m3-nav__footer {
  margin-top: 12px;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.m3-main {
  min-height: 100vh;
  border: 0;
  background: var(--md-sys-color-surface-container-lowest);
}

.m3-topbar {
  min-height: 64px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest);
}

.m3-content {
  background: var(--md-sys-color-surface-container-lowest);
}

.m3-btn {
  min-height: 40px;
  border: 1px solid var(--md-sys-color-outline-variant);
  transition: none;
}

.m3-btn--filled,
.m3-btn--tonal {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: none;
}

.m3-btn--filled:hover {
  transform: none;
  box-shadow: none;
}

.m3-btn--outlined,
.m3-btn--text,
.m3-icon-btn,
.m3-card {
  background: transparent;
}

.m3-icon-btn:hover {
  background: var(--md-sys-color-surface-container-high);
}
