/* ==========================================================================
   Travel Insight - Reusable UI Components
   Buttons, Inputs, Cards, Modals, Skeleton Loaders, Badges, Error States
   ========================================================================== */

/* Button System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary) 0%, #1d4ed8 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px 0 var(--accent-primary-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 6px 20px 0 var(--accent-primary-glow);
  text-decoration: none;
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--border-subtle);
  text-decoration: none;
}

.btn-outline {
  background-color: transparent;
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--accent-primary-glow);
  text-decoration: none;
}

.btn-sm {
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
  min-height: 36px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.9rem 2rem;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

.btn-xs {
  padding: 0.25rem 0.65rem !important;
  font-size: 0.78rem !important;
  min-height: 28px !important;
  border-radius: var(--radius-sm) !important;
}

.section-focus-banner {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  animation: fadeIn 200ms ease;
}

/* Card System */
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal), transform var(--transition-normal), border-color var(--transition-normal);
}

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

.glass-card {
  background: var(--bg-glass-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Form Inputs & Fields */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
}

.form-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.8rem;
  font-size: 1rem;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.form-input.has-error {
  border-color: var(--accent-rose);
  background-color: var(--accent-rose-subtle);
}

.field-error-msg {
  font-size: 0.8rem;
  color: var(--accent-rose);
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.2rem;
}

.field-error-msg.visible {
  display: flex;
}

/* Autocomplete Suggestion Dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  width: 100%;
  background-color: var(--bg-secondary);
  border: 1.5px solid var(--border-focus);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
  z-index: 99999;
  max-height: 360px;
  overflow-y: auto;
  display: none;
  padding: 0.4rem;
}

.autocomplete-dropdown.open {
  display: block !important;
}

.autocomplete-header-label {
  padding: 0.45rem 0.75rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.3rem;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.autocomplete-item:hover, .autocomplete-item.focused {
  background-color: var(--bg-tertiary);
  border-left: 3px solid var(--accent-primary);
}

.item-main {
  display: flex;
  flex-direction: column;
}

.item-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.item-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.item-type-badge {
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  line-height: 1.2;
}

.badge-alert {
  background-color: var(--badge-alert-bg);
  color: var(--badge-alert-text);
  border-color: var(--badge-alert-border);
}

.badge-safe {
  background-color: var(--badge-safe-bg);
  color: var(--badge-safe-text);
  border-color: var(--badge-safe-border);
}

.badge-info {
  background-color: var(--badge-info-bg);
  color: var(--badge-info-text);
  border-color: var(--badge-info-border);
}

/* Travel-Impacting Warning Pill (High Visibility) */
.badge-travel-impacting {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #ffffff;
  border: 1px solid #f87171;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.75rem;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}

/* Accordion Component */
.accordion {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
  overflow: hidden;
}

.accordion-header {
  width: 100%;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
}

.accordion-header:hover {
  background-color: var(--bg-tertiary);
}

.accordion-icon {
  transition: transform var(--transition-normal);
  color: var(--text-muted);
}

.accordion.expanded .accordion-icon {
  transform: rotate(180deg);
}

.accordion-content {
  display: none;
  padding: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-primary);
}

.accordion.expanded .accordion-content {
  display: block;
}

/* Skeleton Loaders (Independent Section Loading per FR-2.3) */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-subtle) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite ease-in-out;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
  width: 100%;
}

.skeleton-title {
  height: 2rem;
  margin-bottom: 1rem;
  width: 60%;
}

.skeleton-box {
  width: 100%;
  height: 240px;
  border-radius: var(--radius-lg);
}

.skeleton-card {
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Section Independent Error & Retry Container (FR-2.4) */
.section-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  background-color: var(--bg-secondary);
  border: 1.5px dashed var(--accent-rose);
  border-radius: var(--radius-lg);
  gap: 1rem;
}

.section-error-icon {
  width: 48px;
  height: 48px;
  color: var(--accent-rose);
}

.section-error-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.section-error-desc {
  max-width: 460px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Modals & Dialogs (WCAG Accessible) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-normal);
}

.modal-backdrop.open .modal-container {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--bg-primary);
}

/* Toast Feedback */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  pointer-events: auto;
  font-size: 0.9rem;
  font-weight: 500;
  animation: slide-up 250ms ease-out;
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Currency Selector Pill */
.currency-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-tertiary);
  padding: 3px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}

.currency-btn {
  border: none;
  background: transparent;
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  min-height: auto;
}

.currency-btn:hover {
  color: var(--text-primary);
}

