/* global.css */
:root {
  --bg: #F3FAF8;
  --surface: #FFFFFF;
  --surface-alt: #EAF6F1;
  --line: #DCEEE7;
  --line-soft: #E9F4F0;
  --ink: #12302A;
  --ink-soft: #54726A;
  --ink-faint: #93AEA5;
  --primary: #146356;
  --primary-hover: #0F4F45;
  --primary-tint: #E3F1EC;
  --leaf: #59C3A6;
  --sky: #5FA9CE;
  --sky-soft: #E3F1F8;
  --leaf-soft: #DFF3EA;
  --status-on: #2FAE66;
  --status-on-soft: #E3F6EA;
  --status-off: #C9634F;
  --status-off-soft: #FBEAE6;
  --status-dr: #5B7FD9;
  --status-dr-soft: #E9EDFB;
  --status-warn: #F5A623;
  --status-warn-soft: #FEF4E6;
  --shadow-sm: 0 2px 8px -4px rgba(18,48,40,0.10);
  --shadow-md: 0 10px 28px -14px rgba(18,48,40,0.22);
  --shadow-lg: 0 24px 60px -20px rgba(18,48,40,0.30);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --font-display: 'Manrope', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 2.5px solid var(--sky);
  outline-offset: 2px;
  border-radius: 6px;
}

#app {
  min-height: 100vh;
  position: relative;
}

/* ===================== SHARED: LOGO ===================== */
/*
.logo {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--sky) 0%, var(--leaf) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.logo-mark svg {
  width: 20px;
  height: 20px;
}
  */

.logo-word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}

.logo-word span {
  color: var(--primary);
}

.logo-sub {
  font-size: .66rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
  margin-top: 2px;
}

/* ===================== SHARED: LANG TOGGLE ===================== */
.lang-toggle {
  display: flex;
  background: var(--surface-alt);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.lang-toggle button {
  border: none;
  background: transparent;
  padding: .35rem .8rem;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: .03em;
  transition: background .18s, color .18s;
}

.lang-toggle button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn svg {
  width: 18px;
  height: 18px;
}

/* Primary Button (Green) */
.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(20, 99, 86, 0.2);
}

.btn-primary:hover {
  background: #105247; /* Slightly darker green */
  box-shadow: 0 4px 12px rgba(20, 99, 86, 0.3);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(20, 99, 86, 0.2);
}

/* Secondary Button (Optional, for future use) */
.btn-secondary {
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  background: var(--line);
}

/* ==================== USER BANNER (TOP RIGHT) ==================== */

.user-chip { display: flex; align-items: center; gap: .6rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sky), var(--leaf));
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: .78rem;
  display: flex; align-items: center; justify-content: center;
}
.user-meta { line-height: 1.25; }
.user-meta .name { font-size: .82rem; font-weight: 700; color: var(--ink); }
.user-meta .role { font-size: .68rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }

