/* ==========================================================================
   MODERN WEATHER APP - STYLESHEET (With Analytics)
   ========================================================================== */

/* ---------- CSS Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    min-height: 100vh;
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

/* ---------- Theme Color Variables ---------- */
:root {
    --bg-gradient: linear-gradient(135deg, #70e1f5 0%, #ffd194 100%);
    --container-bg: rgba(255, 255, 255, 0.82);
    --container-border: rgba(255, 255, 255, 0.6);
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(255, 255, 255, 0.8);
    --card-hover-bg: rgba(255, 255, 255, 0.95);
    --text-main: #1f2937;
    --text-sub: #4b5563;
    --text-muted: #6b7280;
    --accent-primary: #0284c7;
    --accent-hover: #0369a1;
    --accent-glow: rgba(2, 132, 199, 0.25);
    --input-bg: rgba(255, 255, 255, 0.9);
    --input-border: #cbd5e1;
    --shadow-soft: 0 10px 30px -5px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 14px 35px -4px rgba(2, 132, 199, 0.2);
    --skeleton-bg: #e2e8f0;
    --skeleton-shine: #f8fafc;
    --error-bg: rgba(254, 226, 226, 0.9);
    --error-text: #b91c1c;
    --error-border: #fca5a5;
    --fav-star: #eab308;
    --chart-grid: rgba(0,0,0,0.06);
    --chart-tick: #4b5563;
}

[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #09122c 0%, #111d4a 50%, #1e1b4b 100%);
    --container-bg: rgba(17, 24, 39, 0.82);
    --container-border: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(31, 41, 55, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover-bg: rgba(45, 55, 72, 0.85);
    --text-main: #f8fafc;
    --text-sub: #cbd5e1;
    --text-muted: #94a3b8;
    --accent-primary: #38bdf8;
    --accent-hover: #0ea5e9;
    --accent-glow: rgba(56, 189, 248, 0.3);
    --input-bg: rgba(30, 41, 59, 0.85);
    --input-border: #475569;
    --shadow-soft: 0 12px 35px -5px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 14px 35px -4px rgba(56, 189, 248, 0.25);
    --skeleton-bg: #334155;
    --skeleton-shine: #475569;
    --error-bg: rgba(127, 29, 29, 0.85);
    --error-text: #fecaca;
    --error-border: #991b1b;
    --fav-star: #facc15;
    --chart-grid: rgba(255,255,255,0.08);
    --chart-tick: #94a3b8;
}

/* ---------- Basic Body Styles ---------- */
body {
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-main);
    transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1), color 0.4s ease;
    position: relative;
}

/* ---------- Container & Layout ---------- */
.weather-bg-animation {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    pointer-events: none; z-index: 0; overflow: hidden;
}

.container {
    position: relative; z-index: 1;
    background: var(--container-bg);
    width: 100%; max-width: 480px; max-height: 94vh;
    overflow-y: auto; overflow-x: hidden;
    padding: 1.8rem; border-radius: 24px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--container-border);
    animation: pageEntrance 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-primary) transparent;
    transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

