/* Mortgage Calculator Styles */

:root {
  /* Dark theme (default) */
  --bg-body: #0b1220;
  --bg-card: #0f1a33;
  --bg-input: #0b1220;
  --bg-canvas: rgba(255,255,255,.02);
  --bg-callout: rgba(255,255,255,.04);
  --bg-field-explain: rgba(255,255,255,.03);
  --bg-badge: rgba(255,255,255,.08);
  --bg-toggle: rgba(255,255,255,.15);
  --text-primary: #e6edf7;
  --text-heading: #f0f4fa;
  --text-muted: rgba(230,237,247,.72);
  --text-label: rgba(230,237,247,.85);
  --text-explain: rgba(230,237,247,.55);
  --border-card: rgba(255,255,255,.08);
  --border-input: rgba(255,255,255,.18);
  --border-input-focus: rgba(255,255,255,.35);
  --border-callout: rgba(255,255,255,.10);
  --border-badge: rgba(255,255,255,.12);
  --border-explain: rgba(99,179,237,.4);
  --accent: rgba(99,179,237,.9);
  --accent-bg: rgba(99,179,237,.15);
  --accent-border: rgba(99,179,237,.3);
  --accent-hover-bg: rgba(99,179,237,.25);
  --accent-hover-border: rgba(99,179,237,.5);
  --accent-active: rgba(99,179,237,.8);
  --toggle-knob: #fff;
  --hr-color: rgba(255,255,255,.12);
  --chart-text: rgba(230,237,247,.8);
  --chart-text-secondary: rgba(230,237,247,.6);
  --chart-grid: rgba(255,255,255,.08);
}

body.light-theme {
  /* Light theme */
  --bg-body: #f5f7fa;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-canvas: rgba(0,0,0,.02);
  --bg-callout: rgba(0,0,0,.03);
  --bg-field-explain: rgba(0,0,0,.03);
  --bg-badge: rgba(0,0,0,.06);
  --bg-toggle: rgba(0,0,0,.12);
  --text-primary: #1a2332;
  --text-heading: #0f172a;
  --text-muted: rgba(26,35,50,.65);
  --text-label: rgba(26,35,50,.8);
  --text-explain: rgba(26,35,50,.6);
  --border-card: rgba(0,0,0,.08);
  --border-input: rgba(0,0,0,.15);
  --border-input-focus: rgba(0,0,0,.3);
  --border-callout: rgba(0,0,0,.08);
  --border-badge: rgba(0,0,0,.1);
  --border-explain: rgba(37,99,235,.5);
  --accent: rgba(37,99,235,.9);
  --accent-bg: rgba(37,99,235,.1);
  --accent-border: rgba(37,99,235,.25);
  --accent-hover-bg: rgba(37,99,235,.15);
  --accent-hover-border: rgba(37,99,235,.4);
  --accent-active: rgba(37,99,235,.7);
  --toggle-knob: #fff;
  --hr-color: rgba(0,0,0,.1);
  --chart-text: rgba(26,35,50,.8);
  --chart-text-secondary: rgba(26,35,50,.5);
  --chart-grid: rgba(0,0,0,.08);
}

/* Base styles */
body {
  background: var(--bg-body);
  color: var(--text-primary);
  transition: background 0.3s, color 0.3s;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  transition: background 0.3s, border-color 0.3s;
}

.card .h5,
.card h2 {
  color: var(--text-heading);
}

/* Form controls */
.form-control,
.form-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-input);
  transition: background 0.3s, color 0.3s, border-color 0.3s;
  color-scheme: dark;
}

body.light-theme .form-control,
body.light-theme .form-select {
  color-scheme: light;
}

.form-control:focus,
.form-select:focus {
  box-shadow: none;
  border-color: var(--border-input-focus);
}

.form-label {
  margin-bottom: 0.15rem;
  color: var(--text-label);
}

/* Utility classes */
.muted {
  color: var(--text-muted);
}

canvas {
  background: var(--bg-canvas);
  border-radius: 12px;
}

.badge-soft {
  background: var(--bg-badge);
  border: 1px solid var(--border-badge);
  color: var(--text-label);
}

hr {
  border-color: var(--hr-color) !important;
}

/* Best plan styling */
.best-plan-hero {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.best-plan-stat {
  text-align: center;
  padding: 12px 20px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  min-width: 100px;
}

.best-plan-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}

.best-plan-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.best-plan-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.best-plan-detail {
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 8px;
}

.best-plan-detail-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.best-plan-detail-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.best-plan-objective {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-callout);
  border: 1px solid var(--border-callout);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.best-plan-objective-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.best-plan-objective-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

