/* Import modern fonts from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Prompt:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* Core Color System & Variables */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #131a26;
  --bg-tertiary: #1b2536;
  --glass-bg: rgba(19, 26, 38, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-hover: rgba(255, 255, 255, 0.12);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  /* Neon Electric Colors */
  --electric-blue: #00e5ff;
  --electric-blue-glow: rgba(0, 229, 255, 0.35);
  
  --neon-green: #39ff14;
  --neon-green-glow: rgba(57, 255, 20, 0.35);
  
  --electric-amber: #ff9f00;
  --electric-amber-glow: rgba(255, 159, 0, 0.35);
  
  --neon-purple: #d500f9;
  --neon-purple-glow: rgba(213, 0, 249, 0.35);
  
  --danger-red: #ff3366;
  --danger-glow: rgba(255, 51, 102, 0.35);
  
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  
  --font-thai: 'Prompt', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition-speed: 0.3s;
}

/* Global Reset & Base Styling */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-thai);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 10% 20%, rgba(0, 229, 255, 0.05) 0px, transparent 50%),
    radial-gradient(at 90% 80%, rgba(213, 0, 249, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Navigation Shell & Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition-speed);
}

.logo-section {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--glass-border);
  background: linear-gradient(135deg, rgba(0,229,255,0.05), rgba(213,0,249,0.03));
}

.sidebar-logo-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 10px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.4));
  animation: pulse-glow 3s infinite ease-in-out;
}

.logo-text-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--electric-blue);
  text-transform: uppercase;
  font-family: var(--font-mono);
  opacity: 0.85;
}

.logo-text-block h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(to right, var(--electric-blue), var(--neon-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  margin: 0;
}

.logo-icon {
  font-size: 1.5rem;
  animation: pulse-glow 2s infinite ease-in-out;
}

/* Developer Credit Block */
.developer-credit {
  margin: 10px 14px;
  border-radius: var(--border-radius-sm);
  background: linear-gradient(135deg, rgba(0,229,255,0.06), rgba(213,0,249,0.06));
  border: 1px solid rgba(0, 229, 255, 0.15);
  padding: 10px 12px;
}

.dev-credit-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dev-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.dev-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dev-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-thai);
  line-height: 1.2;
}

.dev-role {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-thai);
  line-height: 1.3;
}

.dev-credit-title {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--electric-blue);
  margin-bottom: 4px;
  font-family: var(--font-mono);
  opacity: 0.7;
}

.menu-section {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.menu-group-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin: 16px 0 8px 12px;
  font-weight: 600;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  margin-bottom: 4px;
  transition: all var(--transition-speed) ease;
  font-size: 0.95rem;
  border: 1px solid transparent;
}

.menu-item:hover {
  background-color: var(--glass-hover);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.03);
}

.menu-item.active {
  background-color: rgba(0, 229, 255, 0.1);
  color: var(--electric-blue);
  border-left: 4px solid var(--electric-blue);
  font-weight: 500;
}

/* Main Content Area */
.main-content {
  margin-left: 280px;
  flex: 1;
  padding: 32px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Section Header */
.section-header {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 16px;
}

.section-header h2 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn var(--transition-speed) ease;
}

.tab-panel.active {
  display: block;
}

/* Layout Grid System */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.grid-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
}

/* Dashboard Cards (Glassmorphism) */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: transform 0.2s ease, border-color var(--transition-speed);
}

.glass-card:hover {
  border-color: rgba(0, 229, 255, 0.2);
}

.glass-card h3 {
  font-size: 1.25rem;
  margin-bottom: 16px;
  font-weight: 500;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 8px;
  color: var(--text-primary);
}

/* Interactive Controls and Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
}

.input-unit {
  position: absolute;
  right: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
}

input[type="number"], input[type="text"] {
  width: 100%;
  padding: 12px 44px 12px 44px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1rem;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
  appearance: none;
}

select {
  width: 100%;
  padding: 12px 16px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-family: var(--font-thai);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' 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 12px center;
  background-size: 16px;
  padding-right: 36px;
}

input[type="number"]:focus, select:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--electric-blue);
  box-shadow: 0 0 0 3px var(--electric-blue-glow);
}

/* Remove spin arrows on number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Custom inputs without unit or icon padding adjust */
input.no-icon {
  padding-left: 16px;
}
input.no-unit {
  padding-right: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed);
  border: none;
  font-family: var(--font-thai);
  font-size: 0.95rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--electric-blue), var(--neon-purple));
  color: #000;
  color: var(--bg-primary);
  font-weight: 700;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 229, 255, 0.4);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background-color: var(--glass-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background-color: rgba(255, 51, 102, 0.15);
  color: var(--danger-red);
  border: 1px solid rgba(255, 51, 102, 0.3);
}

.btn-danger:hover {
  background-color: var(--danger-red);
  color: white;
  box-shadow: 0 0 10px var(--danger-glow);
}

/* Specific component widgets styling */

/* Ohm's Law Calculator */
.ohms-wheel-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.ohms-circle {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 6px solid var(--glass-border);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--bg-secondary);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.ohms-half {
  width: 100%;
  height: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.ohms-top {
  border-bottom: 4px solid var(--electric-blue);
  color: var(--electric-blue);
  text-shadow: 0 0 10px var(--electric-blue-glow);
}

.ohms-bottom {
  display: flex;
  width: 100%;
}

.ohms-bottom-left, .ohms-bottom-right {
  width: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
}

.ohms-bottom-left {
  border-right: 4px solid var(--electric-blue);
  color: var(--neon-green);
  text-shadow: 0 0 10px var(--neon-green-glow);
}

.ohms-bottom-right {
  color: var(--electric-amber);
  text-shadow: 0 0 10px var(--electric-amber-glow);
}

/* Resistor dynamic network list */
.resistor-item {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  animation: slideIn 0.2s ease;
}

.resistor-index {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-muted);
  min-width: 30px;
}

