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

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --temp-primary: #ff6b35;
  --temp-secondary: #ff8c42;
  --hum-primary: #3a7bd5;
  --hum-secondary: #4facfe;
  --purple-primary: #667eea;
  --purple-secondary: #764ba2;
  --spacing-xs: 0.5rem;
  --spacing-sm: 0.75rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 2.5rem;
  --border-radius-sm: 12px;
  --border-radius-md: 16px;
  --border-radius-lg: 20px;
  --border-radius-xl: 24px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

html {
  height: -webkit-fill-available;
}

body {
  font-family: "Outfit", sans-serif;
  background: var(--primary-gradient);
  color: #ffffff;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
  position: relative;
  overflow-x: hidden;
}

/* Animated Background Effects */
.bg-effects {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background: var(--primary-gradient);
}

.heat-wave {
  position: absolute;
  top: -50%;
  left: -10%;
  width: 50%;
  height: 200%;
  background: radial-gradient(
    ellipse,
    rgba(255, 107, 53, 0.08) 0%,
    transparent 70%
  );
  animation: heatPulse 8s ease-in-out infinite;
}

.water-ripple {
  position: absolute;
  bottom: -50%;
  right: -10%;
  width: 50%;
  height: 200%;
  background: radial-gradient(
    ellipse,
    rgba(58, 123, 213, 0.08) 0%,
    transparent 70%
  );
  animation: waterPulse 10s ease-in-out infinite;
}

@keyframes heatPulse {
  0%,
  100% {
    transform: scale(1) translateY(0);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.2) translateY(-20px);
    opacity: 0.8;
  }
}

@keyframes waterPulse {
  0%,
  100% {
    transform: scale(1) translateY(0);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.3) translateY(20px);
    opacity: 0.8;
  }
}

.container {
  flex: 1;
  width: 100%;
  max-width: 1400px;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.8s ease;
}

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

/* Header */
header {
  text-align: center;
  margin-bottom: var(--spacing-2xl);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 auto var(--spacing-lg);
  padding: var(--spacing-sm) var(--spacing-lg);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 400px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.connecting {
  background: #f59e0b;
  box-shadow: 0 0 10px #f59e0b;
}

.status-dot.error {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
  animation: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2);
  }
}

.status-text {
  font-size: 1rem;
  font-weight: 500;
  color: #e5e7eb;
}

