/* RJ Weather - ACF Version with Desktop Centering and Enhanced Styling */
/* Version 0.952 - Ultra-compact view, mobile UX improvements, desktop optimizations */

/* Import brand fonts - Cubano and Roboto */
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;0,900;1,400&display=swap');
@import url('https://fonts.cdnfonts.com/css/cubano');

:root {
  --font-display: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --font-heading: 'Cubano', 'Roboto', Arial, sans-serif;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-border: #e5e7eb;
  --color-primary: #2563eb;
  --color-warning: #f59e0b;
}

.rjdev-weather-container {
  font-family: var(--font-display);
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--color-border);
  overflow: hidden;
  margin: 1rem 0;
}

/* Staleness Warning */
.weather-staleness-warning {
  background: rgba(245, 158, 11, 0.1);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--color-warning);
  text-align: center;
  padding: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Weather Content */
.rjdev-weather-content {
  padding: 0.75rem;
}

/* Weather Alert */
.weather-alert {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  color: #dc2626;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.alert-icon {
  font-size: 1.1rem;
}

/* Current Weather */
.current-weather-card {
  margin-bottom: 0.75rem;
  text-align: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

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

.current-temp {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.temp-value {
  font-family: var(--font-heading);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.temp-unit {
  font-size: 1.25rem;
  color: var(--color-text-light);
  font-weight: 500;
}

.current-location {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--color-text-light);
  margin-top: 0.25rem;
}

.current-info {
  text-align: right;
}

.weather-desc {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  justify-content: flex-end;
}

.weather-emoji {
  font-size: 1.25rem;
}

.feels-like {
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.current-details {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.detail-icon {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
}

.detail-value {
  color: var(--color-text);
}

/* Compact AQI dot for current weather details */
.aqi-dot-small {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* Tiny timestamp styling */
.weather-timestamp-tiny {
  text-align: center;
  font-size: 0.65rem;
  color: var(--color-text-light);
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(0,0,0,0.05);
  opacity: 0.7;
}

/* Forecast Header */
.forecast-header-row {
  display: flex;
  padding: 0.5rem 0;
  border-bottom: 2px solid var(--color-primary);
  font-weight: 700;
  color: var(--color-text);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.header-day { 
  flex: 1; 
  min-width: 80px;
}

.header-weather { 
  flex: 1; 
  text-align: center; 
  min-width: 60px;
}

.header-temps { 
  flex: 1; 
  text-align: center; 
  min-width: 90px;
}

.header-aqi { 
  flex: 1; 
  text-align: right; 
  min-width: 90px;
}

.forecast-grid {
  display: flex;
  flex-direction: column;
  position: relative;
}

.forecast-day {
  display: flex;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: background-color 0.2s;
  min-height: 45px;
}

.forecast-day:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.forecast-day.today {
  background-color: rgba(37, 99, 235, 0.05);
  font-weight: 600;
}

.day-header {
  flex: 1;
  min-width: 80px;
  text-align: left;
}

.day-name {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 2px 0;
}

.day-date {
  font-size: 0.8rem;
  color: var(--color-text-light);
  margin: 0;
}

.day-weather {
  flex: 1;
  text-align: center;
  min-width: 60px;
}

.weather-icon-large {
  font-size: 2rem;
}

.day-temps {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  font-weight: 700;
  min-width: 90px;
}

.temp-high {
  color: var(--color-text);
}

.temp-low {
  color: var(--color-text-light);
}

.day-aqi {
  flex: 1;
  text-align: right;
  min-width: 90px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
}

.aqi-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.aqi-text {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

/* Enhanced Weather Summary - Brand compliant */
.weather-summary {
  margin-top: 0.75rem;
  padding: 1rem;
  background: rgba(248, 250, 252, 0.8);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--color-text);
  text-align: center;
  line-height: 1.4;
}

.weather-summary.enhanced {
  background: rgba(248, 250, 252, 0.95);
  border: 2px solid rgba(37, 99, 235, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.summary-highlight {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  display: block;
  letter-spacing: 0.025em;
}

/* Ultra-Compact View (days=0) */
.forecast-ultra-compact {
  text-align: center;
}

.today-range-mobile {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.75rem;
  display: block;
}

.today-range-mobile .temp-high {
  color: var(--color-text);
  font-weight: 700;
}

.today-range-mobile .temp-low {
  color: var(--color-text-light);
  font-weight: 700;
}

/* Ultra-compact summary styling */
.weather-summary.ultra-compact-summary {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.75rem;
  font-size: 0.9rem;
}

.weather-summary.ultra-compact-summary .summary-highlight {
  font-size: 1rem;
}

/* Mobile-only timestamp for ultra-compact */
.weather-timestamp-tiny.mobile-only {
  display: block;
}

/* Today's Range in Current Weather (Ultra-compact desktop) */
.today-range-in-current {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 1rem 0 0.5rem 0;
  text-align: center;
  display: none; /* Hidden on mobile */
}

.today-range-in-current .temp-high {
  color: var(--color-text);
  font-weight: 700;
}

.today-range-in-current .temp-low {
  color: var(--color-text-light);
  font-weight: 700;
}

/* 1-Day Only View */
.forecast-today-only {
  text-align: center;
}

.today-details {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: rgba(37, 99, 235, 0.05);
  border-radius: 8px;
}

.today-range {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.today-label {
  color: var(--color-text-light);
  margin-right: 0.5rem;
}

.today-range .temp-high {
  color: var(--color-text);
  font-weight: 700;
}

.today-range .temp-low {
  color: var(--color-text-light);
  font-weight: 700;
}

/* AQI Legend */
.aqi-legend {
  margin-top: 0.75rem;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--color-text-light);
}

.legend-text {
  margin: 0;
}

.legend-text a {
  color: var(--color-primary);
  text-decoration: none;
}

.legend-text a:hover {
  text-decoration: underline;
}

.legend-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
}

.legend-color.good { background-color: #10b981; }
.legend-color.moderate { background-color: #f59e0b; }
.legend-color.unhealthy-sensitive { background-color: #f97316; }
.legend-color.unhealthy { background-color: #ef4444; }
.legend-color.very-unhealthy { background-color: #8b5cf6; }
.legend-color.hazardous { background-color: #7c2d12; }

/* Error States */
.rjdev-weather-error {
  text-align: center;
  padding: 2rem;
  color: #dc2626;
  background: rgba(239, 68, 68, 0.05);
  border-radius: 8px;
  margin: 1rem 0;
}

/* MOBILE RESPONSIVE - Enhanced for 5+ days visibility */
@media (max-width: 768px) {
  .rjdev-weather-content {
    padding: 0.5rem;
  }
  
  .temp-value {
    font-family: var(--font-heading);
    font-size: 2.5rem;
  }
  
  .current-details {
    gap: 0.75rem;
    justify-content: space-around;
  }
  
  .current-weather-card {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
  }
  
  /* Enhanced mobile forecast - shows 5 days for 5+ day forecasts */
  .forecast-grid {
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scroll-behavior: smooth !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 0 !important;
    padding-bottom: 0 !important;
    position: relative;
  }

  /* Mobile scroll indicator - centered in white space */
  .forecast-grid.has-mobile-scroll:after {
    content: '↓';
    position: absolute;
    bottom: 8px;
    left: 50%; /* CENTER horizontally */
    transform: translateX(-50%); /* Perfect centering */
    font-size: 1.2rem;
    color: var(--color-primary);
    background: rgba(255, 255, 255, 0.9); /* More opaque white background */
    padding: 4px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Subtle shadow for visibility */
    pointer-events: none;
    opacity: 0.8;
    z-index: 10; /* Ensure it's above other content */
  }
  
  /* Dynamic height based on number of days */
  .forecast-grid[data-days="1"],
  .forecast-grid[data-days="2"],
  .forecast-grid[data-days="3"],
  .forecast-grid[data-days="4"] {
    max-height: none !important; /* No scrolling for 4 or fewer days */
  }
  
  .forecast-grid[data-days="5"],
  .forecast-grid[data-days="6"],
  .forecast-grid[data-days="7"] {
    max-height: 170px !important; /* Show exactly 5 days (34px each) */
  }
  
  .forecast-grid[data-days="8"],
  .forecast-grid[data-days="9"],
  .forecast-grid[data-days="10"],
  .forecast-grid[data-days="11"],
  .forecast-grid[data-days="12"],
  .forecast-grid[data-days="13"],
  .forecast-grid[data-days="14"],
  .forecast-grid[data-days="15"],
  .forecast-grid[data-days="16"] {
    max-height: 170px !important; /* For longer forecasts */
  }
  
  .forecast-day {
    padding: 0.25rem 0 !important; /* Increased slightly for better visibility */
    min-height: 34px !important; /* Increased from 32px */
    flex: none !important;
    border-radius: 0 !important;
    border: none !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
  }
  
  .forecast-day.today {
    background-color: rgba(37, 99, 235, 0.05);
    border: none !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
  }
  
  .day-name {
    font-size: 0.85rem;
    margin-bottom: 1px;
  }
  
  .day-date {
    font-size: 0.7rem;
  }
  
  .weather-icon-large {
    font-size: 1.6rem;
  }
  
  .day-temps {
    font-size: 0.9rem;
    gap: 0.5rem;
  }
  
  .header-day, .day-header { 
    min-width: 55px; 
  }
  
  .header-weather, .day-weather { 
    min-width: 45px; 
  }
  
  .header-temps, .day-temps { 
    min-width: 65px; 
  }
  
  .header-aqi, .day-aqi { 
    min-width: 65px; 
  }
  
  .day-aqi {
    text-align: right;
    justify-content: flex-end;
  }
  
  .legend-text {
    font-size: 0.6rem;
  }
  
  .weather-summary {
    margin-top: 0.5rem;
    padding: 0.75rem;
    font-size: 0.9rem;
  }
  
  .summary-highlight {
    font-family: var(--font-heading);
    font-size: 1rem;
  }
  
  .aqi-legend {
    margin-top: 0.5rem;
    padding: 0.4rem;
  }
  
  .weather-timestamp-tiny {
    font-size: 0.6rem;
    margin-top: 0.5rem;
  }
  
  /* Hide AQI legend on mobile for ultra-compact view */
  .forecast-ultra-compact + .aqi-legend {
    display: none;
  }
}

/* Ultra-compact for very small screens */
@media (max-width: 480px) {
  .forecast-day {
    padding: 0.2rem 0 !important; /* Slightly more compact */
    min-height: 30px !important; /* Reduced for very small screens */
  }
  
  .forecast-grid[data-days="5"],
  .forecast-grid[data-days="6"],
  .forecast-grid[data-days="7"],
  .forecast-grid[data-days="8"],
  .forecast-grid[data-days="9"],
  .forecast-grid[data-days="10"],
  .forecast-grid[data-days="11"],
  .forecast-grid[data-days="12"],
  .forecast-grid[data-days="13"],
  .forecast-grid[data-days="14"],
  .forecast-grid[data-days="15"],
  .forecast-grid[data-days="16"] {
    max-height: 155px !important; /* Adjusted for very small screens */
  }
  
  .current-main {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }
  
  .current-info {
    text-align: center;
  }
  
  .weather-desc {
    justify-content: center;
  }
  
  .day-name {
    font-size: 0.8rem;
  }
  
  .day-date {
    font-size: 0.65rem;
  }
  
  .weather-icon-large {
    font-size: 1.4rem;
  }
  
  .day-temps {
    font-size: 0.85rem;
  }
  
  .header-day, .day-header { 
    min-width: 45px; 
  }
  
  .header-weather, .day-weather { 
    min-width: 35px; 
  }
  
  .header-temps, .day-temps { 
    min-width: 55px; 
  }
  
  .header-aqi, .day-aqi { 
    min-width: 55px; 
  }
  
  .current-details {
    gap: 0.5rem;
  }
  
  .detail-item {
    font-size: 0.8rem;
  }
}

/* Desktop Horizontal Layout - Proper Centering */
@media (min-width: 768px) {
  .forecast-header-row {
    display: none;
  }

  .forecast-grid {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    gap: 1rem;
    padding: 0.75rem; /* Reduced from 1rem */
    justify-content: flex-start; /* Changed from center to flex-start */
    align-items: stretch;
    
    /* Center the content properly */
    display: flex;
    margin: 0 auto;
    width: fit-content;
    max-width: 100%;
  }

  /* When there are fewer days, center them */
  .forecast-grid[data-days="1"],
  .forecast-grid[data-days="2"],
  .forecast-grid[data-days="3"],
  .forecast-grid[data-days="4"],
  .forecast-grid[data-days="5"] {
    justify-content: center;
    margin: 0 auto;
  }

  /* Enhanced desktop forecast day styling - Reduced height */
  .forecast-day {
    flex: 0 0 130px; /* Consistent width */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 0.5rem; /* Reduced from 1.25rem */
    border: 1px solid var(--color-border);
    border-radius: 12px;
    min-height: auto;
    background: rgba(255, 255, 255, 0.8);
    transition: all 0.2s ease;
  }

  .forecast-day:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: white;
  }

  .forecast-day.today {
    background-color: rgba(37, 99, 235, 0.08);
    border: 2px solid rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
  }

  .forecast-day.today:hover {
    background-color: rgba(37, 99, 235, 0.12);
    transform: translateY(-3px);
  }

  .day-header {
    margin-bottom: 0.5rem; /* Reduced from 0.75rem */
    text-align: center;
    width: 100%;
  }

  .day-name {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
  }

  .day-date {
    font-size: 0.8rem;
    color: var(--color-text-light);
  }

  .day-weather {
    margin-bottom: 0.5rem; /* Reduced from 0.75rem */
    text-align: center;
  }

  .weather-icon-large {
    font-size: 2.2rem; /* Reduced from 2.5rem */
  }

  .day-temps {
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem; /* Reduced from 0.5rem */
    text-align: center;
    font-size: 1rem;
  }

  .day-aqi {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
  }

  /* Enhanced scroll indicator for desktop */
  .forecast-grid.has-scroll::after {
    content: '→';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    color: var(--color-primary);
    padding: 0 0.5rem;
    background: linear-gradient(to left, white 50%, transparent);
    pointer-events: none;
  }

  /* Better container spacing for desktop */
  .rjdev-weather-content {
    padding: 1.5rem;
  }

  .current-weather-card {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
  }

  /* Enhanced font sizes for desktop consistency */
  .current-details {
    gap: 2rem;
  }

  .detail-item {
    font-size: 1rem; /* Increased from 0.9rem */
  }

  .detail-icon {
    font-size: 1.3rem; /* Increased from 1.1rem */
  }

  .current-location {
    font-size: 1rem; /* Increased from 0.9rem */
  }

  /* Desktop: Ultra-compact view positioning */
  .today-range-in-current {
    display: block; /* Show on desktop */
  }
  
  .forecast-ultra-compact .today-range-mobile {
    display: none; /* Hide mobile version on desktop */
  }
  
  /* Hide mobile-only timestamp on desktop */
  .weather-timestamp-tiny.mobile-only {
    display: none;
  }
  
  /* Ultra-compact summary on desktop */
  .weather-summary.ultra-compact-summary {
    margin-top: 1rem;
    padding: 1rem;
    font-size: 1rem;
  }
  
  .weather-summary.ultra-compact-summary .summary-highlight {
    font-size: 1.1rem;
  }
  
  /* Enhanced desktop 1-day view */
  .today-details {
    padding: 1.5rem;
    margin-top: 1rem;
  }

  .today-range {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin-bottom: 1rem;
  }

  .weather-summary {
    margin-top: 1.5rem;
    padding: 1.5rem;
    font-size: 1rem;
  }

  .summary-highlight {
    font-family: var(--font-heading);
    font-size: 1.25rem;
  }

  .weather-timestamp-tiny {
    font-size: 0.7rem;
    margin-top: 1rem;
  }

  /* Desktop: Combine AQI legend and timestamp on same line to save space */
  .aqi-legend {
    margin-top: 0.75rem;
    padding: 0.5rem;
    text-align: left; /* Changed from center */
    font-size: 0.7rem;
    color: var(--color-text-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
  }
  
  .legend-text {
    margin: 0;
    flex: 1;
  }
  
  /* Move timestamp inline on desktop */
  .weather-timestamp-tiny {
    display: inline-block;
    margin: 0;
    padding: 0;
    border: none;
    opacity: 0.8;
    font-size: 0.7rem; /* Match AQI legend font size */
    color: var(--color-text-light);
    white-space: nowrap;
  }
  
  /* Hide the standalone timestamp when AQI legend is present */
  .aqi-legend + .weather-timestamp-tiny {
    display: none;
  }
}

/* Mobile: Keep original timestamp styling when no AQI legend */
@media (max-width: 767px) {
  .weather-timestamp-tiny {
    text-align: center;
    font-size: 0.6rem;
    color: var(--color-text-light);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0,0,0,0.05);
    opacity: 0.7;
  }
}
