/* ============================================================
   ELECTRICAL HUB - CORE STYLES
   Aesthetic: Industrial HMI Precision
   ============================================================ */

/* ========== THEME VARIABLES ========== */
:root[data-theme="dark"] {
  --bg-base: #0A0E1A;
  --bg-panel: #111726;
  --bg-elevated: #1A2235;
  --bg-input: #0D1321;
  --border-subtle: #1F2A40;
  --border-strong: #2A3A55;
  --text-primary: #E8EEF7;
  --text-secondary: #8B9AB3;
  --text-muted: #4A5874;
  --accent-primary: #00D9FF;
  --accent-primary-dim: #00D9FF33;
  --accent-warning: #FFB800;
  --accent-danger: #FF4757;
  --accent-success: #2ED573;
  --accent-purple: #A78BFA;
  --grid-line: rgba(0, 217, 255, 0.04);
  --glow-primary: 0 0 20px rgba(0, 217, 255, 0.3);
  --shadow-panel: 0 4px 24px rgba(0, 0, 0, 0.4);
}

:root[data-theme="light"] {
  --bg-base: #F5F6F8;
  --bg-panel: #FFFFFF;
  --bg-elevated: #FAFBFC;
  --bg-input: #F5F6F8;
  --border-subtle: #E4E7EC;
  --border-strong: #CDD2DA;
  --text-primary: #1D3557;
  --text-secondary: #5A6A80;
  --text-muted: #9AA5B5;
  --accent-primary: #E63946;
  --accent-primary-dim: #E6394622;
  --accent-warning: #F77F00;
  --accent-danger: #D62828;
  --accent-success: #2A9D8F;
  --accent-purple: #6A4C93;
  --grid-line: rgba(29, 53, 87, 0.04);
  --glow-primary: 0 2px 8px rgba(230, 57, 70, 0.15);
  --shadow-panel: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(29, 53, 87, 0.06);
}

* { -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  transition: background-color 0.3s, color 0.3s;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========== PANELS ========== */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-panel);
}

.panel-flat {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
}

/* ========== SIDEBAR ========== */
.sidebar-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  font-size: 14px;
}
.sidebar-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.sidebar-item.active { background: var(--accent-primary-dim); color: var(--accent-primary); }
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent-primary);
  border-radius: 0 2px 2px 0;
  box-shadow: var(--glow-primary);
}
.sidebar-item i { width: 16px; text-align: center; font-size: 13px; }
.sidebar-item .badge {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}
.sidebar-item.locked { opacity: 0.5; }
.sidebar-item.locked .badge { color: var(--accent-warning); border-color: var(--accent-warning); }

.sidebar-group-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 14px;
  margin: 20px 0 8px;
}

/* ========== LOGO ========== */
.logo-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-purple) 100%);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0A0E1A;
  font-weight: 800;
  font-size: 18px;
  box-shadow: var(--glow-primary);
  position: relative;
}
.logo-mark::after {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 7px;
}

/* ========== STATUS DOT ========== */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-success);
  position: relative;
  display: inline-block;
}
.status-dot::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--accent-success);
  opacity: 0.3;
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(2); opacity: 0; }
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  white-space: nowrap;
  font-family: inherit;
}
.btn-primary {
  background: var(--accent-primary);
  color: #0A0E1A;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ========== INPUTS ========== */
.input-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.input-field {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.15s;
  outline: none;
  box-sizing: border-box;
}
.input-field:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-dim);
}
.input-group { position: relative; }
.input-suffix-inline {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

select.input-field {
  font-family: inherit;
  font-size: 13px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B9AB3' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ========== SEGMENTED CONTROL ========== */
.segmented {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
  border: none;
  font-family: inherit;
}
.segmented button.active {
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
:root[data-theme="light"] .segmented button.active {
  background: var(--accent-primary);
  color: white;
}

/* ========== RESULT CARDS ========== */
.result-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}
.result-card.highlight {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary), var(--glow-primary);
}
.result-card.highlight::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-purple));
}
.result-card .card-icon {
  width: 32px; height: 32px;
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.result-card .card-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.result-card .card-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-top: 4px;
}
.result-card .card-value .unit {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 4px;
}
.result-card .card-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ========== LOCK OVERLAY ========== */
.locked-card .card-content {
  filter: blur(4px);
  opacity: 0.4;
  user-select: none;
  pointer-events: none;
}
.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(180deg, transparent 0%, var(--bg-elevated) 60%);
  border-radius: 10px;
}
.lock-overlay i {
  font-size: 18px;
  color: var(--accent-warning);
}
.lock-overlay .lock-text {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}
.lock-overlay .lock-cta {
  font-size: 11px;
  color: var(--accent-primary);
  font-weight: 600;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.lock-overlay .lock-cta:hover { text-decoration: underline; }

/* ========== BADGES ========== */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.badge-success { background: rgba(46, 213, 115, 0.12); color: var(--accent-success); border-color: rgba(46, 213, 115, 0.3); }
.badge-warning { background: rgba(255, 184, 0, 0.12); color: var(--accent-warning); border-color: rgba(255, 184, 0, 0.3); }
.badge-danger  { background: rgba(255, 71, 87, 0.12); color: var(--accent-danger); border-color: rgba(255, 71, 87, 0.3); }
.badge-info    { background: var(--accent-primary-dim); color: var(--accent-primary); border-color: var(--accent-primary); }
.badge-pro     { background: linear-gradient(135deg, #A78BFA22, #00D9FF22); color: var(--accent-purple); border-color: var(--accent-purple); }

/* ========== LEVEL SWITCHER ========== */
.level-switcher {
  background: var(--bg-input);
  border: 1px dashed var(--accent-warning);
  border-radius: 10px;
  padding: 10px 14px;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.4s ease-out backwards; }
.fade-in:nth-child(1) { animation-delay: 0.05s; }
.fade-in:nth-child(2) { animation-delay: 0.1s; }
.fade-in:nth-child(3) { animation-delay: 0.15s; }
.fade-in:nth-child(4) { animation-delay: 0.2s; }
.fade-in:nth-child(5) { animation-delay: 0.25s; }
.fade-in:nth-child(6) { animation-delay: 0.3s; }

/* ========== INFO BOX ========== */
.info-box {
  background: var(--bg-input);
  border-left: 3px solid var(--accent-primary);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.info-box.level-warning { border-left-color: var(--accent-warning); }
.info-box.level-danger { border-left-color: var(--accent-danger); }
.info-box.level-success { border-left-color: var(--accent-success); }
.info-box.level-info { border-left-color: var(--accent-primary); }
.info-box strong { color: var(--text-primary); font-weight: 600; }

/* ========== SECTION TITLE ========== */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-subtle), transparent);
}

/* ========== BREADCRUMB ========== */
.breadcrumb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.breadcrumb span.separator { margin: 0 6px; opacity: 0.5; }
.breadcrumb span.current { color: var(--accent-primary); }

/* ========== TOAST ========== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-panel);
  animation: fadeInUp 0.3s ease-out;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.toast-success { border-left: 3px solid var(--accent-success); }
.toast.toast-error { border-left: 3px solid var(--accent-danger); }
.toast.toast-warning { border-left: 3px solid var(--accent-warning); }

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  #sidebar { display: none; }
}
