/* =========================================
   1. VARIABLES & THEME CONFIG
========================================= */
:root {
  --bg-color: #f3f4f6;
  --nav-bg: rgba(255, 255, 255, 0.9);
  --card-bg: #ffffff;
  --featured-card-bg: #ffffff;
  
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  
  --accent-safe: #059669;
  --accent-warning: #d97706;
  --accent-danger: #dc2626;  
  
  --glow-safe: none;
  --glow-warning: none;
  --glow-danger: 0 0 0 4px rgba(220, 38, 38, 0.2);

  --dynamic-color: var(--accent-safe);

  --font-heading: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
}

body.dark-mode {
  --bg-color: #09090b;
  --nav-bg: rgba(9, 9, 11, 0.8);
  --card-bg: rgba(24, 24, 27, 0.6);
  --featured-card-bg: rgba(24, 24, 27, 0.8);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --border-color: rgba(255, 255, 255, 0.08);
  
  --shadow-card: none;

  --accent-safe: #a7f3d0;  
  --accent-warning: #fde68a;
  --accent-danger: #fca5a5;

  --glow-safe: 0 0 20px rgba(16, 185, 129, 0.15);
  --glow-warning: 0 0 25px rgba(245, 158, 11, 0.2);
  --glow-danger: 0 0 35px rgba(239, 68, 68, 0.3);
}

/* =========================================
   2. GLOBAL RESET & LAYOUT
========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; transition: all 0.3s ease; }

body { 
  background-color: var(--bg-color); 
  color: var(--text-primary); 
  font-family: var(--font-body); 
  min-height: 100vh;
  overflow-x: hidden;
}

.app-wrapper { display: flex; flex-direction: column; min-height: 100vh; }

/* =========================================
   3. NAVBAR
========================================= */
.navbar { 
  height: 70px; 
  padding: 0 2rem; 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  background: var(--nav-bg); 
  backdrop-filter: blur(16px); 
  border-bottom: 1px solid var(--border-color); 
  position: sticky; 
  top: 0; 
  z-index: 100; 
}

.brand-logo { font-family: var(--font-heading); font-weight: 700; font-size: 1.5rem; letter-spacing: 1px; }
.dot { color: var(--accent-safe); }

.nav-right { display: flex; align-items: center; gap: 1.5rem; }
.date-display { font-family: var(--font-heading); font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; }
.divider-vertical { width: 1px; height: 24px; background: var(--border-color); }

.icon-btn { background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 8px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background-color: var(--border-color); }
.profile-avatar { font-size: 0.75rem; font-weight: 600; padding: 6px 14px; border: 1px solid var(--border-color); border-radius: 20px; color: var(--text-secondary); }

/* =========================================
   4. DASHBOARD & HEADER (NEW LUXURY HUD)
========================================= */
.dashboard { flex: 1; padding: 2.5rem 2rem; max-width: 1400px; margin: 0 auto; width: 100%; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center; 
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
  gap: 1.5rem;
  position: relative;
}

.page-title { font-family: var(--font-heading); font-size: 2.5rem; font-weight: 300; line-height: 1.1; }
.page-subtitle { color: var(--text-secondary); margin-top: 0.5rem; font-size: 0.95rem; }

/* --- WEATHER HUD STYLES START --- */
.weather-hud-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end; 
  justify-content: center;
  margin-left: auto; 
  margin-right: 2rem; 
  padding-right: 2rem;
  border-right: 1px solid var(--border-color);
}

.weather-location {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.loc-icon { width: 14px; height: 14px; color: var(--accent-safe); }

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

.metric-main { display: flex; align-items: center; gap: 10px; }

.temp-big {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 300;
  color: var(--text-primary);
  line-height: 1;
}

.weather-icon-hud { width: 32px; height: 32px; stroke-width: 1.5; color: var(--text-primary); }

.metric-divider { width: 1px; height: 30px; background: var(--border-color); opacity: 0.5; }

.metric-details { display: flex; flex-direction: column; justify-content: center; gap: 2px; text-align: left; }

.condition-text { font-size: 0.9rem; font-weight: 500; color: var(--text-primary); }

.meta-row { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--text-secondary); }
.tiny-icon { width: 12px; height: 12px; opacity: 0.7; }
/* --- WEATHER HUD STYLES END --- */

