/* ==========================================================================
   dBtoW Converter - Modern RF & Wireless Signal Engineering Stylesheet
   Refined aesthetic with vibrant indigo-cyan tech palette, glassmorphism & cards
   ========================================================================== */

:root {
  --rf-primary: #0284c7;
  --rf-primary-hover: #0369a1;
  --rf-primary-light: #e0f2fe;
  --rf-indigo: #4f46e5;
  --rf-indigo-light: #e0e7ff;
  --rf-purple: #7c3aed;
  --rf-purple-light: #ede9fe;
  --rf-amber: #d97706;
  --rf-emerald: #059669;
  --rf-rose: #e11d48;
  
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --card-border-hover: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 30px rgba(15, 23, 42, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

/* Base Container & Scope */
.dbw-scope {
  width: 100%;
  box-sizing: border-box;
}

/* Breadcrumb Navigation */
.dbw-breadcrumb {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.dbw-breadcrumb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #475569;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 14px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 9999px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.dbw-breadcrumb-btn:hover {
  color: var(--rf-primary);
  border-color: var(--rf-primary);
  transform: translateY(-1px);
}
.dbw-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--rf-primary);
  background: var(--rf-primary-light);
  border: 1px solid #bae6fd;
  padding: 6px 14px;
  border-radius: 9999px;
}

/* Hero Header */
.dbw-hero {
  max-width: 1200px;
  margin: 20px auto 30px;
  padding: 32px 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 60%, #0369a1 100%);
  border-radius: var(--radius-xl);
  color: #ffffff;
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.25);
  position: relative;
  overflow: hidden;
}
.dbw-hero::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.25) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.dbw-hero-title {
  font-size: 2.1rem;
  font-weight: 800;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.dbw-hero-title i {
  color: #38bdf8;
}
.dbw-hero-sub {
  font-size: 1.05rem;
  color: #94a3b8;
  max-width: 820px;
  line-height: 1.6;
  margin: 0;
}

/* Main Layout */
.dbw-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* Card Common */
.dbw-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: 26px 28px;
  box-shadow: var(--shadow-md);
  margin-bottom: 28px;
  transition: all 0.2s ease;
}
.dbw-card:hover {
  border-color: var(--card-border-hover);
  box-shadow: var(--shadow-lg);
}

.dbw-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 2px solid #f1f5f9;
  flex-wrap: wrap;
  gap: 10px;
}
.dbw-card-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Presets Bar */
.presets-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 14px 18px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
}
.preset-strip-lbl {
  font-size: 0.85rem;
  font-weight: 700;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-right: 4px;
}
.btn-preset-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 9999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-preset-chip:hover {
  background: var(--rf-primary-light);
  border-color: var(--rf-primary);
  color: var(--rf-primary);
  transform: translateY(-1px);
}
.btn-preset-chip.active {
  background: var(--rf-primary);
  border-color: var(--rf-primary);
  color: #ffffff;
}

/* Conversion Dual Box */
.converter-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
}

.converter-panel {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: all 0.2s ease;
  position: relative;
}
.converter-panel:focus-within {
  border-color: var(--rf-primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12);
}
.converter-panel.panel-power:focus-within {
  border-color: var(--rf-indigo);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.converter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.converter-panel-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}
.converter-panel-unit {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #475569;
}

.input-group-custom {
  display: flex;
  align-items: center;
  gap: 10px;
}
.input-main-calc {
  flex: 1;
  font-size: 1.85rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace, sans-serif;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: #0f172a;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.input-main-calc:focus {
  border-color: var(--rf-primary);
}

.unit-select-custom {
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: #1e293b;
  cursor: pointer;
  outline: none;
  min-width: 90px;
}
.unit-select-custom:focus {
  border-color: var(--rf-primary);
}

