/* =========================================================
   ROOT VARIABLES (GLOBAL THEME SETTINGS)
   Defines reusable colors, spacing, and design tokens
   ========================================================= */
:root {
  --primary: #6a11cb;
  --secondary: #2575fc;
  --accent: #f65282;
  --bg: #eef2ff;
  --text: #1e293b;
  --muted: #64748b;
  --card-bg: #ffffff;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
}

/* =========================================================
   GLOBAL RESET + BASE STYLES
   Removes default spacing and sets base font
   ========================================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Inter", sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  padding: 20px;
}

/* =========================================================
   MAIN APP CONTAINER (CENTERED CARD LAYOUT)
   ========================================================= */
.weather-app {
  max-width: 760px;
  margin: auto;
  background: var(--card-bg);
  padding: 30px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* =========================================================
   HEADINGS (H1, H2)
   ========================================================= */
h1, h2 {
  text-align: center;
  font-weight: 600;
}

/* =========================================================
   SEARCH BAR SECTION
   ========================================================= */
.search-form {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.search-input {
  flex: 1;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #c7d2fe;
  font-size: 16px;
}

.search-input:focus {
  border-color: var(--primary);
  outline: none;
}

.search-button {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  padding: 14px 20px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

/* =========================================================
   ACTION BUTTONS (LOCATION, RANDOM CITY, ETC.)
   ========================================================= */
.location-button {
  margin-top: 10px;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: #e0e7ff;
  cursor: pointer;
}

/* =========================================================
   CURRENT WEATHER DISPLAY SECTION
   ========================================================= */
.weather-data {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 25px;
}

.city {
  font-size: 36px;
  font-weight: 600;
}

.details {
  color: var(--muted);
  font-size: 15px;
}

.details strong {
  color: var(--accent);
}

/* =========================================================
   TEMPERATURE DISPLAY SECTION
   ========================================================= */
.temperature-container {
  display: flex;
  align-items: center;
}

.temperature {
  font-size: 76px;
  font-weight: 700;
  color: var(--accent);
  margin-left: 8px;
}

/* =========================================================
   UNIT SWITCH (°C / °F TOGGLE)
   ========================================================= */
.unit-toggle {
  font-size: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.unit-toggle span {
  cursor: pointer;
  color: var(--primary);
  opacity: 0.6;
  transition: 0.2s ease;
}

.unit-toggle span:hover {
  opacity: 1;
}

.active-unit {
  font-weight: 700;
  color: var(--accent);
  opacity: 1 !important;
  text-decoration: underline;
}

.separator {
  cursor: default;
  opacity: 0.4;
}

/* =========================================================
   WEATHER ICON
   ========================================================= */
#icon img {
  width: 80px;
}

/* =========================================================
   FORECAST GRID (DESKTOP DEFAULT)
   ========================================================= */
.forecast {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 15px;
  margin-top: 20px;
  justify-items: center;
  text-align: center;
}

.forecast-day {
  background: #fff;
  border-radius: 14px;
  padding: 12px 10px;
  width: 100%;
  max-width: 120px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.today {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
}

.forecast-date {
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 6px;
}

.forecast-icon {
  width: 55px;
  margin: 0 auto;
}

/* =========================================================
   FORECAST TEMPERATURE DETAILS
   ========================================================= */
.forecast-temps {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.max-temp,
.min-temp {
  display: flex;
  justify-content: center;
  gap: 6px;
  align-items: center;
}

.max-temp strong {
  color: #f65282;
  font-size: 15px;
}

.min-temp {
  color: #64748b;
  font-size: 13px;
}

.label {
  font-size: 10px;
  font-weight: 700;
  color: #6a11cb;
  letter-spacing: 0.5px;
}

/* =========================================================
   UTILITY CLASSES
   ========================================================= */
.hidden {
  display: none;
}

/* =========================================================
   ERROR MESSAGE BOX
   ========================================================= */
.error-message {
  text-align: center;
  margin-top: 20px;
  padding: 20px;
  border-radius: 12px;
  background: #fee2e2;
  color: #b91c1c;
}

/* =========================================================
   SMOOTH UI TRANSITIONS
   ========================================================= */
#weather-content {
  transition: 0.3s ease;
}

/* =========================================================
   SEARCH HISTORY BUTTONS
   ========================================================= */
.history {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  justify-content: center;
}

.history-btn {
  background: #e0e7ff;
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--primary);
  transition: 0.2s;
}

.history-btn:hover {
  background: #c7d2fe;
}

/* =========================================================
   NEARBY CITIES (DESKTOP GRID)
   ========================================================= */
#nearby {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 15px;
}

.nearby-btn {
  background: #e0e7ff;
  border: none;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;

  font-size: 14px;
  color: var(--primary);
  font-weight: 500;

  width: 100%;
  height: 100%;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  text-align: center;
  transition: 0.2s ease;
}

.nearby-btn:hover {
  background: #c7d2fe;
  transform: translateY(-2px);
}

/* =========================================================
   FOOTER SECTION
   ========================================================= */
footer {
  margin-top: 40px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* =========================================================
   TABLET RESPONSIVE DESIGN
   ========================================================= */
@media (max-width: 768px) {

  body {
    padding: 12px;
  }

  .weather-app {
    padding: 18px;
    width: 100%;
  }

  h1 {
    font-size: 22px;
  }

  .weather-data {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 15px;
  }

  .city {
    font-size: 28px;
  }

  .details {
    font-size: 13px;
    line-height: 1.4;
  }

  .temperature-container {
    justify-content: center;
    flex-direction: row;
    gap: 10px;
  }

  .temperature {
    font-size: 48px;
    margin-left: 0;
  }

  #icon img {
    width: 60px;
  }

  .search-form {
    flex-direction: column;
  }

  .search-input,
  .search-button {
    width: 100%;
  }

  #current-location {
    display: none;
  }
}

/* =========================================================
   MOBILE FORECAST SCROLL (HORIZONTAL CARDS)
   ========================================================= */
.forecast {
  display: flex;
  overflow-x: auto;
  gap: 12px;
  padding-bottom: 10px;
  scroll-snap-type: x mandatory;
}

.forecast-day {
  min-width: 90px;
  flex: 0 0 auto;
  scroll-snap-align: start;
}

/* =========================================================
   DARK MODE THEME
   ========================================================= */
body.dark {
  --bg: #0f172a;
  --text: #e2e8f0;
  --card-bg: #111827;
  --muted: #94a3b8;

  --primary: #6a11cb;
  --secondary: #2575fc;
  --accent: #f65282;

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* =========================================================
   LOADING ANIMATION
   ========================================================= */
#loader {
  text-align: center;
  margin-top: 20px;
  font-weight: 600;
}

#loader::after {
  content: " ...";
  animation: dots 1s infinite steps(3, end);
}

