/* ============================================
   EECalc - Electronics Engineering Calculators
   Shared Stylesheet
   ============================================ */

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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #0891b2;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #059669;
  --success-light: #d1fae5;
  --warning: #d97706;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --max-width: 960px;
  --transition: 0.2s ease;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-dark);
}

img {
  max-width: 100%;
  height: auto;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.logo svg {
  width: 28px;
  height: 28px;
}

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

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 0;
  transition: color var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
}

/* ---------- Layout ---------- */
.main-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px;
  min-height: calc(100vh - 60px - 160px);
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--text-secondary);
}

.breadcrumb a:hover {
  color: var(--primary);
}

.breadcrumb span {
  margin: 0 6px;
}

/* ---------- Homepage Hero ---------- */
.hero {
  text-align: center;
  padding: 48px 20px 32px;
}

.hero h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.hero p {
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Tool Grid ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 32px;
}

.tool-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform var(--transition), box-shadow var(--transition),
    border-color var(--transition);
  cursor: pointer;
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.tool-card:hover .tool-card-icon {
  background: var(--primary);
  color: #fff;
}

.tool-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.tool-card-icon svg {
  width: 24px;
  height: 24px;
}

.tool-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.tool-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tool-card .tool-link {
  margin-top: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

/* ---------- Calculator Page ---------- */
.calc-page {
  max-width: 720px;
  margin: 0 auto;
}

.calc-page h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.calc-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

/* ---------- Calculator Card ---------- */
.calc-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.calc-card h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ---------- Form Elements ---------- */
.form-group {
  margin-bottom: 18px;
}

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

.form-group .hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.input-row {
  display: flex;
  gap: 0;
  align-items: stretch;
}

.input-row input,
.input-row select {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--card-bg);
  outline: none;
  transition: border-color var(--transition);
  font-family: inherit;
}

.input-row input:focus,
.input-row select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  position: relative;
  z-index: 1;
}

.input-row .unit {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

/* Standalone input (no unit) */
.input-full {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--card-bg);
  outline: none;
  transition: border-color var(--transition);
  font-family: inherit;
}

.input-full:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

select.input-full {
  cursor: pointer;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:active {
  transform: scale(0.98);
}

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

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

.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* ---------- Results ---------- */
.result-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.result-section h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  border: none;
  padding: 0;
}

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

.result-item {
  background: var(--success-light);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.result-item .label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.result-item .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--success);
}

.result-item .unit-small {
  font-size: 14px;
  font-weight: 500;
  color: var(--success);
}

.result-note {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fef9c3;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #92400e;
  line-height: 1.5;
}

.result-error {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fef2f2;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #991b1b;
  display: none;
}

.result-error.show {
  display: block;
}

/* ---------- Formula Section (SEO Content) ---------- */
.info-section {
  margin-top: 40px;
  padding: 28px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.info-section h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

.info-section h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-top: 18px;
  margin-bottom: 8px;
}

.info-section p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 10px;
}

.info-section ul {
  padding-left: 20px;
  margin-bottom: 10px;
}

.info-section li {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.formula {
  background: #f1f5f9;
  border-left: 3px solid var(--primary);
  padding: 12px 18px;
  margin: 12px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: "Courier New", monospace;
  font-size: 15px;
  color: var(--text);
  overflow-x: auto;
}

/* ---------- Related Tools ---------- */
.related-tools {
  margin-top: 32px;
}

.related-tools h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.related-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.related-links a:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ---------- Ad Placeholder ---------- */
.ad-slot {
  margin: 24px 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 32px 20px;
  margin-top: 48px;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.footer-inner p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 12px;
}

.footer-links a {
  font-size: 13px;
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--primary);
}

/* ---------- Circuit Diagram ---------- */
.circuit-diagram {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 24px;
  text-align: center;
}

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

.circuit-diagram .diagram-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* SVG circuit styles */
.circuit-diagram .wire {
  stroke: #475569;
  stroke-width: 2;
  fill: none;
}

.circuit-diagram .component {
  stroke: #1e293b;
  stroke-width: 2;
  fill: #fff;
}

.circuit-diagram .component-fill {
  stroke: #1e293b;
  stroke-width: 2;
  fill: #f1f5f9;
}

.circuit-diagram .label-text {
  font-size: 13px;
  fill: var(--text-secondary);
  font-family: inherit;
}

.circuit-diagram .value-text {
  font-size: 13px;
  fill: var(--primary);
  font-weight: 600;
  font-family: inherit;
}

.circuit-diagram .current-arrow {
  stroke: var(--primary);
  stroke-width: 1.5;
  fill: var(--primary);
}

.circuit-diagram .led-light {
  stroke: #f59e0b;
  stroke-width: 1.5;
  fill: none;
}

/* ---------- Real-time indicator ---------- */
.calc-hint-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.calc-hint-bar .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 24px;
  }

  .hero p {
    font-size: 15px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

  .calc-page h1 {
    font-size: 22px;
  }

  .calc-card {
    padding: 20px;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .nav-links {
    gap: 16px;
  }

  .nav-links a {
    font-size: 13px;
  }

  .btn-row {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .header-inner {
    padding: 0 14px;
  }

  .main-container {
    padding: 20px 14px;
  }

  .logo {
    font-size: 17px;
  }
}
