/* ── Energy Audit — Shared Stylesheet ──
   Issue 12 fix: design tokens and common components live here once.
   All 4 pages link to this file. Change a colour here → updates everywhere.
*/

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

/* ── Design Tokens ── */
:root {
  /* Backgrounds */
  --bg:  #080b12;
  --bg1: #0e1320;
  --bg2: #141925;
  --bg3: #1a2030;
  --bg4: #1f2840;

  /* Borders */
  --bdr:  #1f2840;
  --bdr2: #2a3550;

  /* Text */
  --tx0: #eef0f6;
  --tx1: #7a8aaa;
  --tx2: #3d4d6a;

  /* Green — primary brand colour */
  --grn:      #1db87a;
  --grn1:     #0f9460;
  --grn-glow: rgba(29,184,122,0.18);
  --grn-bg:   rgba(29,184,122,0.08);
  --grn-tx:   #75e0b2;
  --grn3:     rgba(8,30,22,0.9);

  /* Blue */
  --blu:    #2d6be4;
  --blu-bg: rgba(45,107,228,0.10);
  --blu-tx: #80aaff;
  --blu0:   #1e3a6e;

  /* Purple */
  --pur:    #7c5cbf;
  --pur-bg: rgba(124,92,191,0.10);
  --pur-tx: #c4b0ff;
  --pur0:   #2d2060;

  /* Orange */
  --org:    #d97b2e;
  --org-bg: rgba(217,123,46,0.10);
  --org-tx: #ffb870;

  /* Red */
  --red:    #e05555;
  --red-bg: rgba(224,85,85,0.08);
  --red-tx: #f09595;

  /* Fonts */
  --font-head: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

/* ── Base ── */
html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--tx0);
  font-family: var(--font-mono);
  font-size: 13px;
}



/* ── Layout ── */
.layout  { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg1);
  border-right: 1px solid var(--bdr);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 50;
}
.main { margin-left: 220px; flex: 1; }

.sb-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--bdr);
  display: flex;
  align-items: center;
  gap: 9px;
}
.sb-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--grn), var(--grn1));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.sb-name { font-family: var(--font-head); font-size: 16px; font-weight: 700; }
.sb-name span { color: var(--grn); }

.sb-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sb-section {
  font-size: 9px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--tx2);
  padding: 6px 8px 4px;
  margin-top: 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--tx1);
  cursor: pointer;
  transition: all .15s;
  font-size: 12px;
  text-decoration: none;
  margin-bottom: 1px;
}
.nav-item:hover  { background: var(--bg3); color: var(--tx0); }
.nav-item.active {
  background: var(--grn-bg);
  color: var(--grn);
  border: 1px solid rgba(29,184,122,0.2);
}
.nav-item i { font-size: 16px; flex-shrink: 0; }

.sb-user { padding: 14px; border-top: 1px solid var(--bdr); }
.user-row { display: flex; align-items: center; gap: 9px; }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg4);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  color: var(--grn);
  flex-shrink: 0;
  border: 1px solid var(--bdr2);
}
.user-info  { flex: 1; min-width: 0; }
.user-name  { font-size: 11px; font-weight: 500; color: var(--tx0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 9px; color: var(--tx2); text-transform: uppercase; letter-spacing: 0.5px; }
.logout-btn { background: transparent; border: none; color: var(--tx2); cursor: pointer; padding: 4px; border-radius: 5px; transition: color .15s; }
.logout-btn:hover { color: var(--red); }

/* ── Role badges ── */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.role-badge.admin { background: var(--pur-bg); color: var(--pur-tx); border: 1px solid rgba(124,92,191,0.2); }
.role-badge.user  { background: var(--blu-bg); color: var(--blu-tx); border: 1px solid rgba(45,107,228,0.2); }

/* ── Shared buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--bdr2);
  background: var(--bg2);
  color: var(--tx0);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: var(--font-mono);
}
.btn:hover         { background: var(--bg3); }
.btn.primary       { background: var(--grn); color: #fff; border-color: var(--grn); }
.btn.primary:hover { background: var(--grn1); box-shadow: 0 0 20px var(--grn-glow); }
.btn.danger        { background: var(--red-bg); color: var(--red-tx); border-color: rgba(224,85,85,0.3); }
.btn.danger:hover  { background: rgba(224,85,85,0.2); }
.btn.accent        { background: var(--grn-bg); color: var(--grn-tx); border-color: rgba(29,184,122,0.3); }
.btn.sm            { padding: 4px 9px; font-size: 11px; }
.btn i             { font-size: 14px; }
.btn:disabled      { opacity: 0.5; cursor: not-allowed; }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notification ── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--bg1);
  border: 1px solid var(--grn);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 12px;
  color: var(--grn);
  z-index: 99999;
  display: none;
  align-items: center;
  gap: 8px;
  animation: toastIn .2s ease;
}
.toast.show { display: flex; }
.toast.err  { border-color: var(--red); color: var(--red); }
@keyframes toastIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── Auto-save status indicator ── */
.autosave-indicator {
  font-size: 10px;
  color: var(--tx2);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color .3s;
}
.autosave-indicator.saving { color: var(--org-tx); }
.autosave-indicator.saved  { color: var(--grn); }
.autosave-indicator.error  { color: var(--red-tx); }

/* ── Lightbox ── */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 300000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lightbox.active      { display: flex; }
.lightbox-img         { max-width: 90vw; max-height: 88vh; object-fit: contain; border-radius: 8px; box-shadow: 0 0 60px rgba(0,0,0,0.8); }
.lightbox-close       { position: absolute; top: 18px; right: 22px; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff; font-size: 20px; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s; }
.lightbox-close:hover { background: rgba(224,85,85,0.7); }
.lightbox-nav         { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15); color: #fff; font-size: 18px; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s; user-select: none; }
.lightbox-nav:hover   { background: rgba(255,255,255,0.25); }
.lightbox-prev        { left: 18px; }
.lightbox-next        { right: 18px; }
.lightbox-counter     { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.6); font-size: 11px; font-family: var(--font-mono); }

/* ── Screen-reader only ── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
