/* ============================================
   FOME WDVS Kalkulation — Style
   Light design, country-specific accents
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- CSS Variables --- */
:root {
  --accent: #e87a1e;
  --accent-light: #fdebd0;
  --accent-hover: #cf6a14;
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 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);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Germany theme */
[data-country="de"] {
  --accent: #5ba4d9;
  --accent-light: #dbeafe;
  --accent-hover: #4a8fc4;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- Country Selection Screen --- */
.country-select-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f9fb 0%, #e8ecf1 100%);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.country-select-screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.05);
}

.country-select-container {
  text-align: center;
  animation: fadeInUp 0.6s ease-out;
}

.country-select-container h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
}

.country-select-container p {
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  font-size: 1.05rem;
}

.country-buttons {
  display: flex;
  gap: 2rem;
  justify-content: center;
}

.country-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 3rem;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
  min-width: 200px;
}

.country-btn:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.country-btn.ch:hover {
  border-color: #e87a1e;
  background: #fef7f0;
}

.country-btn.de:hover {
  border-color: #5ba4d9;
  background: #f0f7fe;
}

.country-btn .flag {
  font-size: 3.5rem;
  line-height: 1;
}

.country-btn .country-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

/* --- Header / Banner --- */
.site-header {
  position: relative;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.banner-wrapper {
  width: 100%;
  height: 100px;
  overflow: hidden;
  position: relative;
}

.banner-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0) 60%, rgba(255, 255, 255, 0.8) 100%);
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  background: var(--bg-card);
}

.header-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.header-title span {
  color: var(--accent);
}

.header-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.country-switch-btn {
  padding: 0.4rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: var(--transition);
  font-family: inherit;
}

.country-switch-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

/* --- Main Container --- */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* --- Section Cards --- */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.section-card:hover {
  box-shadow: var(--shadow-lg);
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--accent-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title .icon {
  font-size: 1.3rem;
}

/* --- Input Grid --- */
.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.input-group input[type="number"],
.input-group select {
  padding: 0.6rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: var(--transition);
  -moz-appearance: textfield;
  appearance: textfield;
  max-width: 200px;
}

/* Narrow inputs for main calculator */
.input-narrow {
  max-width: 160px !important;
}

/* Compact input grid */
.input-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Inline discount input in results tables */
.results-table .discount-input {
  width: 60px;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: inherit;
  text-align: right;
  background: var(--bg);
  transition: var(--transition);
  -moz-appearance: textfield;
  appearance: textfield;
}

.results-table .discount-input::-webkit-outer-spin-button,
.results-table .discount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.results-table .discount-input:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
}

.input-group input[type="number"]::-webkit-outer-spin-button,
.input-group input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Slider */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.slider-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.slider-wrapper input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: var(--transition);
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.slider-value {
  min-width: 50px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  background: var(--accent-light);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
}

/* Toggle row above inputs */
.toggle-row {
  margin-bottom: 1rem;
}

.toggle-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toggle-switch {
  position: relative;
  width: 52px;
  height: 28px;
  background: var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: var(--transition);
}

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

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

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

.toggle-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

/* --- Results Tables --- */
.results-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.results-table thead {
  background: var(--bg);
}

.results-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.results-table td {
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--border-light);
  white-space: nowrap;
}

.results-table tbody tr:hover {
  background: var(--accent-light);
}

.results-table tbody tr:last-child {
  border-bottom: none;
}

.results-table .total-row {
  background: var(--bg);
  font-weight: 700;
}

.results-table .total-row td {
  border-top: 2px solid var(--accent);
  color: var(--text);
}

.results-table .number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --- Summary Cards --- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.summary-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  text-align: center;
  transition: var(--transition);
}

.summary-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.summary-card .summary-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.summary-card .summary-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.summary-card .summary-unit {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* --- Comparison Section --- */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.comparison-col {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.comparison-header {
  padding: 0.75rem 1rem;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
}

.comparison-col.fome .comparison-header {
  background: var(--accent);
  color: white;
}

.comparison-col.mineral .comparison-header {
  background: var(--text);
  color: white;
}

.comparison-body {
  padding: 0;
}

.comparison-body .results-table {
  border: none;
}

/* --- Admin Section --- */
.admin-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 2rem auto;
  padding: 0.6rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-family: inherit;
  transition: var(--transition);
}

.admin-trigger:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-secondary);
  transition: var(--transition);
}

.modal-close:hover {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
}

.modal-body {
  padding: 1.5rem;
}

/* Login form */
.login-form {
  max-width: 360px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form input {
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.btn-primary {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-secondary {
  padding: 0.6rem 1.2rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

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

.btn-danger {
  padding: 0.6rem 1.2rem;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.btn-danger:hover {
  background: #dc2626;
}

/* Admin Tables */
.admin-section {
  margin-bottom: 2rem;
}

.admin-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th {
  padding: 0.6rem 0.8rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--border-light);
}

.admin-table input {
  width: auto;
  max-width: 120px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: inherit;
  background: var(--bg);
  transition: var(--transition);
  -moz-appearance: textfield;
  appearance: textfield;
}

.admin-table input::-webkit-outer-spin-button,
.admin-table input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.admin-table input:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
}

/* Admin tabs */
.admin-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.admin-tab {
  padding: 0.6rem 1.2rem;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}

.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.admin-tab:hover:not(.active) {
  color: var(--text);
}

.admin-tab-content {
  display: none;
}

.admin-tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* Status messages */
.status-msg {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 0.75rem;
  display: none;
}

.status-msg.success {
  display: block;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.status-msg.error {
  display: block;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* --- Animations --- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .main-container {
    padding: 1rem;
  }

  .section-card {
    padding: 1.25rem;
  }

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

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


  .country-buttons {
    flex-direction: column;
    align-items: center;
  }

  .header-bar {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .header-title {
    font-size: 1rem;
  }

  .banner-wrapper {
    height: 70px;
  }
}

@media (max-width: 480px) {

  .results-table {
    font-size: 0.8rem;
  }

  .results-table th,
  .results-table td {
    padding: 0.5rem 0.6rem;
  }
}

/* --- Utility --- */
.hidden {
  display: none !important;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.currency::before {
  content: attr(data-currency);
}