.converter-exchange-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-swap-mode {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  color: var(--rf-primary);
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.btn-swap-mode:hover {
  background: var(--rf-primary);
  color: #ffffff;
  border-color: var(--rf-primary);
  transform: rotate(180deg) scale(1.08);
}

/* Control Options Toolbar (Impedance, Precision) */
.options-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 18px;
  background: #f1f5f9;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 0.9rem;
}
.option-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.option-item label {
  font-weight: 700;
  color: #334155;
  margin: 0;
}
.option-item select {
  font-size: 0.88rem;
  font-weight: 600;
  padding: 5px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #1e293b;
}

/* Results Multi-Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}
.res-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}
.res-card:hover {
  border-color: var(--rf-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.res-card.highlight {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-color: #38bdf8;
}
.res-card.highlight-purple {
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border-color: #c084fc;
}

.res-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.res-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
}
.btn-copy-val {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
}
.btn-copy-val:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--rf-primary);
}

.res-value-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: auto;
}
.res-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.45rem;
  font-weight: 800;
  color: #0f172a;
  word-break: break-all;
}
.res-unit {
  font-size: 0.95rem;
  font-weight: 700;
  color: #475569;
}
.res-desc {
  font-size: 0.76rem;
  color: #64748b;
  margin-top: 4px;
}

/* Formula Breakdown Box */
.formula-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-top: 10px;
}
.formula-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.formula-math {
  font-family: 'JetBrains Mono', monospace;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.92rem;
  color: #0284c7;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

/* Reference Comparison Table */
.dbw-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid #e2e8f0;
  background: #ffffff;
}
.dbw-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 0.88rem;
}
.dbw-table th {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 10px;
  font-weight: 700;
  border: 1px solid #1e293b;
}
.dbw-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: #334155;
}
.dbw-table tr:hover td {
  background: #f8fafc;
}
.dbw-table tr.active-target td {
  background: #e0f2fe;
  color: #0284c7;
  font-weight: 800;
}
.dbw-table .app-example {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 500;
  color: #64748b;
  text-align: left;
  padding-left: 14px;
}

/* dBx Knowledge Guide Cards */
.dbx-guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 16px;
}
.dbx-card {
  border-radius: var(--radius-lg);
  border: 1px solid #e2e8f0;
  background: #ffffff;
  padding: 20px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.dbx-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}
.dbx-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
}
.dbx-card.border-power::before { background: #0284c7; }
.dbx-card.border-voltage::before { background: #f59e0b; }
.dbx-card.border-antenna::before { background: #10b981; }
.dbx-card.border-acoustic::before { background: #8b5cf6; }

.dbx-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.dbx-symbol {
  font-size: 1.25rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: #0f172a;
}
.dbx-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #475569;
}
.dbx-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}
.dbx-desc {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.55;
  margin-bottom: 8px;
}
.dbx-ref {
  font-size: 0.8rem;
  background: #f8fafc;
  border-radius: 6px;
  padding: 6px 10px;
  color: #0369a1;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

/* 3dB / 10dB Rule Quick Card */
.rule-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-radius: var(--radius-lg);
  padding: 22px;
  color: #ffffff;
  margin-top: 24px;
}
.rule-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #38bdf8;
}
.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.rule-item {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 14px;
}
.rule-item-key {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  font-weight: 800;
  color: #facc15;
  margin-bottom: 4px;
}
.rule-item-val {
  font-size: 0.86rem;
  color: #e2e8f0;
  line-height: 1.45;
}

/* Toast Message */
.dbw-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  color: #ffffff;
  padding: 10px 22px;
  border-radius: 9999px;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100000;
}
.dbw-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 860px) {
  .converter-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .converter-exchange-icon {
    transform: rotate(90deg);
  }
  .btn-swap-mode:hover {
    transform: rotate(270deg) scale(1.08);
  }
  .dbw-hero {
    padding: 24px 18px;
  }
  .dbw-hero-title {
    font-size: 1.6rem;
  }
  .input-main-calc {
    font-size: 1.45rem;
  }
}