/* ===================== SHARED: TOPBAR ===================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(243,250,248,0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: .9rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-left { display: flex; align-items: center; gap: 1.5rem; }

.plant-select {
  display: flex; align-items: center; gap: .4rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: .4rem .9rem .4rem .7rem;
  font-size: .82rem; font-weight: 600; color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.plant-select .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--status-on); }
.plant-select svg { width: 15px; height: 15px; color: var(--ink-faint); }

.topbar-right { display: flex; align-items: center; gap: 1.1rem; }

.clock {
  font-family: var(--font-mono); font-size: .8rem; color: var(--ink-soft);
  display: flex; align-items: center; gap: .4rem;
}
.clock svg { width: 14px; height: 14px; color: var(--ink-faint); }

.icon-btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--status-off-soft); color: var(--status-off); border-color: var(--status-off); }
.icon-btn svg { width: 17px; height: 17px; }

.back-link {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.85rem; font-weight: 700; color: var(--ink-soft);
  text-decoration: none; transition: color 0.15s, transform 0.15s;
}
.back-link svg { width: 18px; height: 18px; transition: transform 0.15s; }
.back-link:hover { color: var(--primary); }
.back-link:hover svg { transform: translateX(-3px); }

/* ===================== SHARED: BADGES & TAGS ===================== */
.status-badge {
  display: flex; align-items: center; gap: .35rem;
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: .28rem .6rem; border-radius: 999px; white-space: nowrap;
}
.status-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.charging { background: var(--status-on-soft); color: var(--status-on); }
.status-badge.discharging { background: var(--status-warn-soft); color: var(--status-warn); }
.status-badge.idle { background: var(--sky-soft); color: var(--sky); }
.status-badge.error { background: #ffcdc4; color: var(--status-off); }
/* Unit without any battery telemetry: no state, so no colour either */
.status-badge.no-data { background: var(--surface-alt); color: var(--ink-faint); }

.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .6rem; border-radius: 999px;
  font-weight: 700; font-size: .7rem;
  text-transform: uppercase; letter-spacing: .04em;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-error { background: var(--status-off-soft); color: var(--status-off); }
.badge-warning { background: #FFF4E5; color: #FF9800; }
.badge-active { background: var(--status-on-soft); color: var(--status-on); }
.badge-scheduled { background: #FFF4E5; color: #FF9800; }
.status-active { font-weight: 700; color: var(--ink); }
.status-resolved { font-weight: 600; color: var(--ink-faint); }

.tag { font-size: .68rem; font-weight: 600; padding: .24rem .55rem; border-radius: 6px; background: var(--surface-alt); color: var(--ink-soft); }

/* ===================== SHARED: FORMS, SEARCH & FILTERS ===================== */
.field { margin-bottom: 1.15rem; }
.field label { display: block; font-size: .78rem; font-weight: 600; color: var(--ink); margin-bottom: .4rem; }
.field-input { position: relative; display: flex; align-items: center; }
.field-input input {
  width: 100%; border: 1.5px solid var(--line); background: var(--surface);
  border-radius: var(--radius-sm); padding: .78rem .9rem; font-size: .92rem;
  color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.field-input input::placeholder { color: var(--ink-faint); }
.field-input input:focus { border-color: var(--sky); box-shadow: 0 0 0 4px var(--sky-soft); outline: none; }
.field-input.has-toggle input { padding-right: 2.6rem; }

.pw-toggle {
  position: absolute; right: .7rem; background: none; border: none;
  color: var(--ink-faint); display: flex; padding: .2rem; border-radius: 6px;
}
.pw-toggle:hover { color: var(--ink-soft); }
.pw-toggle svg { width: 18px; height: 18px; }

.field-error { font-size: .76rem; color: var(--status-off); margin-top: .4rem; display: none; align-items: center; gap: .35rem; }
.field.invalid input { border-color: var(--status-off); box-shadow: 0 0 0 4px var(--status-off-soft); }
.field.invalid .field-error { display: flex; }

.field-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; font-size: .82rem; }
.remember { display: flex; align-items: center; gap: .5rem; color: var(--ink-soft); cursor: pointer; }
.remember input { width: 15px; height: 15px; accent-color: var(--primary); }
.forgot-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.forgot-link:hover { text-decoration: underline; }

.demo-hint {
  margin-top: 1.3rem; text-align: center; font-size: .78rem;
  color: var(--ink-faint); background: var(--surface-alt);
  border-radius: var(--radius-sm); padding: .65rem .8rem;
}
.demo-hint b { color: var(--ink-soft); font-family: var(--font-mono); font-weight: 500; }

.switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--line); transition: .3s; border-radius: 24px;
}
.slider:before {
  position: absolute; content: ""; height: 18px; width: 18px;
  left: 3px; bottom: 3px; background-color: white; transition: .3s;
  border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
input:checked + .slider { background-color: var(--status-on); }
input:focus + .slider { box-shadow: 0 0 0 3px var(--status-on-soft); }
input:checked + .slider:before { transform: translateX(22px); }

.search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search-wrap svg { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-faint); }
.search-wrap input {
  width: 100%; border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: .6rem 1rem .6rem 2.4rem; font-size: .84rem; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.search-wrap input:focus { border-color: var(--sky); box-shadow: 0 0 0 4px var(--sky-soft); outline: none; }

.filter-pills { display: flex; gap: .5rem; flex-wrap: wrap; }
.pill {
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: 999px; padding: .5rem 1rem; font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; gap: .4rem; transition: all .15s;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .6; }
.pill:hover { border-color: var(--sky); color: var(--ink); }
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pill.active .dot { background: #fff; opacity: 1; }

.view-toggle { display: flex; background: var(--surface-alt); border-radius: 10px; padding: 3px; gap: 2px; }
.view-toggle button {
  border: none; background: transparent; padding: .5rem .8rem; border-radius: 8px;
  font-size: .78rem; font-weight: 700; color: var(--ink-soft); display: flex; align-items: center; gap: .4rem;
}
.view-toggle button svg { width: 15px; height: 15px; }
.view-toggle button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ===================== SHARED: SOC BARS & ANIMATIONS ===================== */
.soc-top { display: flex; justify-content: space-between; align-items: baseline; }
.soc-top .lbl { font-size: .68rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.soc-top .pct { font-family: var(--font-mono); font-size: .85rem; font-weight: 600; color: var(--ink); }

.soc-bar { height: 8px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.soc-fill { height: 100%; border-radius: 999px; transition: width 0.5s ease; }
.soc-fill.idle { background: var(--sky); }
.soc-fill.error { background: var(--status-off); }
.soc-fill.no-data { background: var(--ink-faint); }

@keyframes charge-flow {
  from { background-position: 0 0; }
  to { background-position: 28px 0; }
}
@keyframes discharge-flow {
  from { background-position: 28px 0; }
  to { background-position: 0 0; }
}

.soc-fill.charging {
  background-image: linear-gradient(45deg, rgba(255,255,255,.25) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.25) 50%, rgba(255,255,255,.25) 75%, transparent 75%, transparent);
  background-size: 28px 28px;
  background-color: var(--status-on);
  animation: charge-flow 1s linear infinite;
}

.soc-fill.discharging {
  background-image: linear-gradient(45deg, rgba(255,255,255,.25) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.25) 50%, rgba(255,255,255,.25) 75%, transparent 75%, transparent);
  background-size: 28px 28px;
  background-color: var(--status-warn);
  animation: discharge-flow 1s linear infinite;
}

@keyframes move-stripes {
  0% { background-position: 0 0; }
  100% { background-position: 1rem 0; }
}
.charging-anim {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.15) 75%,
    transparent 75%,
    transparent
  );
  background-size: 1rem 1rem;
  animation: move-stripes 1s linear infinite;
  background-color: var(--status-on);
}

/* ===================== SHARED: TITLES & EMPTY STATE ===================== */
.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
  margin-bottom: 1.2rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.empty-state {
  grid-column: 1 / -1; text-align: center; padding: 3.5rem 1.5rem;
  background: var(--surface); border: 1.5px dashed var(--line); border-radius: var(--radius-lg);
  color: var(--ink-soft);
}
.empty-state svg { width: 38px; height: 38px; color: var(--ink-faint); margin: 0 auto 1rem; }
.empty-state h3 { font-family: var(--font-display); font-size: 1.05rem; color: var(--ink); margin-bottom: .35rem; }
.empty-state p { font-size: .85rem; max-width: 320px; margin: 0 auto; }