/* Resistor Visual Colors */
.resistor-visual {
  width: 100%;
  height: 130px;
  background: linear-gradient(135deg, #0d121f, #131a26);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.resistor-lead {
  position: absolute;
  width: 84%;
  height: 5px;
  background: linear-gradient(to right, #4a5568, #718096, #4a5568);
  border-radius: 3px;
  z-index: 1;
}

.resistor-body {
  position: relative;
  width: 190px;
  height: 54px;
  background: linear-gradient(180deg, #e8c89a 0%, #d4a874 40%, #c49060 60%, #d4a874 100%);
  border-radius: 14px;
  z-index: 2;
  box-shadow:
    inset 0 3px 8px rgba(255,255,255,0.3),
    inset 0 -4px 8px rgba(0,0,0,0.25),
    0 4px 20px rgba(0,0,0,0.4),
    0 0 0 1px rgba(0,0,0,0.2);
  display: flex;
  justify-content: space-evenly;
  padding: 0 24px;
  align-items: stretch;
}

.color-band {
  width: 10px;
  height: 100%;
  background: transparent;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
  opacity: 0.2;
}

.color-band.band-first { border-radius: 4px 0 0 4px; }
.color-band.band-last { border-radius: 0 4px 4px 0; }

/* Color picker grids */
.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.color-button {
  height: 36px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  transition: transform 0.1s ease;
}

.color-button:hover {
  transform: scale(1.05);
}

/* Colors standard mapping */
.color-black { background-color: #000000; color: #ffffff; }
.color-brown { background-color: #8b4513; color: #ffffff; }
.color-red { background-color: #ff0000; color: #ffffff; }
.color-orange { background-color: #ffa500; color: #000000; }
.color-yellow { background-color: #ffff00; color: #000000; }
.color-green { background-color: #008000; color: #ffffff; }
.color-blue { background-color: #0000ff; color: #ffffff; }
.color-violet { background-color: #ee82ee; color: #000000; }
.color-gray { background-color: #808080; color: #ffffff; }
.color-white { background-color: #ffffff; color: #000000; }
.color-gold { background-color: #ffd700; color: #000000; }
.color-silver { background-color: #c0c0c0; color: #000000; }

/* Canvas/SVG display areas for AC diagram */
.diagram-container {
  width: 100%;
  height: 250px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.diagram-svg {
  width: 100%;
  height: 100%;
}

/* Interactive Water pipe Flow Simulation */
.flow-simulation-box {
  width: 100%;
  height: 220px;
  background: #0d121f;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--glass-border);
  position: relative;
  overflow: hidden;
}

.water-pipe {
  position: absolute;
  top: 50%;
  left: 10%;
  width: 80%;
  height: 60px;
  transform: translateY(-50%);
  background: #1e293b;
  border: 3px solid #475569;
  border-radius: 12px;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.water-constriction {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 20px;
  transform: translate(-50%, -50%);
  background: #475569;
  z-index: 10;
  border-radius: 4px;
}

.water-flow-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  background-color: var(--electric-blue);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--electric-blue);
}

/* Electricity Bill item list */
.bill-items-list {
  max-height: 250px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.bill-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--border-radius-sm);
  margin-bottom: 8px;
  border: 1px solid var(--glass-border);
}

.bill-item-info h4 {
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.bill-item-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Electrical Symbol Library */
.symbols-filter-container {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.symbols-filter-container button.active-filter {
  background: linear-gradient(135deg, var(--electric-blue), var(--neon-purple));
  color: var(--bg-primary);
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 0 10px var(--electric-blue-glow);
}

.symbols-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

.symbol-card {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.symbol-card:hover {
  transform: translateY(-4px);
  border-color: var(--electric-blue);
  box-shadow: 0 5px 15px rgba(0, 229, 255, 0.15);
}

.symbol-graphic {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.symbol-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.symbol-detail-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 32px;
  max-width: 500px;
  width: 90%;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Outputs & Results UI Elements */
.results-box {
  background-color: rgba(0, 229, 255, 0.04);
  border: 1px solid rgba(0, 229, 255, 0.15);
  border-radius: var(--border-radius-sm);
  padding: 16px;
  margin-top: 16px;
}

.results-title {
  font-size: 0.85rem;
  color: var(--electric-blue);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 8px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.result-row:last-child {
  margin-bottom: 0;
}

.result-value {
  font-family: var(--font-mono);
  font-weight: 700;
}

/* Standard values helper text */
.helper-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Safe alert banner */
.safety-banner {
  background-color: rgba(255, 159, 0, 0.08);
  border-left: 4px solid var(--electric-amber);
  padding: 12px 16px;
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  margin-bottom: 16px;
}

.safety-banner-title {
  color: var(--electric-amber);
  font-weight: 600;
  margin-bottom: 4px;
}

/* Mobile Menu Toggle */
.mobile-header {
  display: none;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--glass-border);
  padding: 16px;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 200;
}

.menu-toggle-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes slideIn {
  from { transform: translateX(-15px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse-glow {
  0%, 100% {
    filter: drop-shadow(0 0 2px var(--electric-blue));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 10px var(--electric-blue));
    transform: scale(1.1);
  }
}

@keyframes flowWater {
  0% { left: -5%; }
  100% { left: 105%; }
}

/* Responsive adjustments */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  
  .mobile-header {
    display: flex;
  }
  
  .grid-2col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .grid-3col {
    grid-template-columns: 1fr;
  }
  
  .symbols-filter-container {
    flex-wrap: wrap;
  }
  
  .symbols-filter-container button {
    flex: 1 1 calc(50% - 6px);
  }
}
