/* ===== GLOBAL RESET & BASE ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg-from: #0d4f6e;
  --color-bg-mid: #0a7a6e;
  --color-bg-to: #06b89a;
  --color-glass: rgba(255, 255, 255, 0.14);
  --color-glass-border: rgba(255, 255, 255, 0.28);
  --color-glass-hover: rgba(255, 255, 255, 0.22);
  --color-text-primary: #ffffff;
  --color-text-secondary: rgba(255, 255, 255, 0.75);
  --color-text-muted: rgba(255, 255, 255, 0.55);
  --color-accent: #FFD54F;
  --color-accent2: #4FC3F7;
  --color-shadow: rgba(0, 0, 0, 0.2);
  --radius-card: 20px;
  --radius-sm: 10px;
  --transition: 0.25s ease;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  background: linear-gradient(145deg, var(--color-bg-from) 0%, var(--color-bg-mid) 50%, var(--color-bg-to) 100%);
  background-attachment: fixed;
  color: var(--color-text-primary);
  overflow-x: hidden;
  -ms-overflow-style: none;
  /* IE and Edge */
  scrollbar-width: none;
  /* Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
::-webkit-scrollbar {
  display: none;
}

/* Animated background orbs */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 100%;
  max-width: 600px;
  height: 600px;
  background: radial-gradient(circle, #00c4a7 0%, transparent 70%);
  top: -100px;
  left: -150px;
  animation: orb1 18s ease-in-out infinite alternate;
}

body::after {
  width: 100%;
  max-width: 500px;
  height: 500px;
  background: radial-gradient(circle, #0197c8 0%, transparent 70%);
  bottom: -100px;
  right: -120px;
  animation: orb2 22s ease-in-out infinite alternate;
}

@keyframes orb1 {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(80px, 60px) scale(1.2);
  }
}

@keyframes orb2 {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(-60px, -80px) scale(1.15);
  }
}

/* ===== LAYOUT ===== */
.page-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px 48px;
}

/* ===== HEADER ===== */
.app-header {
  position: relative;
  width: 100%;
  max-width: 860px;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.app-header__top-row {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  gap: 10px;
  position: relative;
}

.app-header__side-mirror {
  display: none;
}

.app-header__title {
  font-size: clamp(1.2rem, 5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 2;
  white-space: normal;
  text-align: center;
  width: 100%;
  padding: 0 85px;
  box-sizing: border-box;
}

.app-header__subtitle {
  margin-top: 6px;
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  font-weight: 400;
}

/* ===== LANG SELECTOR ===== */
.lang-selector {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  /* Align to top instead of center */
  z-index: 100;
}

@media (max-width: 640px) {
  .app-header__title {
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    gap: 6px;
  }

  .lang-dropdown {
    right: 0;
  }
}

.lang-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1.5px solid var(--color-glass-border);
  border-radius: 50px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  /* Slightly increased gap for the image */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all var(--transition);
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lang-flag {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-glass-border);
  border-radius: 12px;
  list-style: none;
  padding: 8px 0;
  margin: 0;
  min-width: 100px;
  display: none;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.lang-selector.open .lang-dropdown {
  display: flex;
}

.lang-dropdown li {
  padding: 8px 16px;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition);
}

.lang-dropdown li:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ===== SEARCH SECTION ===== */
.search-section {
  width: 100%;
  max-width: 860px;
  margin-bottom: 28px;
}

.search-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  flex-wrap: wrap;
  /* important to let the main search button wrap on small screens */
}

/* New input group housing both input and share button */
.search-input-group {
  display: flex;
  gap: 10px;
  flex: 1 1 300px;
}

.search-wrapper {
  position: relative;
  flex: 1;
}

.search-input {
  width: 100%;
  height: 50px;
  padding: 12px 18px;
  /* Regular padding instead of 46px */
  background: var(--color-glass);
  border: 1.5px solid var(--color-glass-border);
  border-radius: 50px;
  color: #fff;
  font-size: 0.95rem;
  font-family: inherit;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--transition);
  outline: none;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.search-input:focus {
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
  pointer-events: none;
}

.search-btn {
  padding: 14px 26px;
  background: rgba(255, 255, 255, 0.2);
  border: 1.5px solid var(--color-glass-border);
  border-radius: 50px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.search-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.search-btn:active {
  transform: translateY(0);
}

/* ===== AUTOCOMPLETE ===== */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.2);
  /* match lang-btn */
  border: 1.5px solid var(--color-glass-border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  z-index: 100;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  display: none;
}

.autocomplete-list.open {
  display: block;
}

.autocomplete-item {
  padding: 11px 20px;
  cursor: pointer;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.9);
  transition: background var(--transition);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background: rgba(255, 255, 255, 0.15);
}

/* ===== GLASS CARD BASE ===== */
.glass-card {
  background: var(--color-glass);
  border: 1px solid var(--color-glass-border);
  border-radius: var(--radius-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform var(--transition), box-shadow var(--transition);
}

/* ===== MAIN CARD ===== */
#main-card {
  width: 100%;
  max-width: 860px;
  margin-bottom: 20px;
}

