@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

/* ------------------------------
   Variables & Theme
------------------------------ */
:root {
  --bg-color: #f0f5f9;
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --text-primary: #1a1d26;
  --text-secondary: #90a0b7;
  --accent-color: #4d8aff;
  --accent-gradient: linear-gradient(135deg, #4d8aff 0%, #3066be 100%);
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  --border-radius: 24px;
  --nav-icon-size: 1.5rem;
}

body.dark-mode {
  --bg-color: #12141c;
  --sidebar-bg: #1a1d26;
  --card-bg: #1f2330;
  --text-primary: #ffffff;
  --text-secondary: #90a0b7;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* ------------------------------
   Reset & Base Styles
------------------------------ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

html {
  width: 100%;
  scrollbar-gutter: stable both-edges;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  transition: background-color 0.3s ease;
  overflow-x: hidden;
  width: 100%;
  scrollbar-gutter: stable both-edges;
}

.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

/* ------------------------------
   Layout Structure
------------------------------ */
.container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: fixed;
  height: 100vh;
  transition: transform 0.3s ease;
  z-index: 100;
}

.main-content {
  flex: 1;
  margin-left: 250px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: auto;
  min-width: 0;
}

.dashboard {
  display: grid;
  grid-template-columns: 2.5fr 1fr;
  gap: 2rem;
}

.content-left {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ------------------------------
   Navigation
------------------------------ */
.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
  justify-content: center;
}

.nav-links li {
  width: 100%;
}

.nav-links li a {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 15px;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 12px 15px;
  border-radius: 16px;
  transition: all 0.3s ease;
}

.nav-links li.active a,
.nav-links li a:hover {
  color: var(--text-primary);
}

.nav-links li.active a {
  background-color: var(--bg-color);
}

body.dark-mode .nav-links li.active a {
  background-color: rgba(255, 255, 255, 0.05);
}

.menu-toggle {
  display: none !important;
}

/* ------------------------------
   Header & Components
------------------------------ */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.search-box {
  background: var(--card-bg);
  padding: 0.8rem 1.5rem;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 400px;
  max-width: 100%;
  box-shadow: var(--card-shadow);
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.search-box i {
  color: var(--text-secondary);
}

.icon-btn {
  background: var(--card-bg);
  border: none;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-primary);
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.2s;
}

.icon-btn:hover {
  transform: scale(1.05);
}

/* ------------------------------
   Views & Panels
------------------------------ */
.card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
}

.map-view {
  display: none;
  height: calc(100vh - 100px);
  border-radius: 20px;
  overflow: hidden;
  margin-top: 20px;
}

.panel-view {
  display: none;
  margin-top: 20px;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--card-shadow);
}

