/* ============================================================
   EcoLag AI — layout.css
   App Shell · Top Nav · Bottom Nav · Grid · Sections · Responsive
   ============================================================ */

/* ── APP SHELL ── */
#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOP NAV (desktop) ── */
#topnav {
  display: none; /* shown via JS after login */
  align-items: center;
  padding: 0 28px;
  height: 60px;
  background: rgba(10, 22, 40, 0.97);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
  gap: 6px;
}

.nav-logo {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 2px;
  cursor: pointer;
  user-select: none;
  margin-right: 8px;
}
.nav-logo .y { color: var(--y); }
.nav-logo .g { color: var(--g2); }

.nav-links {
  display: flex;
  gap: 2px;
  margin-left: auto;
  margin-right: 14px;
}
.nav-link {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 8px 13px;
  border-radius: 10px;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-link:hover  { color: white; background: rgba(255, 255, 255, 0.05); }
.nav-link.active { color: var(--g2); background: rgba(0, 168, 89, 0.1); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-avatar {
  width: 36px; height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  border: 2px solid rgba(0, 168, 89, 0.3);
  cursor: pointer;
  overflow: hidden;
}
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }

.logout-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); }

/* ── BOTTOM NAV (mobile) ── */
#bottomnav {
  display: none; /* shown via JS on mobile after login */
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(8, 14, 26, 0.97);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  flex-direction: row;
  padding: 8px 0 max(16px, env(safe-area-inset-bottom));
  z-index: 100;
}
.bnav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}
.bnav-icon {
  font-size: 19px;
  width: 40px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  transition: all 0.2s;
}
.bnav-btn.active .bnav-icon { background: rgba(0, 135, 83, 0.18); }
.bnav-lbl {
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.2s;
}
.bnav-btn.active .bnav-lbl { color: var(--g2); font-weight: 600; }

/* ── MAIN SCROLL AREA ── */
#main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 80px; /* space for fixed bottom nav */
}

@media (min-width: 768px) {
  #main { padding-bottom: 0; }
}

/* ── SECTIONS (pages) ── */
.section {
  display: none;
  padding: 22px 18px 120px;
  min-height: 100%;
}
.section.active { display: block; animation: fadeIn 0.25s ease; }

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 22px; }
.ph-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 21px;
  color: white;
  margin-bottom: 4px;
}
.ph-sub {
  font-size: 13px;
  color: var(--muted);
}

/* ── GREETING ROW ── */
.greeting-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.greeting-name {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 22px;
  color: white;
}
.greeting-sub { font-size: 12px; color: var(--muted); }

.dash-avatar-wrap { position: relative; cursor: pointer; }
.dash-avatar {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  border: 2px solid rgba(0, 168, 89, 0.3);
  overflow: hidden;
}
.dash-avatar img { width: 100%; height: 100%; object-fit: cover; }
.notif-dot {
  position: absolute;
  top: -4px; right: -4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: white;
}

/* ── GRID SYSTEM ── */
.g2 { display: grid; grid-template-columns: 1fr 1fr;            gap: 14px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr;        gap: 13px; }
.g4 { display: grid; grid-template-columns: repeat(4, 1fr);     gap: 12px; }
.g5 { display: grid; grid-template-columns: repeat(5, 1fr);     gap: 12px; }

/* Two-col layout — stacks on mobile */
.two-col { display: flex; flex-direction: column; gap: 16px; }

