/* ============================================================================
   SESTO.SENSO Portal v2 — Base layout
   ============================================================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-ambient);
  color: var(--text-primary);
  transition: background var(--d-slow) var(--ease-standard),
              color var(--d-slow) var(--ease-standard);
  overflow-x: hidden;
  min-height: 100vh;
}

button { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ============================================================================
   APP SHELL
   ============================================================================ */
.app {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}
.app.is-ready { display: flex; }

/* ----- HEADER ----- */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--bg-shell-solid);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 1px 2px rgba(40, 50, 70, .03);
  position: sticky;
  top: 0;
  z-index: 500;
  transition: background var(--d-slow) var(--ease-standard),
              border-color var(--d-slow) var(--ease-standard);
}
html[data-theme="dark"] .header {
  background: var(--bg-shell-solid);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

.header-logo {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: .06em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-logo em { color: var(--pink); font-style: normal; }

.header-ag {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--text-tertiary);
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-pill {
  padding: 5px 11px;
  background: var(--bg-input);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-sunken), var(--shadow-inner-top);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.user-btn {
  padding: 6px 12px;
  background: var(--bg-inverse);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), var(--shadow-cushion);
  transition: filter var(--d-fast) var(--ease-standard);
}
.user-btn:hover { filter: brightness(1.15); }

/* ----- THEME TOGGLE ----- */
.theme-switch { position: relative; }
.theme-switch input { display: none; }
.theme-switch label {
  font-size: 1.4rem;
  height: 1em;
  width: 2.5em;
  border-radius: .3em;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  padding: 0 .15em;
  align-items: center;
  background: var(--bg-sunken);
  box-shadow: var(--shadow-sunken);
  position: relative;
  transition: background var(--d-slow) var(--ease-standard);
}
.theme-switch input:checked + label {
  background: linear-gradient(180deg, #15151B 0%, #0F0F14 100%);
}
.theme-switch label:active { transform: scale(.92); transition: transform .2s; }
.theme-switch label .knob {
  width: .8em;
  height: .8em;
  border-radius: .22em;
  position: absolute;
  top: .1em;
  left: .1em;
  z-index: 10;
  transition: .5s var(--ease-bounce), background .3s ease;
  background: #F5F2ED;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), 0 2px 4px rgba(0, 0, 0, .15);
}
.theme-switch input:checked + label .knob {
  left: 1.6em;
  background: var(--pink-gradient);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 2px 8px rgba(212, 23, 94, .4);
}
.theme-switch label svg { height: .7em; width: .7em; z-index: 5; opacity: .6; }
.theme-switch label .icon-sun { color: #D97706; }
.theme-switch label .icon-moon { color: #94A3B8; }

/* ----- BODY (sidebar + main) ----- */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ----- SIDEBAR ----- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  padding: 20px 14px;
  background: var(--bg-shell-solid);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: background var(--d-slow) var(--ease-standard),
              border-color var(--d-slow) var(--ease-standard);
}

.sidebar-section {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 14px 10px 8px;
}
.sidebar-section:first-child { padding-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  margin-bottom: 2px;
  width: 100%;
  text-align: left;
  transition: all var(--d-fast) var(--ease-standard);
}
.nav-item:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--pink-gradient);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25),
              inset 0 -1px 0 rgba(0, 0, 0, .1),
              var(--shadow-pink);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--bg-input);
  box-shadow: var(--shadow-inner-top);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user-ava {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--bg-inverse);
  color: var(--text-inverse);
  font-family: var(--font-display);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; flex: 1; }
.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .12em;
}
.sidebar-signout {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--r-sm);
  transition: color var(--d-fast) var(--ease-standard);
}
.sidebar-signout:hover { color: var(--pink); }

/* ----- MAIN ----- */
main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px;
  overflow-x: hidden;
}

/* ----- PAGE HEADER ----- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 24px;
  flex-wrap: wrap;
}
.page-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 42px;
  letter-spacing: .02em;
  line-height: 1;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.page-title em,
.page-title .accent {
  color: var(--pink);
  font-style: normal;
}
.page-sub,
.page-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.page-sub .pink { color: var(--pink); }
.page-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ----- MOBILE ----- */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 99;
}
@media (max-width: 880px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--d-base) var(--ease-decelerate);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-backdrop.open { display: block; }
  main { padding: 20px 18px; }
  .page-title { font-size: 32px; }
}
