/* ========================================
   CAMPINGPLATZ PREISRECHNER — STYLES
   ======================================== */

/* ========================================
   DESIGN TOKENS (CSS Custom Properties)
   ======================================== */
:root {
  /* Primary palette */
  --color-primary: #0E1F53;
  --color-primary-light: #1a3478;
  --color-primary-muted: #6b8fc0;
  --color-primary-bg: #e0e6f5;
  --color-primary-bg-hover: #c8d6ed;
  --color-primary-bg-focus: #e6edf7;
  --color-shadow-primary: rgba(14,31,83,0.12);
  --color-shadow-primary-light: rgba(26,52,120,0.12);

  /* Backgrounds */
  --color-bg-page: #f4f1ea;
  --color-bg-white: #ffffff;
  --color-bg-section: #faf8f5;
  --color-bg-item-hover: #f5f2ec;
  --color-bg-disabled: #f0eee8;
  --color-bg-result-start: #f4f1ea;
  --color-bg-result-end: #edeadf;

  /* Text */
  --color-text: #2d2a24;
  --color-text-secondary: #5a5448;
  --color-text-muted: #6a6458;
  --color-text-dim: #8a8478;
  --color-text-faint: #a09888;
  --color-text-white: #ffffff;
  --color-text-error: #c0392b;

  /* Borders */
  --color-border: #d4cfc6;
  --color-border-light: #e5e0d7;

  /* Shadows */
  --color-shadow: rgba(0,0,0,0.08);
}

/* ========================================
   RESET & BASE
   ======================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--color-bg-page);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 1rem;
}

/* ========================================
   CONTAINER
   ======================================== */
.calculator {
  max-width: 780px;
  width: 100%;
  background: var(--color-bg-white);
  border-radius: 20px;
  box-shadow: 0 8px 40px var(--color-shadow);
  overflow: hidden;
  align-self: flex-start;
}

/* ========================================
   HEADER
   ======================================== */
.calculator-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: var(--color-text-white);
  padding: 1.75rem 2rem 1.5rem;
  text-align: center;
}
.calculator-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 0.2rem;
}
.calculator-header p {
  font-size: 0.85rem;
  opacity: 0.85;
}

/* ========================================
   BODY / PADDING
   ======================================== */
.calculator-body { padding: 1.5rem 2rem 2rem; }

/* ========================================
   TABS
   ======================================== */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.tab-btn {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.75rem;
  border: 2px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg-section);
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}
.tab-btn:hover { border-color: var(--color-primary-muted); color: var(--color-primary); }
.tab-btn.active {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
  color: var(--color-primary);
  box-shadow: 0 2px 8px var(--color-shadow-primary);
}
.tab-btn:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 2px; }

/* ========================================
   DATUM / ZEITRAUM
   ======================================== */
.date-section {
  background: var(--color-bg-section);
  border: 1px solid var(--color-border-light);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.date-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary-light);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.date-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.date-field {
  flex: 1;
  min-width: 140px;
}
.date-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 0.25rem;
}
.date-field input[type="date"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-bg-white);
  transition: border-color 0.2s;
}
.date-field input[type="date"]:focus {
  outline: none;
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px var(--color-shadow-primary-light);
}
.date-divider {
  display: flex;
  align-items: center;
  padding-bottom: 0.15rem;
  font-size: 0.85rem;
  color: var(--color-text-dim);
  font-weight: 600;
}
.nights-field {
  flex: 1;
  min-width: 120px;
}
.nights-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 0.25rem;
}
.nights-field input[type="number"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-bg-white);
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}
.nights-field input[type="number"]::-webkit-inner-spin-button,
.nights-field input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.nights-field input[type="number"]:focus {
  outline: none;
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px var(--color-shadow-primary-light);
}
.nights-count {
  text-align: center;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}
.nights-count strong { color: var(--color-primary); }
.or-divider {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0.4rem 0;
}
/* ========================================
   INPUT MODE TOGGLE
   ======================================== */
.input-mode-toggle {
  display: flex;
  gap: 0.25rem;
  background: var(--color-bg-section);
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  padding: 0.2rem;
  margin-bottom: 0.75rem;
}
.toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.toggle-btn:hover { color: var(--color-primary); }
.toggle-btn.active {
  background: var(--color-bg-white);
  color: var(--color-primary);
  box-shadow: 0 1px 4px var(--color-shadow-primary);
}
.toggle-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.toggle-btn svg { flex-shrink: 0; }

/* ========================================
   DATE RANGE / NIGHTS GROUPS
   ======================================== */
.date-range-group,
.nights-group {
  transition: opacity 0.2s ease;
}

/* ========================================
   PEAK NOTE (when only nights are entered)
   ======================================== */
.peak-note {
  font-size: 0.78rem;
  color: #8a6f2b;
  background: #faf3dc;
  border: 1px solid #f0e4b8;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.6rem;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  line-height: 1.4;
}
.peak-note span { flex-shrink: 0; margin-top: 0.05rem; }

/* ========================================
   RESULT SURCHARGE
   ======================================== */