/* ── CAMERA OVERLAY ── */
#camera-overlay {
  display: none;
  position: fixed; inset: 0;
  z-index: 300;
  background: #000;
  flex-direction: column;
}
#camera-video {
  width: 100%; height: 100%;
  object-fit: cover;
  position: absolute; inset: 0;
}
.cam-ui { position: absolute; inset: 0; display: flex; flex-direction: column; }
.cam-top {
  padding: 50px 20px 16px;
  background: linear-gradient(180deg, rgba(0,0,0,0.7), transparent);
}
.cam-bottom {
  margin-top: auto;
  padding: 20px 32px 48px;
  background: linear-gradient(0deg, rgba(0,0,0,0.75), transparent);
  display: flex; align-items: center; justify-content: space-between;
}
.cam-shutter {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: white;
  border: 4px solid rgba(255,255,255,0.5);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 8px rgba(255,255,255,0.15);
  transition: transform 0.1s;
}
.cam-shutter:active { transform: scale(0.94); }
.cam-close {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  border: none; cursor: pointer;
  font-size: 20px; color: white;
}
.cam-corner { position: absolute; width: 26px; height: 26px; }
.cam-corner.tl { top: 80px; left: 30px; border-top: 3px solid var(--g2); border-left: 3px solid var(--g2); }
.cam-corner.tr { top: 80px; right: 30px; border-top: 3px solid var(--g2); border-right: 3px solid var(--g2); }
.cam-corner.bl { bottom: 140px; left: 30px; border-bottom: 3px solid var(--g2); border-left: 3px solid var(--g2); }
.cam-corner.br { bottom: 140px; right: 30px; border-bottom: 3px solid var(--g2); border-right: 3px solid var(--g2); }
.cam-grid-line-h {
  position: absolute; left: 0; right: 0; height: 1px;
  background: rgba(255,255,255,0.08);
}
.cam-grid-line-v {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: rgba(255,255,255,0.08);
}

/* ── AUTH PAGE ── */
#auth-page {
  position: fixed; inset: 0;
  z-index: 200;
  background: linear-gradient(160deg, #030d06, #061a0e, #081a26);
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px 40px;
}
.auth-bg {
  position: fixed; inset: 0;
  overflow: hidden; pointer-events: none; z-index: 0;
}
.auth-bg .ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(0, 135, 83, 0.07);
}
.auth-wrap {
  width: 100%;
  max-width: 430px;
  display: flex;
  flex-direction: column;
  gap: 0;
  animation: fadeUp 0.6s ease;
  position: relative;
  z-index: 1;
  padding-top: 16px;
}
.auth-logo   { text-align: center; padding: 0 0 24px; }
.auth-icon {
  width: 68px; height: 68px;
  border-radius: 20px;
  background: rgba(0, 135, 83, 0.2);
  border: 1px solid rgba(0, 135, 83, 0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 12px;
  animation: glow 3s ease infinite;
}
.auth-brand {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 24px;
  letter-spacing: 2px;
}
.auth-sub {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 4px;
  margin-top: 4px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
  background: var(--card);
  border-radius: var(--r-xl);
  padding: 26px;
  border: 1px solid var(--border2);
}
.auth-foot {
  text-align: center;
  margin-top: 14px;
  font-size: 11px;
  color: var(--muted);
}

/* ── FILTER BAR ── */
.filter-bar {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  color: white;
  outline: none;
  cursor: pointer;
}
.filter-select option { background: var(--card); }
.search-input {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 13px;
  font-family: var(--font-body);
  font-size: 12px;
  color: white;
  outline: none;
  flex: 1;
  min-width: 180px;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: rgba(0, 168, 89, 0.4); }

/* ── TABLE ── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tbl td {
  padding: 12px 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13px;
  color: white;
  vertical-align: middle;
}
.tbl tr:hover td { background: rgba(255,255,255,0.02); }
.tbl tr:last-child td { border-bottom: none; }

/* ── RESPONSIVE ── */
@media (min-width: 768px) {
  #topnav    { display: flex; }
  #bottomnav { display: none !important; }

  .section   { padding: 32px 40px 60px; }
  .g4        { grid-template-columns: repeat(4, 1fr); }
  .two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }

  #toast     { bottom: 24px; }
}

@media (max-width: 767px) {
  #topnav    { display: none !important; }
  #bottomnav { display: flex; }

  .g2 { grid-template-columns: 1fr 1fr; }
  .g4 { grid-template-columns: 1fr 1fr; }
  .g5 { grid-template-columns: 1fr 1fr; }

  .hero-card { padding: 18px; }
  .cd-val    { font-size: 19px; min-width: 46px; }
  .ph-title  { font-size: 19px; }
  .stat-val  { font-size: 20px; }

  .two-col   { display: flex; flex-direction: column; gap: 16px; }

  /* Toast sits above the nav */
  #toast { bottom: 80px; }
}

/* ── BOTTOM NAV — always solid, always on top ── */
#bottomnav {
  box-shadow: 0 -1px 0 rgba(255,255,255,0.07), 0 -4px 16px rgba(0,0,0,0.5);
  z-index: 200;
}