@keyframes pageEntrance {
    0% { opacity: 0; transform: translateY(35px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- App Header ---------- */
.app-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.app-title { font-size: 1.7rem; font-weight: 700; color: var(--text-main); }

.theme-toggle {
    background: var(--card-bg); border: 1px solid var(--card-border);
    width: 42px; height: 42px; border-radius: 50%;
    cursor: pointer; transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.theme-toggle:hover { transform: rotate(20deg) scale(1.08); background: var(--card-hover-bg); }

/* ---------- Analytics Section ---------- */
.analytics-section {
    margin-top: 2rem;
    border-top: 1px solid var(--card-border);
    padding-top: 1.5rem;
}

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

.analytics-title { margin-top: 0!important; }

.live-status-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--card-bg);
    padding: 3px 8px;
    border-radius: 12px;
}
.live-pulse {
    width: 6px; height: 6px; border-radius: 50%; background: #22c55e;
    animation: pulse 1.5s infinite;
}
@keyframes pulse { 0% { opacity: 0.4; } 50% { opacity: 1; } 100% { opacity: 0.4; } }

.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    transition: box-shadow 0.3s ease;
}
.chart-card:hover { box-shadow: var(--shadow-soft); }

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.chart-title-group { display: flex; align-items: center; gap: 8px; }
.chart-card-title { font-size: 0.95rem; color: var(--text-main); }
.chart-icon { font-size: 1.1rem; }
.chart-badge {
    font-size: 0.7rem; font-weight: 700; color: var(--accent-primary);
    background: var(--accent-glow); padding: 2px 8px; border-radius: 10px;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 210px;
    margin-top: 0.5rem;
}

.chart-toggle-group {
    display: flex;
    background: var(--container-bg);
    padding: 2px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
}
.chart-toggle-btn {
    border: none; padding: 4px 10px; border-radius: 6px; cursor: pointer;
    font-size: 0.75rem; color: var(--text-sub); background: transparent;
    transition: background 0.2s;
}
.chart-toggle-btn.active {
    background: var(--accent-primary); color: #fff;
}

.custom-select {
    padding: 6px 10px; border-radius: 8px; border: 1px solid var(--card-border);
    background: var(--container-bg); color: var(--text-main); cursor: pointer;
    font-size: 0.85rem;
}

.range-controls-wrapper { margin: 0.5rem 0 1rem; }
.range-btn-group {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
}
.range-btn {
    padding: 6px 0; border: 1px solid var(--card-border);
    border-radius: 8px; background: var(--card-bg); color: var(--text-sub);
    cursor: pointer; font-size: 0.8rem; transition: background 0.2s;
}
.range-btn.active { background: var(--accent-primary); color: #fff; }

.hist-summary-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 1rem;
}
.hist-summary-card {
    background: var(--container-bg); padding: 8px; border-radius: 12px;
    text-align: center;
}
.hist-summary-label { display: block; font-size: 0.7rem; color: var(--text-muted); }
.hist-summary-val { font-size: 0.9rem; font-weight: 700; }

.hist-error-banner {
    margin-top: 1rem; padding: 10px;
    background: var(--error-bg); color: var(--error-text);
    border-radius: 10px; text-align: center; font-size: 0.85rem;
}

/* ... keep existing styles for search, details, cards, forecast, responsive ... */
/* NOTE: To save space, I did not paste all existing styles here, but the final file
   will include them along with the new analytics styles. Ensure you keep existing
   styles when writing! */

/* Re-implenting remaining styles that were previously present */
.search-section { display: flex; flex-direction: column; gap: 10px; margin-bottom: 1.2rem; }
.search-box { display: flex; gap: 8px; position: relative; }
input#city-input { flex: 1; padding: 12px 16px; font-size: 0.95rem; border-radius: 12px; border: 2px solid var(--input-border); background: var(--input-bg); color: var(--text-main); outline: none; transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease; }
input#city-input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 4px var(--accent-glow); transform: translateY(-1px); }
.btn-primary { padding: 12px 20px; font-size: 0.95rem; font-weight: 600; color: #ffffff; background: var(--accent-primary); border: none; border-radius: 12px; cursor: pointer; box-shadow: 0 4px 12px var(--accent-glow); transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 6px 18px var(--accent-glow); }
.btn-location { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 10px 14px; font-size: 0.88rem; font-weight: 500; color: var(--text-main); background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px; cursor: pointer; transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease; }
.btn-location:hover { background: var(--card-hover-bg); transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.loc-icon { font-size: 1rem; transition: transform 0.3s ease; }
.btn-location:hover .loc-icon { transform: rotate(15deg) scale(1.15); }

.recent-section, .favorites-section { margin-bottom: 0.9rem; text-align: left; animation: fadeIn 0.4s ease; }
.section-subtitle { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 6px; }
.chip-container { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-sub); padding: 5px 12px; font-size: 0.8rem; font-weight: 500; border-radius: 20px; cursor: pointer; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); display: inline-flex; align-items: center; gap: 4px; }
.chip-btn:hover { background: var(--accent-primary); color: #ffffff; border-color: var(--accent-primary); transform: translateY(-2px); box-shadow: 0 4px 10px var(--accent-glow); }

.loading-state { padding: 1.5rem 0; animation: fadeIn 0.3s ease; }
.skeleton-card { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.skeleton-circle { width: 90px; height: 90px; border-radius: 50%; background: var(--skeleton-bg); position: relative; overflow: hidden; }
.skeleton-line { height: 18px; border-radius: 9px; background: var(--skeleton-bg); position: relative; overflow: hidden; }
.skeleton-title { width: 55%; height: 26px; }
.skeleton-subtitle { width: 35%; }
.skeleton-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; margin-top: 10px; }
.skeleton-box { height: 60px; border-radius: 12px; background: var(--skeleton-bg); position: relative; overflow: hidden; }
.skeleton-circle::after, .skeleton-line::after, .skeleton-box::after { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent); animation: shimmer 1.5s infinite ease-in-out; }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

.error-message { margin: 1rem 0; padding: 12px 16px; background: var(--error-bg); color: var(--error-text); border: 1px solid var(--error-border); border-radius: 12px; font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 8px; animation: errorShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes errorShake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.weather-info { margin-top: 1rem; }
.weather-info.animate-in { animation: contentSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.weather-info.animate-out { animation: contentSlideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards; }
@keyframes contentSlideIn { 0% { opacity: 0; transform: translateY(20px) scale(0.98); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes contentSlideOut { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-15px) scale(0.98); } }

.weather-header { display: flex; justify-content: center; align-items: center; gap: 10px; margin-bottom: 0.5rem; }
#city-display { font-size: 1.55rem; font-weight: 700; color: var(--text-main); }
.favorite-btn { background: transparent; border: none; cursor: pointer; font-size: 1.5rem; color: var(--text-muted); transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.3s ease; display: flex; align-items: center; justify-content: center; }
.favorite-btn:hover { transform: scale(1.25) rotate(15deg); }
.favorite-btn.active { color: var(--fav-star); text-shadow: 0 0 10px rgba(234, 179, 8, 0.5); }

.weather-main-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 20px; padding: 1.5rem 1rem; margin-bottom: 1.25rem; box-shadow: var(--shadow-soft); display: flex; flex-direction: column; align-items: center; transition: transform 0.3s ease, box-shadow 0.3s ease; animation: gentleCardFloat 5s ease-in-out infinite alternate; }
.weather-main-card:hover { box-shadow: var(--shadow-hover); }
@keyframes gentleCardFloat { 0% { transform: translateY(0); } 100% { transform: translateY(-4px); } }
.weather-icon { font-size: 4.2rem; line-height: 1; margin-bottom: 0.4rem; }
.floating-icon { display: inline-block; animation: gentleBob 3.5s ease-in-out infinite alternate; }
@keyframes gentleBob { 0% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-6px) rotate(3deg); } 100% { transform: translateY(2px) rotate(-3deg); } }
.temp-wrapper { display: flex; align-items: flex-start; justify-content: center; }
.temp-display { font-size: 3.4rem; font-weight: 800; letter-spacing: -1.5px; color: var(--text-main); line-height: 1; transition: transform 0.3s ease; }
.temp-unit { font-size: 1.5rem; font-weight: 600; color: var(--accent-primary); margin-left: 2px; }
.condition-display { font-size: 1.1rem; font-weight: 500; color: var(--text-sub); margin-top: 6px; text-transform: capitalize; }