.sync-time {
  font-size: 1rem;
  color: #9ca3af;
  font-weight: 500;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(
    135deg,
    var(--temp-primary) 0%,
    var(--hum-primary) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.title-icon {
  font-size: 2rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.subtitle {
  font-size: 1rem;
  color: #9ca3af;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* Main Grid - Symmetrical Layout */
main {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
}

/* Theme Sections - Equal Heights */
.theme-section {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border-radius: var(--border-radius-xl);
  padding: var(--spacing-xl);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.theme-section:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Temperature Theme */
.temperature-theme {
  background: linear-gradient(
    135deg,
    rgba(255, 107, 53, 0.1) 0%,
    rgba(255, 68, 68, 0.05) 100%
  );
  border: 1px solid rgba(255, 107, 53, 0.3);
  box-shadow: 0 8px 32px rgba(255, 107, 53, 0.15);
}

.temperature-theme .theme-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fire-particle {
  position: absolute;
  width: 60px;
  height: 60px;
  background: radial-gradient(
    circle,
    rgba(255, 107, 53, 0.3) 0%,
    transparent 70%
  );
  border-radius: 50%;
  animation: fireFloat 6s ease-in-out infinite;
}

.fire-particle:nth-child(1) {
  top: 20%;
  right: 10%;
  animation-delay: 0s;
}

.fire-particle:nth-child(2) {
  bottom: 30%;
  right: 20%;
  animation-delay: 2s;
  animation-duration: 8s;
}

.fire-particle:nth-child(3) {
  top: 60%;
  right: 5%;
  animation-delay: 4s;
  animation-duration: 7s;
}

@keyframes fireFloat {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.3;
  }
  50% {
    transform: translate(-10px, -20px) scale(1.2);
    opacity: 0.6;
  }
}

/* Humidity Theme */
.humidity-theme {
  background: linear-gradient(
    135deg,
    rgba(58, 123, 213, 0.1) 0%,
    rgba(14, 165, 233, 0.05) 100%
  );
  border: 1px solid rgba(58, 123, 213, 0.3);
  box-shadow: 0 8px 32px rgba(58, 123, 213, 0.15);
}

.humidity-theme .theme-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.water-drop {
  position: absolute;
  width: 40px;
  height: 40px;
  background: radial-gradient(
    circle,
    rgba(58, 123, 213, 0.3) 0%,
    transparent 70%
  );
  border-radius: 50%;
  animation: waterDrop 5s ease-in-out infinite;
}

.water-drop:nth-child(1) {
  top: 15%;
  left: 15%;
  animation-delay: 0s;
}

.water-drop:nth-child(2) {
  top: 45%;
  left: 10%;
  animation-delay: 1.5s;
  animation-duration: 6s;
}

.water-drop:nth-child(3) {
  top: 70%;
  left: 20%;
  animation-delay: 3s;
  animation-duration: 7s;
}

@keyframes waterDrop {
  0% {
    transform: translateY(-10px) scale(1);
    opacity: 0;
  }
  20% {
    opacity: 0.5;
  }
  100% {
    transform: translateY(50px) scale(0.5);
    opacity: 0;
  }
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  position: relative;
  z-index: 1;
}

.icon-container {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-md);
  font-size: 2rem;
  flex-shrink: 0;
}

.temperature-icon {
  background: linear-gradient(
    135deg,
    var(--temp-primary) 0%,
    var(--temp-secondary) 100%
  );
  box-shadow: 0 8px 20px rgba(255, 107, 53, 0.4);
  color: #fff;
}

.humidity-icon {
  background: linear-gradient(
    135deg,
    var(--hum-primary) 0%,
    var(--hum-secondary) 100%
  );
  box-shadow: 0 8px 20px rgba(58, 123, 213, 0.4);
  color: #fff;
}

.header-info {
  flex: 1;
}

.header-info h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  letter-spacing: -0.5px;
}

.description {
  font-size: 1rem;
  color: #9ca3af;
  font-weight: 500;
}

/* Main Reading - Centered and Symmetrical */
.main-reading {
  margin-bottom: var(--spacing-lg);
  position: relative;
  z-index: 1;
  text-align: center;
}

.reading-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.reading-value {
  font-size: clamp(3.5rem, 8vw, 5.5rem);
  font-weight: 800;
  letter-spacing: -3px;
  line-height: 1;
  animation: valueUpdate var(--transition-slow) ease;
}

@keyframes valueUpdate {
  0% {
    transform: scale(1.05);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.reading-unit {
  font-size: 2.25rem;
  font-weight: 600;
  color: #9ca3af;
  align-self: flex-start;
  margin-top: 0.75rem;
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-size: 0.875rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.trend-badge.up {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  opacity: 1;
}

.trend-badge.down {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  opacity: 1;
}

.trend-badge.stable {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  opacity: 1;
}

/* Temperature Gauge */
.temperature-gauge {
  position: relative;
  margin-bottom: var(--spacing-lg);
  z-index: 1;
}

.gauge-fill {
  height: 14px;
  background: linear-gradient(90deg, #3b82f6 0%, #f59e0b 50%, #ef4444 100%);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.gauge-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: rgba(255, 255, 255, 0.3);
  transition: width 0.8s ease;
}

/* Humidity Wave */
.humidity-wave {
  position: relative;
  margin-bottom: var(--spacing-lg);
  height: 120px;
  z-index: 1;
}

.wave-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  overflow: hidden;
  transition: height 0.8s ease;
}

.wave-path {
  fill: url(#waveGradient);
}

svg {
  width: 100%;
  height: 100%;
}

.humidity-wave::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    180deg,
    rgba(58, 123, 213, 0.15) 0%,
    rgba(58, 123, 213, 0.35) 100%
  );
  border-radius: var(--border-radius-sm);
}

.wave-fill svg {
  position: relative;
  z-index: 1;
}

.wave-path {
  fill: rgba(58, 123, 213, 0.6);
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  margin: var(--spacing-sm) 12px 0 12px;
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 600;
}

/* Stats Grid - Symmetrical Layout */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
  position: relative;
  z-index: 1;
  margin-top: auto;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all var(--transition-normal);
}

.stat-item:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.stat-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.temperature-stat {
  background: rgba(255, 107, 53, 0.15);
  color: var(--temp-primary);
}

.humidity-stat {
  background: rgba(58, 123, 213, 0.15);
  color: var(--hum-primary);
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 0.9rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Combined Stats - Symmetrical Cards */
.combined-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-xl);
}

.combined-card {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-xl);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all var(--transition-normal);
}

.combined-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.3);
  background: rgba(255, 255, 255, 0.08);
}