@keyframes dots {
  0% { content: ""; }
  33% { content: "."; }
  66% { content: ".."; }
  100% { content: "..."; }
}

/* =========================================================
   SMALL PHONES
   ========================================================= */
@media (max-width: 480px) {

  .weather-app {
    padding: 14px;
  }

  .city {
    font-size: 24px;
  }

  .temperature {
    font-size: 42px;
  }

  .forecast-day {
    min-width: 80px;
  }
}

/* =========================================================
   AI WEATHER ASSISTANT BOX
   ========================================================= */
#advice {
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
}

.ai-box {
  margin-top: 15px;
  padding: 15px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6a11cb20, #2575fc20);
  border: 1px solid #c7d2fe;
  font-size: 14px;
  line-height: 1.6;
}

#ai-text {
  margin: 0;
}

body.dark .ai-box {
  background: rgba(255,255,255,0.05);
  border: 1px solid #334155;
}

/* =========================================================
   NEARBY CITIES MOBILE BEHAVIOR
   ========================================================= */
@media (max-width: 768px) {

  #nearby {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 10px;
    scroll-snap-type: x mandatory;
  }

  .nearby-btn {
    min-width: 110px;
    flex: 0 0 auto;
    scroll-snap-align: start;

    border-radius: 14px;
    padding: 14px 10px;
  }
}

/* =========================================================
   EXTRA SMALL PHONES
   ========================================================= */
@media (max-width: 480px) {
  .nearby-btn {
    min-width: 95px;
    font-size: 13px;
  }
}