/* ------------------------------
   Weather Cards
------------------------------ */
.current-weather {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  background: var(--accent-gradient);
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.current-weather::before {
  content: "";
  position: absolute;
  top: -50px;
  right: -50px;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.current-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.location {
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.current-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.temp {
  font-size: 4rem;
  font-weight: 600;
  line-height: 1;
}

.condition {
  font-size: 1.1rem;
  margin-top: 5px;
  opacity: 0.9;
}

.weather-icon-lg {
  font-size: 5rem;
}

.current-footer {
  display: flex;
  gap: 3rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-item span {
  font-weight: 600;
  font-size: 1.1rem;
}

.stat-item small {
  opacity: 0.8;
  font-size: 0.85rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.view-all {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
}

/* Hourly Forecast */
.hourly-forecast {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 10px;
  max-width: 100%;
}

.hour-card {
  min-width: 100px;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    background 0.3s ease,
    color 0.3s ease;
}

.hour-card:hover {
  transform: translateY(-5px) scale(1.03);
}

.hour-card.active {
  background: var(--accent-gradient);
  color: #fff;
}

.hour-card .hour {
  font-size: 0.9rem;
  font-weight: 500;
}

.hour-card i {
  font-size: 1.5rem;
}

.hour-card .temp {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.2;
}

/* Highlights */
.highlights-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.highlight-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 160px;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.highlight-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.highlight-card h3 {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.highlight-value {
  font-size: 2rem;
  font-weight: 600;
  margin: 10px 0;
}

.highlight-value span {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.highlight-status {
  font-weight: 500;
}

.highlight-status.unhealthy {
  color: #ff5d5d;
}

.progress-bar {
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--accent-color);
  border-radius: 4px;
}

.sun-time {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sun-time i {
  font-size: 1.5rem;
  color: var(--accent-color);
}

.sun-time i.up {
  color: #ffb830;
}
.sun-time i.down {
  color: #ff9f1c;
}

/* Weekly Forecast */
.forecast-list {
  padding: 1.5rem;
  height: auto;
}

.forecast-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  opacity: 0;
  animation: slideInRight 0.5s ease forwards;
}

.forecast-item:last-child {
  border-bottom: none;
}

.forecast-item .day {
  width: 50px;
  font-weight: 500;
}

.forecast-item .icon-condition {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: center;
}

.forecast-item .temp-range {
  font-weight: 500;
}

.forecast-item .temp-range .low {
  color: var(--text-secondary);
}

.forecast-item:nth-child(1) {
  animation-delay: 0.7s;
}
.forecast-item:nth-child(2) {
  animation-delay: 0.8s;
}
.forecast-item:nth-child(3) {
  animation-delay: 0.9s;
}
.forecast-item:nth-child(4) {
  animation-delay: 1s;
}
.forecast-item:nth-child(5) {
  animation-delay: 1.1s;
}
.forecast-item:nth-child(6) {
  animation-delay: 1.2s;
}
.forecast-item:nth-child(7) {
  animation-delay: 1.3s;
}

/* ------------------------------
   Animations
------------------------------ */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-8px);
  }
  100% {
    transform: translateY(0px);
  }
}

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

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.content-left > * {
  animation: fadeInScale 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

.content-left .current-weather {
  animation-delay: 0.1s;
}
.content-left .section-header:nth-of-type(1) {
  animation-delay: 0.2s;
}
.content-left .hourly-forecast {
  animation-delay: 0.3s;
}
.content-left .section-header:nth-of-type(2) {
  animation-delay: 0.4s;
}
.content-left .highlights-grid {
  animation-delay: 0.5s;
}

.content-right {
  animation: slideInRight 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  animation-delay: 0.6s;
}

.weather-icon-lg i {
  display: inline-block;
  animation: float 4s ease-in-out infinite;
}

/* ------------------------------
   B. Responsive: Laptop (max 1200px)
------------------------------ */
@media screen and (max-width: 1200px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .highlights-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .search-box {
    width: 300px;
  }
}

/* ------------------------------
   C. Responsive: Tablet (max 992px)
------------------------------ */
@media screen and (max-width: 992px) {
  .sidebar {
    width: 80px;
    padding: 2rem 10px;
  }

  .sidebar .nav-links span {
    display: none;
  }

  .nav-links li a {
    justify-content: center;
    padding: 15px;
  }

  .main-content {
    margin-left: 80px;
    padding: 1.5rem;
    width: auto;
    min-width: 0;
  }

  .search-box {
    width: 250px;
  }

  .highlights-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .current-footer {
    gap: 1.5rem;
  }

  .hour-card {
    min-width: 85px;
  }
}

/* ------------------------------
   D. Responsive: Mobile (max 768px)
------------------------------ */
@media screen and (max-width: 768px) {
  /* Show hamburger, hide bottom bar — use slide-out sidebar */
  .menu-toggle {
    display: flex !important;
    margin-right: 10px;
    z-index: 1001;
  }

  .container {
    flex-direction: column;
  }

  /* Slide-out sidebar (hidden by default) */
  .sidebar {
    height: 100vh;
    width: 260px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: auto;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    flex-direction: column;
    padding: 2rem 1.5rem;
    background: var(--sidebar-bg);
    border-top: none;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Restore full nav-link labels in slide-out sidebar */
  .sidebar .nav-links span {
    display: inline;
    font-size: 1rem;
  }

  .nav-links {
    align-items: stretch;
  }

  .nav-links li a {
    flex-direction: row;
    gap: 15px;
    padding: 12px 15px;
    font-size: 1rem;
    justify-content: flex-start;
  }

  .nav-links li a i {
    font-size: var(--nav-icon-size);
  }

  /* Main content full width */
  .main-content {
    margin-left: 0;
    padding: 1.5rem;
    width: 100%;
    min-width: 0;
  }

  /* Header stacks vertically */
  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .header-left {
    width: 100%;
  }

  .header-left .user-greeting h1 {
    font-size: 1.3rem;
  }

  .search-box {
    width: 100%;
  }

  .header-right {
    width: 100%;
    justify-content: flex-end;
  }

  /* Dashboard single column */
  .dashboard {
    grid-template-columns: 1fr;
  }

  /* Highlights 2 columns */
  .highlights-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  /* Weather card */
  .current-weather {
    padding: 1.5rem;
    max-width: 100%;
  }

  .current-body {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .temp {
    font-size: 3rem;
  }

  .weather-icon-lg {
    font-size: 4rem;
  }

  .current-footer {
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
  }

  /* Hourly scrolls horizontally */
  .hourly-forecast {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .hour-card {
    min-width: 90px;
    flex-shrink: 0;
  }

  /* Forecast list */
  .content-right .forecast-list {
    padding: 1rem;
  }

  /* Map view full height minus header */
  .map-view {
    height: calc(100vh - 140px);
  }

  /* Panel views */
  .panel-view {
    padding: 16px;
  }
}

/* ------------------------------
   E. Responsive: Small Mobile (max 480px)
------------------------------ */
@media screen and (max-width: 480px) {
  .main-content {
    padding: 1rem;
    gap: 1.25rem;
  }

  .header {
    gap: 0.75rem;
  }

  .header-left .user-greeting h1 {
    font-size: 1.15rem;
  }

  .header-left .user-greeting p {
    font-size: 0.8rem;
  }

  .search-box {
    padding: 0.7rem 1rem;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  /* Weather card compact */
  .current-weather {
    padding: 1.25rem;
  }

  .current-header {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
    margin-bottom: 1.25rem;
  }

  .current-body {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  .temp {
    font-size: 2.5rem;
  }

  .weather-icon-lg {
    font-size: 3rem;
  }

  .current-footer {
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  .stat-item span {
    font-size: 0.95rem;
  }

  .stat-item small {
    font-size: 0.75rem;
  }

  /* Hourly: 3 per row wrapped grid */
  .hourly-forecast {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    overflow-x: visible;
  }

  .hour-card {
    min-width: 0;
    width: 100%;
    padding: 0.75rem;
  }

  .hour-card .temp {
    font-size: 1rem;
  }

  /* Highlights single column */
  .highlights-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .highlight-card {
    min-height: 130px;
  }

  .highlight-value {
    font-size: 1.6rem;
  }

  /* Forecast items compact */
  .forecast-item {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
  }

  .forecast-item .day {
    width: 45px;
    font-size: 0.85rem;
  }

  .forecast-item .icon-condition {
    gap: 6px;
    font-size: 0.85rem;
  }

  .forecast-item .icon-condition i {
    font-size: 1.1rem;
  }

  .forecast-item .temp-range {
    font-size: 0.85rem;
  }

  /* Section headers */
  .section-header h2 {
    font-size: 1rem;
  }

  .forecast-header h2 {
    font-size: 1rem;
  }

  /* Map smaller */
  .map-view {
    height: calc(100vh - 120px);
  }

  /* Sidebar slightly narrower */
  .sidebar {
    width: 240px;
  }
}

/* ------------------------------
   F. Responsive: Very Small (max 360px)
------------------------------ */
@media screen and (max-width: 360px) {
  .main-content {
    padding: 0.75rem;
    gap: 1rem;
  }

  .header-left .user-greeting h1 {
    font-size: 1rem;
  }

  .search-box {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }

  .current-weather {
    padding: 1rem;
  }

  .temp {
    font-size: 2.2rem;
  }

  .weather-icon-lg {
    font-size: 2.5rem;
  }

  .hourly-forecast {
    grid-template-columns: repeat(2, 1fr);
  }

  .icon-btn {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .sidebar {
    width: 220px;
  }
}