.result-surcharge {
  font-size: 0.8rem;
  color: #8a6f2b;
  margin-top: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: #faf3dc;
  border: 1px solid #f0e4b8;
  border-radius: 8px;
  display: none;
  align-items: flex-start;
  gap: 0.4rem;
  line-height: 1.4;
}
.result-surcharge.visible { display: flex; }
.result-surcharge span { margin-top: 0.05rem; }

.date-error {
  font-size: 0.8rem;
  color: var(--color-text-error);
  margin-top: 0.4rem;
  display: none;
}
.date-error.visible { display: block; }

/* ========================================
   POSITIONS / ITEMS
   ======================================== */
.items-section { margin-bottom: 1.25rem; }
.items-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary-light);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.items-list { display: flex; flex-direction: column; gap: 0.45rem; }
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  background: var(--color-bg-section);
  border: 1px solid var(--color-border-light);
  border-radius: 10px;
  transition: background 0.15s;
}
.item-row:hover { background: var(--color-bg-item-hover); }
.item-label {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--color-text);
}
.item-price {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}
.item-stepper {
  display: flex;
  align-items: center;
  gap: 0;
}
.stepper-btn {
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg-white);
  color: var(--color-primary);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  user-select: none;
}
.stepper-btn:first-child { border-radius: 8px 0 0 8px; }
.stepper-btn:last-child { border-radius: 0 8px 8px 0; }
.stepper-btn:hover { background: var(--color-primary-bg); border-color: var(--color-primary-muted); }
.stepper-btn:active { background: var(--color-primary-bg-hover); }
.stepper-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.stepper-btn:disabled { opacity: 0.3; cursor: not-allowed; background: var(--color-bg-disabled); }
.stepper-value {
  width: 44px;
  height: 34px;
  border-top: 1.5px solid var(--color-border);
  border-bottom: 1.5px solid var(--color-border);
  border-left: none;
  border-right: none;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg-white);
  -moz-appearance: textfield;
}
.stepper-value::-webkit-inner-spin-button,
.stepper-value::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-value:focus { outline: none; background: var(--color-primary-bg-focus); }
.item-line-total {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-primary);
  min-width: 68px;
  text-align: right;
  white-space: nowrap;
}

/* ========================================
   RESULT / SUMMARY
   ======================================== */
.result-section {
  background: linear-gradient(135deg, var(--color-bg-result-start) 0%, var(--color-bg-result-end) 100%);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.result-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary-light);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.result-table { width: 100%; border-collapse: collapse; }
.result-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-dim);
  padding: 0.3rem 0.4rem;
  border-bottom: 1.5px solid var(--color-border);
}
.result-table th:last-child,
.result-table td:last-child { text-align: right; }
.result-table td {
  padding: 0.35rem 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border-light);
}
.result-table .result-item-label { font-weight: 500; }
.result-table .result-item-qty { text-align: center; color: var(--color-text-muted); }
.result-table .result-item-price { text-align: right; color: var(--color-text-muted); }
.result-table .result-item-total { text-align: right; font-weight: 600; }
.result-empty {
  text-align: center;
  padding: 2rem 0;
  color: var(--color-text-faint);
  font-size: 0.85rem;
}
.result-grand-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.4rem 0;
  margin-top: 0.25rem;
  border-top: 2px solid var(--color-primary);
}
.result-grand-total-label {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-text);
}
.result-grand-total-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-primary);
}
.table-wrap {
  overflow: auto;
}

/* ========================================
   NOTES
   ======================================== */
.notes-section {
  background: var(--color-bg-section);
  border: 1px solid var(--color-border-light);
  border-radius: 14px;
  padding: 1rem 1.5rem;
}
.notes-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-dim);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.notes-list {
  list-style: none;
  padding: 0;
}
.notes-list li {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  padding: 0.3rem 0;
  padding-left: 1.1rem;
  position: relative;
  line-height: 1.4;
}
.notes-list li::before {
  content: "•";
  position: absolute;
  left: 0.3rem;
  color: var(--color-primary-muted);
}

/* ========================================
   LOADING / ERROR
   ======================================== */
.loading-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-dim);
}
.loading-state .spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 0.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-text-error);
}
.error-state .error-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 600px) {
  body { padding: 0.5rem; }
  .calculator-body { padding: 1rem 1rem 1.5rem; }
  .calculator-header { padding: 1.25rem 1rem; }
  .calculator-header h1 { font-size: 1.1rem; }
  .tab-btn { font-size: 0.7rem; padding: 0.55rem 0.4rem; }
  .input-mode-toggle { padding: 0.15rem; }
  .toggle-btn { font-size: 0.75rem; padding: 0.4rem 0.5rem; }
  .toggle-btn svg { display: none; }
  .date-row { flex-direction: column; gap: 0.5rem; }
  .date-field { min-width: 0; }
  .date-divider { display: none; }
  .item-row { flex-wrap: wrap; gap: 0.4rem; padding: 0.5rem; }
  .item-label { min-width: 100%; font-size: 0.82rem; }
  .item-price { min-width: auto; font-size: 0.75rem; }
  .item-line-total { min-width: 56px; font-size: 0.82rem; }
  .result-section { padding: 1rem; }
  .notes-section { padding: 0.75rem 1rem; }
  .result-grand-total-value { font-size: 1.15rem; }
}

@media (max-width: 400px) {
  .tabs { flex-direction: column; }
  .tab-btn { min-width: 0; }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