.currency-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

@media (max-width: 640px) {
  .currency-switcher {
    padding: 2px 4px;
    gap: 0.15rem;
  }
  .currency-btn {
    padding: 3px 6px;
    font-size: 0.72rem;
  }
}

@media (max-width: 420px) {
  .currency-switcher {
    padding: 2px 3px;
    gap: 0.1rem;
  }
  .currency-btn {
    padding: 2px 4.5px;
    font-size: 0.68rem;
  }
}

/* Distance & Unit Switcher Pill (km / miles) */
.unit-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-tertiary);
  padding: 3px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--transition-fast);
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}

.unit-switcher:hover {
  border-color: var(--border-focus);
}

.unit-btn {
  border: none;
  background: transparent;
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  min-height: auto;
}

.unit-btn span {
  pointer-events: none;
}

.unit-btn:hover {
  color: var(--text-primary);
}

.unit-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.unit-text-short {
  display: none;
}

@media (max-width: 640px) {
  .unit-switcher {
    padding: 2px 4px;
    gap: 0.15rem;
  }
  .unit-btn {
    padding: 3px 6px;
    font-size: 0.72rem;
  }
  .unit-text-long {
    display: none;
  }
  .unit-text-short {
    display: inline;
  }
}

@media (max-width: 480px) {
  .toast-container {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: calc(100vw - 2rem);
  }
  .toast {
    width: 100%;
    justify-content: center;
    font-size: 0.82rem;
    padding: 0.65rem 1rem;
  }
}

.footer-seo-link {
  color: var(--text-secondary);
  text-decoration: none;
  background: var(--bg-secondary);
  padding: 0.28rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  transition: all 150ms ease;
  font-weight: 500;
}

.footer-seo-link:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--bg-tertiary);
}

/* ==========================================================================
   Global Header & Brand Logo Components
   ========================================================================== */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background-color: var(--bg-glass);
  border-bottom: 1px solid var(--border-subtle);
  height: var(--header-height, 64px);
  display: flex;
  align-items: center;
  transition: all var(--transition-normal);
}

.top-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.03em;
  flex-shrink: 0;
}

.brand-logo svg {
  width: 32px !important;
  height: 32px !important;
  max-width: 32px !important;
  max-height: 32px !important;
  color: var(--accent-primary);
  filter: drop-shadow(0 2px 4px var(--accent-primary-glow));
  flex-shrink: 0;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-teal));
  color: #fff;
  text-transform: uppercase;
  margin-left: 0.25rem;
}

/* Main Navigation Tabs in Header */
.header-nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 7px 15px;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] .nav-tab:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-tab.active {
  background: var(--bg-elevated);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.nav-tab .tab-text-short {
  display: none;
}
.nav-tab .tab-text-full {
  display: inline;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.icon-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

@media (max-width: 768px) {
  .top-header {
    height: auto !important;
    padding: 0.5rem 0 0.55rem;
  }
  .top-header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    row-gap: 0.5rem;
  }
  .header-nav-tabs {
    order: 3;
    width: 100%;
    display: flex !important;
    justify-content: space-between;
    margin-top: 0.2rem;
    padding: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
  }
  .nav-tab {
    flex: 1;
    justify-content: center;
    text-align: center;
    padding: 8px 8px;
    font-size: 0.82rem;
    min-height: 40px;
    border-radius: var(--radius-full);
  }
  .header-actions {
    gap: 0.35rem;
  }
  .brand-logo {
    font-size: 1.05rem;
    gap: 0.4rem;
  }
  .brand-logo svg {
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
  }
  .brand-badge {
    display: none;
  }
  .icon-btn {
    width: 34px;
    height: 34px;
    min-height: 34px;
  }
}

@media (max-width: 640px) {
  .header-actions {
    gap: 0.25rem;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
    min-height: 32px;
  }
  .brand-logo {
    font-size: 0.96rem;
  }
}

@media (max-width: 480px) {
  .nav-tab {
    font-size: 0.8rem;
    padding: 7px 6px;
    gap: 0.35rem;
  }
  .nav-tab .tab-text-full {
    display: none;
  }
  .nav-tab .tab-text-short {
    display: inline;
  }
  .header-actions {
    gap: 0.2rem;
  }
  .brand-logo {
    font-size: 0.9rem;
    gap: 0.3rem;
  }
  .brand-logo svg {
    width: 22px !important;
    height: 22px !important;
    max-width: 22px !important;
    max-height: 22px !important;
  }
}