/* Field explanations */
.field-explain {
  font-size: 0.75rem;
  color: var(--text-explain);
  line-height: 1.4;
  padding: 0;
  background: transparent;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  margin: 0;
  transition: max-height 0.3s ease-out, opacity 0.25s ease-out, margin 0.3s ease-out;
}

.show-explanations .field-explain {
  max-height: 200px;
  opacity: 1;
  margin-top: 6px;
  margin-bottom: 8px;
}

/* Field pair alignment */
.field-group {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.field-group .form-control,
.field-group .form-select {
  margin-top: auto;
}

/* Toggle button */
.toggle-btn {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 20px;
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-btn:hover {
  background: var(--accent-bg);
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg-toggle);
  border-radius: 10px;
  transition: all 0.2s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--toggle-knob);
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle-btn.active .toggle-switch {
  background: var(--accent-active);
}

.toggle-btn.active .toggle-switch::after {
  left: 18px;
}

/* Objective cards */
.objective-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 768px) {
  .objective-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

.objective-card {
  background: var(--bg-input);
  border: 2px solid var(--border-input);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.objective-card:hover {
  border-color: var(--accent-border);
  background: var(--accent-bg);
}

.objective-card.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.objective-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.objective-radio {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--border-input);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  transition: all 0.2s;
}

.objective-card.selected .objective-radio {
  border-color: var(--accent);
}

.objective-radio::after {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s;
}

.objective-card.selected .objective-radio::after {
  opacity: 1;
  transform: scale(1);
}

.objective-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-heading);
  line-height: 1.3;
}

.objective-card-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.objective-card-explain {
  font-size: 0.72rem;
  color: var(--text-explain);
  line-height: 1.4;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  transition: max-height 0.3s ease-out, opacity 0.25s ease-out, margin 0.3s ease-out, padding 0.3s ease-out;
}

.show-explanations .objective-card-explain {
  max-height: 300px;
  opacity: 1;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-input);
}

.objective-card-explain strong {
  color: var(--text-label);
}

/* Theme toggle specific */
.theme-icon {
  font-size: 14px;
  opacity: 0.4;
  transition: opacity 0.2s;
}

.theme-icon-dark {
  opacity: 1;
}

.theme-icon-light {
  opacity: 0.4;
}

.theme-toggle.active .theme-icon-dark {
  opacity: 0.4;
}

.theme-toggle.active .theme-icon-light {
  opacity: 1;
}

/* Better icon visibility in light theme */
body.light-theme .theme-icon {
  filter: saturate(1.3) contrast(1.1);
}

body.light-theme .theme-icon-dark {
  filter: brightness(0.6) saturate(1.5);
}

/* Language selector */
.lang-dropdown {
  position: relative;
}

.lang-dropdown-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lang-dropdown-btn:hover {
  border-color: var(--border-input-focus);
}

.lang-dropdown-btn::after {
  content: '▾';
  font-size: 0.7rem;
  opacity: 0.6;
}

.lang-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  padding: 4px;
  min-width: 80px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s;
  z-index: 100;
}

.lang-dropdown.open .lang-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.lang-dropdown-item:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.lang-dropdown-item.active {
  color: var(--text-primary);
  background: var(--accent-bg);
}

/* Button overrides for light theme */
body.light-theme .btn-outline-light {
  color: var(--text-primary);
  border-color: var(--border-input);
}

body.light-theme .btn-outline-light:hover {
  background: rgba(0,0,0,.05);
  color: var(--text-primary);
  border-color: var(--border-input-focus);
}

body.light-theme .btn-light {
  background: var(--text-primary);
  color: var(--bg-body);
  border-color: var(--text-primary);
}

body.light-theme .btn-light:hover {
  background: #0f172a;
  color: #fff;
}

/* Mobile responsive fixes */

/* Desktop controls - hidden on mobile */
.controls-desktop {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.settings-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Mobile controls - hidden on desktop */
.controls-mobile {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  position: relative;
}

.mobile-menu-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text);
  margin-left: auto;
}

.mobile-menu-btn:hover {
  background: var(--hover-bg);
}

.mobile-menu-panel {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  z-index: 1000;
  min-width: 220px;
  flex-direction: column;
  gap: 12px;
}

/* Ensure solid background in both themes */
:root .mobile-menu-panel {
  background: #1e1e1e;
}

.light-theme .mobile-menu-panel {
  background: #ffffff;
}

.mobile-menu-panel.open {
  display: flex;
}

.mobile-menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-menu-label {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 767px) {
  .controls-desktop {
    display: none;
  }
  
  .controls-mobile {
    display: flex;
  }
  
  /* Objective header - stack on mobile */
  .objective-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
  }
  
  .objective-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .objective-badges .badge {
    font-size: 0.7rem;
  }
}