.status-badge { 
  display: flex; align-items: center; gap: 0.8rem; 
  padding: 8px 20px; 
  border: 1px solid var(--border-color); 
  border-radius: 50px; 
  font-size: 0.8rem; font-weight: 600; letter-spacing: 1px; 
  white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background-color: var(--accent-safe); box-shadow: var(--glow-safe); }

/* =========================================
   5. SENSOR GRID & CARDS
========================================= */
.main-layout { display: flex; flex-direction: column; gap: 1.5rem; }
.sensor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }

.card { 
  background: var(--card-bg); 
  border: 1px solid var(--border-color); 
  padding: 1.5rem; border-radius: 16px; 
  display: flex; flex-direction: column; 
  box-shadow: var(--shadow-card); position: relative; 
  backdrop-filter: blur(10px); 
}
.card-header { display: flex; justify-content: space-between; align-items: center; color: var(--text-secondary); font-size: 0.8rem; letter-spacing: 1px; margin-bottom: 1rem; }
.card-title-group { display: flex; align-items: center; gap: 0.5rem; }
.card-body { flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 120px; }
.value { font-family: var(--font-heading); font-size: 2.5rem; font-weight: 500; }
.unit { margin-left: 0.5rem; color: var(--text-secondary); font-size: 1rem; }
.card-footer { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border-color); font-size: 0.75rem; color: var(--text-secondary); }

/* Featured / Advice Card */
.featured-card { background: var(--featured-card-bg); overflow: hidden; padding: 0; min-height: auto; }
.card-bg-grid, .card-scan-line { position: absolute; inset: 0; pointer-events: none; }
.card-bg-grid { background-image: linear-gradient(var(--border-color) 1px, transparent 1px), linear-gradient(90deg, var(--border-color) 1px, transparent 1px); background-size: 40px 40px; opacity: 0.1; }
.card-scan-line { width: 2px; background: linear-gradient(to bottom, transparent, var(--dynamic-color), transparent); box-shadow: 0 0 15px var(--dynamic-color); opacity: 0.5; animation: scan-animation 6s linear infinite; }
@keyframes scan-animation { 0% { left: -10%; } 100% { left: 110%; } }

.protocol-content { 
  position: relative; z-index: 2; 
  display: flex; width: 100%; padding: 2rem; 
  gap: 2rem; align-items: center; 
}

.status-indicator-group { 
  display: flex; align-items: center; gap: 1.5rem; 
  margin-right: 1rem; border-right: 1px solid var(--border-color); 
  padding-right: 2rem; 
  flex-shrink: 0;
}
.icon-container { padding: 12px; border-radius: 50%; border: 1px solid var(--dynamic-color); color: var(--dynamic-color); box-shadow: 0 0 20px rgba(0,0,0,0.1); }
.icon-large { width: 28px; height: 28px; stroke-width: 1.5; }

.advice-title { font-family: var(--font-heading); font-size: 0.75rem; letter-spacing: 2px; color: var(--text-secondary); margin-bottom: 4px; }
#advice-status-heading { font-family: var(--font-heading); font-size: 2rem; font-weight: 700; color: var(--dynamic-color); line-height: 1; }
.advice-text { font-size: 1rem; color: var(--text-primary); opacity: 0.9; line-height: 1.5; }

