/* =============================================================
   ENVIROSPAN COMPLIANCE OS — main.css
   Core layout: reset, body, sidebar, header, content areas
   ============================================================= */

@import url('variables.css');

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family:    var(--font-family);
  font-size:      var(--font-size-base);
  line-height:    var(--line-height-normal);
  color:          var(--color-text);
  background:     var(--color-bg);
  min-height:     100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-link); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-link-hover); }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: var(--font-family); }
ul, ol { list-style: none; }
p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

/* ── App Shell ───────────────────────────────────────── */
.app-shell {
  display:   flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width:      var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position:   fixed;
  top:        0;
  left:       0;
  bottom:     0;
  display:    flex;
  flex-direction: column;
  z-index:    var(--z-sticky);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition-normal);
}

.sidebar-logo {
  padding:     var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo a {
  display:     flex;
  align-items: center;
  gap:         var(--space-3);
  color:       var(--color-text-inverse);
  font-weight: var(--font-weight-bold);
  font-size:   var(--font-size-lg);
  text-decoration: none;
}

.sidebar-logo img { width: 32px; height: 32px; object-fit: contain; }

.sidebar-logo .site-name { white-space: nowrap; overflow: hidden; }

.sidebar-user {
  padding:       var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink:   0;
}

.sidebar-user .user-name {
  color:       var(--sidebar-text-active);
  font-weight: var(--font-weight-semibold);
  font-size:   var(--font-size-sm);
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-role {
  color:     var(--sidebar-text);
  font-size: var(--font-size-xs);
  margin-top: 2px;
  text-transform: capitalize;
}

.sidebar-nav { flex: 1; padding: var(--space-3) 0; }

.sidebar-nav-section {
  padding:     var(--space-4) var(--space-6) var(--space-2);
  font-size:   var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color:       rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.sidebar-nav a {
  display:     flex;
  align-items: center;
  gap:         var(--space-3);
  padding:     var(--space-2) var(--space-6);
  color:       var(--sidebar-text);
  font-size:   var(--font-size-sm);
  transition:  background var(--transition-fast), color var(--transition-fast);
  border-radius: 0;
  white-space: nowrap;
  overflow:    hidden;
}

.sidebar-nav a:hover {
  background: var(--sidebar-item-hover);
  color:      var(--sidebar-text-active);
}

.sidebar-nav a.active {
  background: var(--sidebar-item-active);
  color:      var(--sidebar-text-active);
  font-weight: var(--font-weight-semibold);
  border-right: 3px solid var(--color-secondary);
}

.sidebar-nav a .nav-icon {
  width:     18px;
  height:    18px;
  flex-shrink: 0;
  opacity:   0.75;
}

.sidebar-nav a.active .nav-icon,
.sidebar-nav a:hover .nav-icon { opacity: 1; }

.sidebar-footer {
  padding:       var(--space-4) var(--space-6);
  border-top:    1px solid var(--sidebar-border);
  flex-shrink:   0;
}

.sidebar-footer a {
  color:     var(--sidebar-text);
  font-size: var(--font-size-sm);
}

.sidebar-footer a:hover { color: var(--sidebar-text-active); }

/* ── Main Content Area ───────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex:        1;
  display:     flex;
  flex-direction: column;
  min-height:  100vh;
}

/* ── Top Header ──────────────────────────────────────── */
.top-header {
  height:     var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  box-shadow: var(--header-shadow);
  display:    flex;
  align-items: center;
  justify-content: space-between;
  padding:    0 var(--space-8);
  position:   sticky;
  top:        0;
  z-index:    var(--z-sticky);
}

.top-header .page-title {
  font-size:   var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color:       var(--color-text);
}

.top-header .header-actions {
  display:    flex;
  align-items: center;
  gap:        var(--space-4);
}

.top-header .impersonation-bar {
  background:  #fff3cd;
  border:      1px solid #ffc107;
  border-radius: var(--radius-md);
  padding:     4px var(--space-3);
  font-size:   var(--font-size-xs);
  color:       #856404;
  display:     flex;
  align-items: center;
  gap:         var(--space-2);
}

/* ── Page Content ────────────────────────────────────── */
.page-content {
  flex:    1;
  padding: var(--space-8);
  max-width: 1400px;
  width:   100%;
}

.page-header {
  display:     flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  gap:         var(--space-4);
  flex-wrap:   wrap;
}

.page-header h1 {
  font-size:   var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color:       var(--color-text);
  line-height: var(--line-height-tight);
}

.page-header .page-subtitle {
  color:     var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-top: var(--space-1);
}

/* ── Breadcrumb ──────────────────────────────────────── */
.breadcrumb {
  display:     flex;
  align-items: center;
  gap:         var(--space-2);
  font-size:   var(--font-size-sm);
  color:       var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb .sep { color: var(--color-border-dark); }
.breadcrumb .current { color: var(--color-text); font-weight: var(--font-weight-medium); }

/* ── Divider ─────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--color-border); margin: var(--space-6) 0; }

/* ── Auth pages (login, register) ────────────────────── */
.auth-page {
  min-height:  100vh;
  background:  var(--color-bg);
  display:     flex;
  align-items: center;
  justify-content: center;
  padding:     var(--space-6);
}

.auth-card {
  background:    var(--color-bg-card);
  border-radius: var(--radius-xl);
  box-shadow:    var(--shadow-xl);
  padding:       var(--space-10);
  width:         100%;
  max-width:     440px;
}

.auth-logo {
  text-align:  center;
  margin-bottom: var(--space-8);
}

.auth-logo img { height: 48px; margin: 0 auto var(--space-3); }

.auth-logo .brand-name {
  font-size:   var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color:       var(--color-primary);
}

.auth-logo .brand-tagline {
  font-size: var(--font-size-sm);
  color:     var(--color-text-muted);
}

.auth-footer {
  text-align:  center;
  margin-top:  var(--space-6);
  font-size:   var(--font-size-sm);
  color:       var(--color-text-muted);
}

.auth-footer a { color: var(--color-primary); font-weight: var(--font-weight-medium); }
