/*
  Travel Itinerary Generator — modern, responsive CSS
  No framework. Simple colors. Centered card layout.

  KEY PARTS:
  • Variables (:root) — One place for colors, radius, shadows. Change --accent to rebrand.
  • Centered layout — .container uses max-width + margin auto so the card stays centered.
  • Card — .form is a white box with shadow and border; :focus-within adds a soft lift.
  • Inputs — Subtle border, accent border+shadow on :focus. select gets a custom arrow (no native dropdown arrow).
  • Button — Smooth hover: darker bg, slight translateY(-1px), soft blue shadow. :active and :disabled reset transform.
  • Responsive — .row becomes single column under 540px; body/form padding scales down on small screens.
  • Reduced motion — @media (prefers-reduced-motion) turns off transitions/transform for accessibility.
*/

/* ========== 1. Variables & reset ========== */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #2d3748;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --error-bg: #fef2f2;
  --error: #b91c1c;
  --success-bg: #f0fdf4;
  --success: #15803d;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ========== 2. Page & centered layout ========== */
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  padding: 1.5rem;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.container--narrow {
  max-width: 400px;
  text-align: center;
}

/* ========== 3. Header ========== */
.header {
  margin-bottom: 1.75rem;
  text-align: center;
}

.header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.tagline {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

/* ========== 4. Card (form) ========== */
.form {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 1.75rem;
  transition: box-shadow var(--transition);
}

.form:focus-within {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ========== 5. Fields & inputs ========== */
.field {
  margin-bottom: 1.25rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}

.field input,
.field textarea {
  background-image: none;
}

.field select {
  padding-right: 2.25rem;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-muted);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #cbd5e1;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.field-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ========== 6. Fieldsets ========== */
.fieldset {
  margin: 0;
  padding: 1.25rem 0 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.fieldset:first-of-type {
  padding-top: 0;
  border-top: none;
}

.fieldset-legend {
  margin-bottom: 1rem;
  padding: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

/* ========== 7. Row grid (responsive) ========== */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ========== 8. Messages ========== */
.form-message {
  display: none;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  line-height: 1.4;
}

.form-message.visible {
  display: block;
}

.form-message.error {
  background: var(--error-bg);
  color: var(--error);
}

.form-message.success {
  background: var(--success-bg);
  color: var(--success);
}

/* ========== 9. Button with smooth hover ========== */
.btn {
  display: inline-block;
  width: 100%;
  padding: 0.75rem 1.25rem;
  margin-top: 0.25rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  text-align: center;
  text-decoration: none;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform 0.15s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn:disabled:hover {
  background: var(--accent);
  transform: none;
}

/* ========== 10. Screen-reader only ========== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========== 11. Success page ========== */
.success-actions {
  margin-top: 1.5rem;
}

.success-actions .btn {
  width: auto;
}

/* ========== 12. Responsive breakpoints ========== */
@media (max-width: 540px) {
  body {
    padding: 1rem;
  }

  .container {
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
  }

  .header h1 {
    font-size: 1.375rem;
  }

  .form {
    padding: 1.25rem;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .fieldset {
    padding-top: 1rem;
  }

  .btn {
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
  }
}

@media (max-width: 360px) {
  body {
    padding: 0.75rem;
  }

  .form {
    padding: 1rem;
  }
}

/* ========== 13. Response Popup Modal ========== */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.popup-overlay.active {
  opacity: 1;
  visibility: visible;
}

.popup-content {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--transition);
}

.popup-overlay.active .popup-content {
  transform: scale(1);
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.popup-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.popup-close {
  background: none;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.popup-close:hover {
  background: var(--bg);
  color: var(--text);
}

.popup-close:active {
  background: var(--border);
}

.popup-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.popup-body pre {
  margin: 0;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-x: auto;
}

/* Popup responsive */
@media (max-width: 540px) {
  .popup-overlay {
    padding: 1rem;
  }

  .popup-content {
    max-height: 90vh;
  }

  .popup-header {
    padding: 1rem 1.25rem;
  }

  .popup-title {
    font-size: 1.125rem;
  }

  .popup-body {
    padding: 1.25rem;
  }

  .popup-body pre {
    font-size: 0.8125rem;
    padding: 0.75rem;
  }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .form,
  .field input,
  .field select,
  .field textarea,
  .btn,
  .popup-overlay,
  .popup-content {
    transition: none;
  }

  .btn:hover {
    transform: none;
  }
}