/* Visual Elements in Cards */
.visual-bar-container { width: 100%; height: 6px; background: var(--border-color); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.visual-bar { height: 100%; width: 0%; background: var(--text-primary); }
.circular-progress { width: 100px; height: 100px; border-radius: 50%; align-self: center; display: flex; align-items: center; justify-content: center; background: var(--border-color); }
.inner-circle { width: 90px; height: 90px; background: var(--bg-color); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.center-content { align-items: center; text-align: center; }
.weather-icon-box { margin-bottom: 0.5rem; transform: scale(1.3); color: var(--text-primary); }

/* Chart Area */
.chart-card { min-height: 400px; }
.chart-wrapper { position: relative; width: 100%; height: 300px; padding: 5px; }
.chart-legend-custom { display: flex; gap: 10px; font-size: 0.75rem; color: var(--text-secondary); }
.legend-item { display: flex; align-items: center; gap: 5px; }
.dot-l { width: 8px; height: 8px; border-radius: 50%; }
.water-l { background: #06b6d4; } .soil-l { background: #10b981; } .rain-l { background: #a855f7; }

/* =========================================
   6. ANIMATIONS & EFFECTS
========================================= */
.pulse-effect { animation: pulse-safe 2s infinite; }
.danger-active { animation: flash-border 2s infinite; }
@keyframes flash-border { 0%, 100% { border-color: var(--accent-danger); } 50% { border-color: transparent; } }
@keyframes pulse-safe { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); } 70% { box-shadow: 0 0 0 15px transparent; } }
@keyframes pulse-warning { 0% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.4); } 70% { box-shadow: 0 0 0 15px transparent; } }
@keyframes pulse-danger { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); } 70% { box-shadow: 0 0 0 20px transparent; } }

/* =========================================
   7. FOOTER
========================================= */
.footer { padding: 1.5rem; border-top: 1px solid var(--border-color); margin-top: auto; background: var(--bg-color); }
.footer-content { max-width: 1400px; margin: 0 auto; display: flex; justify-content: space-between; color: var(--text-secondary); font-size: 0.8rem; }

/* =========================================
   8. RESPONSIVE MEDIA QUERIES
========================================= */
@media (max-width: 900px) {
  /* Header Adjustments */
  .page-header { flex-direction: column; align-items: flex-start; gap: 1.5rem; }
  
  .weather-hud-container {
    margin-left: 0;
    margin-right: 0;
    align-items: flex-start; /* Align left on Mobile */
    border-right: none;
    border-left: 2px solid var(--accent-safe); /* Change divider to left */
    padding-right: 0;
    padding-left: 1.5rem;
    width: 100%;
  }

  .status-badge { width: auto; align-self: flex-start; }
}

@media (max-width: 768px) {
  .navbar { padding: 0 1rem; height: 60px; }
  .brand-logo { font-size: 1.2rem; }
  .date-display { display: none; } 
  .divider-vertical.desktop-only { display: none; }
  .nav-right { gap: 0.8rem; }
  
  .dashboard { padding: 1.5rem 1rem; }
  
  .protocol-content { flex-direction: column; padding: 1.5rem; gap: 1rem; text-align: center; }
  .status-indicator-group { 
    flex-direction: column; align-items: center; 
    border-right: none; padding-right: 0; margin-right: 0; 
    border-bottom: 1px solid var(--border-color); padding-bottom: 1.5rem; 
    width: 100%; gap: 1rem;
  }
  .icon-container { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; }
  .status-text-wrapper { text-align: center; }
  .advice-text { font-size: 0.95rem; text-align: center; }
  
  .sensor-grid { grid-template-columns: 1fr; gap: 1rem; }
  .chart-card { min-height: auto; }
  .chart-wrapper { height: 250px; }
}

/* =========================================
   9. LUXURY SPLASH SCREEN
========================================= */
.splash-screen {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: #09090b; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 1s ease-in-out, visibility 1s ease-in-out;
}
.splash-screen.hidden { opacity: 0; visibility: hidden; }
.splash-content { text-align: center; animation: fadeUp 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.splash-logo { font-family: 'Space Grotesk', sans-serif; font-size: 4rem; font-weight: 700; color: #f3f4f6; letter-spacing: 2px; margin-bottom: 1rem; }
.splash-dot { color: #059669; text-shadow: 0 0 20px rgba(5, 150, 105, 0.5); }
.splash-line { width: 0; height: 2px; background: linear-gradient(90deg, transparent, #059669, transparent); margin: 0 auto 1.5rem auto; animation: lineExpand 1.5s ease-out forwards 0.5s; }
.splash-text { font-family: 'Inter', sans-serif; font-size: 0.8rem; letter-spacing: 6px; color: #6b7280; text-transform: uppercase; opacity: 0; animation: fadeIn 1s ease-out forwards 1s; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes lineExpand { to { width: 100px; } }
@keyframes fadeIn { to { opacity: 1; } }