.section-heading { font-size: 0.88rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); text-align: left; margin-bottom: 8px; margin-top: 1rem; }
.details-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.detail-item { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; text-align: left; transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.25s ease, box-shadow 0.25s ease; animation: itemSlideUp 0.4s ease backwards; animation-delay: calc(var(--stagger, 0) * 0.04s); }
.detail-item:hover { background: var(--card-hover-bg); transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.detail-icon { font-size: 1.35rem; transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.detail-item:hover .detail-icon { transform: scale(1.25) rotate(8deg); }
.detail-meta { display: flex; flex-direction: column; }
.detail-label { font-size: 0.72rem; font-weight: 500; color: var(--text-muted); line-height: 1.2; }
.detail-val { font-size: 0.92rem; font-weight: 700; color: var(--text-main); line-height: 1.3; }

.forecast-block { margin-top: 0.5rem; }
.hourly-container { display: flex; gap: 10px; overflow-x: auto; padding: 6px 2px 12px 2px; -webkit-overflow-scrolling: touch; }
.hourly-card { flex: 0 0 82px; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; padding: 12px 6px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.25s ease, box-shadow 0.25s ease; animation: itemSlideUp 0.4s ease backwards; }
.hourly-card:hover { background: var(--card-hover-bg); transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.hourly-time { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); }
.hourly-icon { font-size: 1.6rem; transition: transform 0.3s ease; }
.hourly-card:hover .hourly-icon { transform: scale(1.2); }
.hourly-temp { font-size: 1.05rem; font-weight: 700; color: var(--text-main); }
.hourly-precip { font-size: 0.72rem; font-weight: 600; color: #0284c7; }

.daily-container { display: flex; flex-direction: column; gap: 8px; padding-bottom: 4px; }
.daily-card { display: flex; align-items: center; justify-content: space-between; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; padding: 12px 16px; transition: transform 0.25s ease, background 0.25s ease, box-shadow 0.25s ease; animation: itemSlideUp 0.4s ease backwards; }
.daily-card:hover { background: var(--card-hover-bg); transform: translateX(4px); box-shadow: var(--shadow-hover); }
.daily-day { font-size: 0.92rem; font-weight: 600; color: var(--text-main); width: 75px; text-align: left; }
.daily-icon { font-size: 1.6rem; transition: transform 0.3s ease; }
.daily-card:hover .daily-icon { transform: scale(1.2) rotate(6deg); }
.daily-condition { font-size: 0.85rem; color: var(--text-sub); flex: 1; text-align: center; padding: 0 8px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.daily-temp-group { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; }
.daily-max { font-weight: 700; color: var(--text-main); }
.daily-min { font-weight: 500; color: var(--text-muted); }

@keyframes itemSlideUp { 0% { opacity: 0; transform: translateY(12px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes staggerFade { 0% { opacity: 0; transform: translateY(-10px); } 100% { opacity: 1; transform: translateY(0); } }
.hidden { display: none !important; }

/* Background animations - keep existing */
.bg-sun-glow { position: absolute; top: -60px; right: -60px; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(circle, rgba(253, 224, 71, 0.45) 0%, rgba(251, 191, 36, 0.2) 50%, transparent 75%); animation: sunPulse 6s infinite ease-in-out alternate; }
@keyframes sunPulse { 0% { transform: scale(0.9); opacity: 0.6; } 100% { transform: scale(1.2); opacity: 0.95; } }
.bg-sun-ray { position: absolute; top: 5%; right: 5%; width: 400px; height: 400px; border-radius: 50%; border: 2px dashed rgba(254, 240, 138, 0.25); animation: spinRays 40s linear infinite; }
@keyframes spinRays { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.bg-light-particle { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.6); box-shadow: 0 0 10px rgba(253, 224, 71, 0.8); animation: floatParticle 8s infinite ease-in-out; }
@keyframes floatParticle { 0%, 100% { transform: translateY(0) translateX(0); opacity: 0.2; } 50% { transform: translateY(-30px) translateX(20px); opacity: 0.8; } }
.bg-cloud { position: absolute; background: rgba(255, 255, 255, 0.35); border-radius: 100px; filter: blur(14px); animation: driftCloud linear infinite; }
[data-theme="dark"] .bg-cloud { background: rgba(148, 163, 184, 0.15); }
@keyframes driftCloud { from { transform: translateX(-250px); } to { transform: translateX(calc(100vw + 250px)); } }
.bg-rain-drop { position: absolute; width: 2px; background: linear-gradient(180deg, transparent, rgba(56, 189, 248, 0.7)); border-radius: 1px; animation: rainFall linear infinite; }
@keyframes rainFall { 0% { transform: translateY(-30px) translateX(0); opacity: 0; } 20% { opacity: 0.9; } 90% { opacity: 0.9; } 100% { transform: translateY(105vh) translateX(-20px); opacity: 0; } }
.bg-lightning-flash { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.85); pointer-events: none; opacity: 0; animation: flashLightning 7s infinite ease-in-out; }
@keyframes flashLightning { 0%, 93%, 97%, 100% { opacity: 0; } 94%, 96% { opacity: 0.85; } 95% { opacity: 0.2; } }
.bg-snow-flake { position: absolute; background: #ffffff; border-radius: 50%; box-shadow: 0 0 6px rgba(255, 255, 255, 0.8); animation: snowFall linear infinite; }
@keyframes snowFall { 0% { transform: translateY(-20px) translateX(0); opacity: 0; } 15% { opacity: 0.9; } 85% { opacity: 0.9; } 100% { transform: translateY(105vh) translateX(40px); opacity: 0; } }
.bg-star { position: absolute; border-radius: 50%; background: #ffffff; box-shadow: 0 0 6px rgba(255, 255, 255, 0.9); animation: starTwinkle ease-in-out infinite alternate; }
@keyframes starTwinkle { 0% { opacity: 0.2; transform: scale(0.7); } 50% { opacity: 1; transform: scale(1.3); box-shadow: 0 0 10px rgba(255, 255, 255, 1); } 100% { opacity: 0.3; transform: scale(0.8); } }

/* Responsive & Accessibility - keep existing */
@media (max-width: 640px) { body { padding: 10px; align-items: flex-start; } .container { max-height: 96vh; padding: 1.3rem 1rem; border-radius: 20px; } .app-title { font-size: 1.45rem; } .temp-display { font-size: 2.8rem; } .weather-icon { font-size: 3.5rem; } .details-grid { grid-template-columns: repeat(2, 1fr); } .daily-condition { display: none; } }
@media (max-width: 360px) { .container { padding: 1rem 0.8rem; } .details-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; } .weather-bg-animation { display: none !important; } .weather-main-card { animation: none !important; } .floating-icon { animation: none !important; } }