.main-card {
  padding: 24px 20px;
}

.main-card__content {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.main-card__left {
  flex: 1 1 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-card__right {
  flex: 1 1 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

@media (min-width: 641px) {
  .main-card {
    padding: 28px 32px;
  }

  .main-card__left {
    flex: 1;
    min-width: 260px;
  }

  .main-card__right {
    flex: 1.2;
    min-width: 310px;
  }
}

/* Hourly panel */
.glass-panel {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
}

.hourly-header {
  text-align: right;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-primary);
  opacity: 0.95;
  margin-bottom: 20px;
}

.hourly-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hourly-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.hourly-time {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.hourly-temp {
  font-size: 1.05rem;
  font-weight: 700;
}

.main-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.main-card__city {
  font-size: 1.35rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.location-icon {
  flex-shrink: 0;
  color: var(--color-accent);
}

.main-card__date {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.main-card__body {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.main-card__icon {
  flex-shrink: 0;
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.25));
}

.main-card__temp-block {
  flex: 1 1 100%;
  min-width: 0;
}

@media (min-width: 480px) {
  .main-card__temp-block {
    flex: 1;
  }
}

.main-card__temp {
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2px;
}

.temp-unit {
  font-size: 0.45em;
  font-weight: 400;
  vertical-align: super;
  opacity: 0.8;
}

.main-card__label {
  font-size: 1.05rem;
  color: var(--color-text-secondary);
  margin-top: 6px;
  font-weight: 500;
}

.main-card__temp-range {
  margin-top: 10px;
  display: flex;
  gap: 14px;
  font-size: 1rem;
  font-weight: 600;
}

.temp-max {
  color: #FFD54F;
}

.temp-min {
  color: #80DEEA;
}

/* Details row */
.main-card__details {
  display: flex;
  gap: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 20px;
  flex-wrap: nowrap;
}

.detail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1 1 0;
  min-width: 0;
  padding: 0 4px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  word-break: break-word;
  hyphens: auto;
}

.detail-item:last-child {
  border-right: none;
}

.detail-item svg {
  color: var(--color-accent2);
}

.detail-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-value {
  font-size: 1rem;
  font-weight: 700;
}

/* ===== FORECAST GRID ===== */
#forecast-grid {
  width: 100%;
  max-width: 860px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.forecast-card {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  padding: 24px 28px;
  margin-bottom: 12px;
  cursor: default;
}

.forecast-card__col-left,
.forecast-card__col-center,
.forecast-card__col-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.forecast-card__col-left {
  align-items: flex-start;
  text-align: left;
  gap: 4px;
}

.forecast-card__col-center {
  align-items: center;
  text-align: center;
  gap: 6px;
}

.forecast-card__col-right {
  align-items: flex-end;
  text-align: right;
  gap: 4px;
}

.forecast-card__icon {
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

.forecast-card__day {
  font-weight: 700;
  font-size: 0.95rem;
}

.forecast-card__date {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.forecast-card__label {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  line-height: 1.35;
  word-break: break-word;
  hyphens: auto;
  margin-top: 6px;
  display: block;
}

.forecast-card__temps {
  display: flex;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  justify-content: flex-end;
}

@media (min-width: 641px) {
  #forecast-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }

  .forecast-card {
    padding: 24px 16px;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 16px;
  }

  .forecast-card__col-left,
  .forecast-card__col-center,
  .forecast-card__col-right {
    align-items: center;
    text-align: center;
    gap: 8px;
  }

  /* Force desktop vertical stacking order */
  .forecast-card__col-left {
    order: 1;
    gap: 4px;
  }

  .forecast-card__col-center {
    order: 2;
  }

  .forecast-card__col-right {
    order: 3;
  }

  .forecast-card__temps {
    justify-content: center;
  }
}

.forecast-card__wind {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* ===== LOADING STATE ===== */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
  color: var(--color-text-secondary);
}

.loader {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== ERROR CARD ===== */
.error-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 24px;
  text-align: center;
  color: rgba(255, 200, 100, 0.85);
  width: 100%;
  max-width: 860px;
  background: var(--color-glass);
  border: 1px solid rgba(255, 200, 100, 0.25);
  border-radius: var(--radius-card);
  backdrop-filter: blur(16px);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeInUp 0.4s ease both;
}

/* ===== FOOTER ===== */
.app-footer {
  text-align: center;
  padding: 20px;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

@media (max-width: 640px) {
  .app-footer {
    flex-direction: column;
    gap: 8px;
  }
}

/* ===== SHARE & TOAST ===== */
.share-btn {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-message {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

.toast-message.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .main-card__body {
    gap: 16px;
  }

  .detail-item {
    padding: 0 6px;
  }

  .search-row {
    flex-direction: column;
  }

  .search-wrapper {
    flex: 1;
    min-width: 0;
    /* allows flex item to shrink below content width */
  }

  .search-input-group {
    flex: none;
    width: 100%;
  }

  .main-search-btn {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .detail-item {
    padding: 0 2px;
  }

  .detail-label {
    font-size: 0.65rem;
  }

  .detail-value {
    font-size: 0.9rem;
  }
}