/* Weather App Styles */

/* Variables */
:root {
  --primary-color: #3498db;
  --primary-dark: #2980b9;
  --secondary-color: #2ecc71;
  --secondary-dark: #27ae60;
  --background-color: #f8fafc;
  --card-color: #ffffff;
  --text-color: #2d3748;
  --text-light: #718096;
  --divider-color: #e2e8f0;
  --danger-color: #e53e3e;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --radius: 0.5rem;
  --shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --transition: 200ms ease-out;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.5;
  min-height: 100vh;
}

#root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.hidden {
  display: none !important;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: 1.25;
}

img {
  max-width: 100%;
  height: auto;
}

button {
  cursor: pointer;
  font-family: inherit;
}

/* Layout */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

main.container {
  flex: 1;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}

section {
  margin-bottom: 1.5rem;
}

/* Header */
header {
  background-color: var(--primary-color);
  color: white;
  padding: 1rem 0;
  box-shadow: var(--shadow);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Navigation Menu with CSS-only hamburger */
.nav-menu {
  position: relative;
}

/* Hamburger menu checkbox (hidden but functional) */
.menu-toggle {
  display: none;
}

.menu-toggle-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

/* Hamburger icon using spans */
.hamburger-icon,
.hamburger-icon::before,
.hamburger-icon::after {
  display: block;
  background-color: white;
  height: 3px;
  width: 25px;
  transition: all 0.3s ease-in-out;
  position: relative;
}

.hamburger-icon::before,
.hamburger-icon::after {
  content: "";
  position: absolute;
}

.hamburger-icon::before {
  top: -8px;
}

.hamburger-icon::after {
  top: 8px;
}

/* Menu items styling */
.menu-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 100%;
  right: 0;
  background-color: var(--primary-color);
  width: 200px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
  z-index: 1;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.menu-items li {
  margin: 0;
}

.menu-items a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  padding: 0.75rem 1rem;
  display: block;
  transition: background-color var(--transition);
}

.menu-items a:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.menu-items a.active {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Toggle menu visibility when checkbox is checked */
.menu-toggle:checked ~ .menu-items {
  max-height: 300px; /* Large enough to contain all items */
}

/* Change hamburger to X when menu is open */
.menu-toggle:checked ~ .menu-toggle-label .hamburger-icon {
  background: transparent;
}

.menu-toggle:checked ~ .menu-toggle-label .hamburger-icon::before {
  transform: rotate(45deg);
  top: 0;
}

.menu-toggle:checked ~ .menu-toggle-label .hamburger-icon::after {
  transform: rotate(-45deg);
  top: 0;
}

/* Desktop styles */
@media (min-width: 768px) {
  .menu-toggle-label {
    display: none;
  }

  .menu-items {
    position: static;
    flex-direction: row;
    max-height: none;
    width: auto;
    background: none;
    box-shadow: none;
    overflow: visible;
  }

  .menu-items li {
    margin: 0 0 0 1rem;
  }

  .menu-items a {
    padding: 0.5rem 1rem;
  }
}

/* Footer */
footer {
  background-color: var(--gray-800);
  color: var(--gray-300);
  padding: 1.5rem 0;
  margin-top: auto;
  font-size: 0.875rem;
}

footer p {
  margin-bottom: 0.5rem;
}

/* Cards */
.card {
  background-color: var(--card-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  height: 100%;
}

/* Search Form */
form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.input-wrapper {
  position: relative;
  flex: 1;
}

input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color var(--transition);
}

input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.clear-button {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  color: var(--gray-400);
  font-size: 1.25rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-button:hover {
  color: var(--danger-color);
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  transition: background-color var(--transition);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-dark);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: var(--gray-200);
  color: var(--gray-700);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.875rem;
  transition: background-color var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--gray-300);
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Weather Section */
.weather-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

#cityName {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

#currentDateTime {
  color: var(--text-light);
  font-size: 0.875rem;
}

.last-updated {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-light);
  font-size: 0.875rem;
}

.weather-content {
  margin-top: 1rem;
}

.current-weather {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.weather-primary {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.weather-icon {
  flex-shrink: 0;
}

.weather-icon img {
  width: 80px;
  height: 80px;
}

.temperature {
  font-size: 2.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.weather-description {
  color: var(--text-light);
  text-transform: capitalize;
}

.weather-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.weather-detail {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background-color: var(--gray-50);
  border-radius: var(--radius);
}

.weather-detail i {
  font-size: 1.25rem;
  color: var(--primary-color);
}

.weather-detail p:first-of-type {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.weather-detail p:last-of-type {
  font-weight: 600;
}

/* Map Section */
.section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.25rem;
}

.section-header i {
  color: var(--primary-color);
}

.map-container {
  height: 250px;
  border-radius: var(--radius);
  overflow: hidden;
  background-color: var(--gray-100);
  position: relative;
}

.map-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* State Containers (Empty, Loading, Error) */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
  min-height: 200px;
  gap: 1rem;
}

.state-container .state-icon {
  font-size: 3rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.state-container .state-icon.error {
  color: var(--danger-color);
}

.state-container h3 {
  margin-bottom: 0.5rem;
}

.state-container p {
  color: var(--text-light);
  max-width: 300px;
  margin: 0 auto;
}

.spinner {
  display: inline-block;
  width: 2.5rem;
  height: 2.5rem;
  border: 0.25rem solid var(--gray-200);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* History Section */
.history-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: var(--gray-50);
  border-radius: var(--radius);
  transition: background-color var(--transition);
  cursor: pointer;
}

.history-item:hover {
  background-color: var(--gray-100);
}

.history-item-city {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.city-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background-color: var(--primary-color);
  color: white;
  border-radius: 50%;
  flex-shrink: 0;
}

.city-info h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.city-info p {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.history-item-weather {
  text-align: right;
}

.history-item-weather p:first-of-type {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.history-item-weather p:last-of-type {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.history-actions {
  display: flex;
  justify-content: flex-end;
}

/* Desktop layout container */
.desktop-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.main-content {
  width: 100%;
}

.sidebar {
  width: 100%;
}

/* Page explanation box */
.page-explanation {
  background-color: #edf2f7;
  border-left: 4px solid #2b6cb0;
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: 0.25rem;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Media Queries */
@media (min-width: 640px) {
  form {
    flex-direction: row;
  }

  header h1 {
    font-size: 1.75rem;
  }

  .weather-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .map-container {
    height: 300px;
  }
}

@media (min-width: 768px) {
  .current-weather {
    flex-direction: row;
  }

  .weather-primary {
    flex: 1;
  }

  .weather-details {
    flex: 2;
  }

  .map-container {
    height: 400px;
  }
}

@media (min-width: 1024px) {
  main.container {
    padding-top: 2rem;
    padding-bottom: 3rem;
  }

  .desktop-container {
    flex-direction: row;
  }

  .main-content {
    flex: 2;
  }

  .sidebar {
    flex: 1;
  }

  section {
    margin-bottom: 2.5rem;
  }

  .card {
    transition: transform var(--transition);
  }

  .card:hover {
    transform: translateY(-2px);
  }
}