.card-purple {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1) 0%,
    rgba(118, 75, 162, 0.05) 100%
  );
  border: 1px solid rgba(102, 126, 234, 0.3);
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.15);
}

.card-orange {
  background: linear-gradient(
    135deg,
    rgba(251, 146, 60, 0.1) 0%,
    rgba(249, 115, 22, 0.05) 100%
  );
  border: 1px solid rgba(251, 146, 60, 0.3);
  box-shadow: 0 8px 32px rgba(251, 146, 60, 0.15);
}

.combined-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-md);
  font-size: 1.75rem;
  color: #fff;
  flex-shrink: 0;
}

.card-purple .combined-icon {
  background: linear-gradient(
    135deg,
    var(--purple-primary) 0%,
    var(--purple-secondary) 100%
  );
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.card-orange .combined-icon {
  background: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
  box-shadow: 0 8px 20px rgba(251, 146, 60, 0.3);
}

.combined-info {
  flex: 1;
  min-width: 0;
}

.combined-label {
  font-size: 0.875rem;
  color: #9ca3af;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.combined-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

/* Footer */
footer {
  margin-top: auto;
  text-align: center;
  padding: var(--spacing-lg);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-content p {
  font-size: 1rem;
  color: #9ca3af;
  font-weight: 500;
}

.footer-content p:first-child {
  margin-bottom: var(--spacing-xs);
  color: #e5e7eb;
}

.footer-tag {
  font-size: 0.9rem !important;
  opacity: 0.7;
}

/* Loading State */
.loading {
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* Responsive Design - Enhanced */
@media (max-width: 1024px) {
  main {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
  }

  .combined-stats {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
  }
}

@media (max-width: 768px) {
  body {
    padding: var(--spacing-md);
    align-items: flex-start;
    padding-top: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
  }

  .theme-section {
    padding: var(--spacing-lg);
  }

  .reading-value {
    font-size: 3.5rem;
  }

  .reading-unit {
    font-size: 1.75rem;
  }

  h1 {
    font-size: 2.8rem;
  }

  .title-icon {
    font-size: 1.5rem;
  }

  .icon-container {
    width: 56px;
    height: 56px;
    font-size: 1.75rem;
  }

  .combined-icon {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }

  .combined-card {
    padding: var(--spacing-lg);
  }

  .combined-value {
    font-size: 1.5rem;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
  }

  .status-bar {
    flex-direction: column;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
  }
}

@media (max-width: 480px) {
  body {
    padding: 1rem;
  }

  .reading-value {
    font-size: 3rem;
    letter-spacing: -2px;
  }

  .reading-unit {
    font-size: 1.5rem;
  }

  .icon-container {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
  }

  .combined-icon {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 1.125rem;
  }

  .combined-value {
    font-size: 1.25rem;
  }

  h1 {
    font-size: 1.75rem;
    gap: var(--spacing-sm);
  }

  .title-icon {
    font-size: 1.25rem;
  }

  .theme-section {
    padding: var(--spacing-md);
  }

  .combined-card {
    padding: var(--spacing-md);
    gap: var(--spacing-md);
  }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .theme-section {
    border-width: 2px;
  }

  .stat-item,
  .combined-card {
    border-width: 2px;
  }
}
