/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --accent: #a78bfa;
    --accent-glow: rgba(96, 165, 250, 0.18);
    --accent-gradient: linear-gradient(135deg, #60a5fa, #a78bfa);
    --bg: #0a0e17;
    --bg-card: rgba(17, 24, 39, 0.75);
    --text: #e2e8f0;
    --text-light: #94a3b8;
    --card-bg: rgba(17, 24, 39, 0.75);
    --card-border: rgba(255, 255, 255, 0.06);
    --detail-bg: rgba(96, 165, 250, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);
    --radius: 20px;
    --radius-sm: 12px;
    --transition: 0.35s cubic-bezier(.4,0,.2,1);
    --dot-color: rgba(255, 255, 255, 0.03);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-x: hidden;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(96, 165, 250, 0.1), transparent),
        radial-gradient(ellipse 60% 40% at 80% 60%, rgba(167, 139, 250, 0.07), transparent),
        radial-gradient(circle, var(--dot-color) 1px, transparent 1px) 0 0 / 24px 24px,
        var(--bg);
    color: var(--text);
    transition: background 0.8s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Dynamic Weather Backgrounds (dark-tinted) ===== */
body.clear        { background: radial-gradient(ellipse at 50% 0%, rgba(96, 165, 250, 0.15), transparent 60%), radial-gradient(circle, var(--dot-color) 1px, transparent 1px) 0 0 / 24px 24px, #0a0e17; }
body.clouds       { background: radial-gradient(ellipse at 50% 0%, rgba(148, 163, 184, 0.12), transparent 60%), radial-gradient(circle, var(--dot-color) 1px, transparent 1px) 0 0 / 24px 24px, #0a0e17; }
body.rain,
body.drizzle      { background: radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, 0.15), transparent 60%), radial-gradient(circle, var(--dot-color) 1px, transparent 1px) 0 0 / 24px 24px, #060a14; }
body.thunderstorm { background: radial-gradient(ellipse at 50% 0%, rgba(139, 92, 246, 0.12), transparent 60%), radial-gradient(circle, var(--dot-color) 1px, transparent 1px) 0 0 / 24px 24px, #050810; }
body.snow         { background: radial-gradient(ellipse at 50% 0%, rgba(226, 232, 240, 0.1), transparent 60%), radial-gradient(circle, var(--dot-color) 1px, transparent 1px) 0 0 / 24px 24px, #0c1220; }
body.mist,
body.fog,
body.haze         { background: radial-gradient(ellipse at 50% 0%, rgba(148, 163, 184, 0.1), transparent 60%), radial-gradient(circle, var(--dot-color) 1px, transparent 1px) 0 0 / 24px 24px, #0a0e17; }

/* ===== Floating Particles ===== */
.bg-particles {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.bg-particles span {
    position: absolute;
    display: block;
    width: 20px;
    height: 20px;
    background: rgba(96, 165, 250, 0.06);
    border-radius: 50%;
    animation: particleFloat linear infinite;
}

.bg-particles span:nth-child(1)  { left: 10%; width: 22px; height: 22px; animation-duration: 18s; animation-delay: 0s; }
.bg-particles span:nth-child(2)  { left: 25%; width: 14px; height: 14px; animation-duration: 22s; animation-delay: 2s; }
.bg-particles span:nth-child(3)  { left: 40%; width: 18px; height: 18px; animation-duration: 20s; animation-delay: 4s; }
.bg-particles span:nth-child(4)  { left: 55%; width: 26px; height: 26px; animation-duration: 25s; animation-delay: 1s; }
.bg-particles span:nth-child(5)  { left: 70%; width: 12px; height: 12px; animation-duration: 19s; animation-delay: 3s; }
.bg-particles span:nth-child(6)  { left: 82%; width: 30px; height: 30px; animation-duration: 24s; animation-delay: 0s; }
.bg-particles span:nth-child(7)  { left: 15%; width: 16px; height: 16px; animation-duration: 21s; animation-delay: 5s; }
.bg-particles span:nth-child(8)  { left: 50%; width: 20px; height: 20px; animation-duration: 17s; animation-delay: 2s; }
.bg-particles span:nth-child(9)  { left: 65%; width: 10px; height: 10px; animation-duration: 23s; animation-delay: 6s; }
.bg-particles span:nth-child(10) { left: 90%; width: 24px; height: 24px; animation-duration: 20s; animation-delay: 1s; }

@keyframes particleFloat {
    0%   { transform: translateY(100vh) rotate(0deg);   opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { transform: translateY(-100vh) rotate(720deg); opacity: 0; }
}

/* ===== Container & Screens ===== */
.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.screen {
    display: none;
    animation: screenIn 0.5s ease both;
}
.screen.active {
    display: block;
}

@keyframes screenIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Glass Card ===== */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

/* ===== Permission Screen ===== */
.permission-card {
    padding: 44px 36px 36px;
    text-align: center;
}

.icon-location {
    margin-bottom: 16px;
    animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}

.permission-card h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.permission-card h1 span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.permission-card p {
    color: var(--text-light);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.privacy-note {
    font-size: 11px !important;
    color: #64748b !important;
    margin-top: 8px !important;
    margin-bottom: 0 !important;
}

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(96, 165, 250, 0.35);
}
.btn-primary:active {
    transform: translateY(0);
}

/* ===== Divider ===== */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: #475569;
    font-size: 13px;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--card-border);
}

/* ===== Search Box ===== */
.search-box {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(15, 23, 42, 0.6);
    border: 1.5px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 4px 4px 4px 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-box .search-icon {
    flex-shrink: 0;
    color: #64748b;
}
.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 8px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    outline: none;
}
.search-box input::placeholder {
    color: #64748b;
}
.btn-search {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform var(--transition);
}
.btn-search:hover {
    transform: scale(1.05);
}

/* ===== Loading Screen ===== */
#loadingScreen {
    text-align: center;
}
.loading-wrapper {
    padding: 60px 20px;
}
.loader {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 28px;
}
.loader-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--primary);
}
.loader-ring:nth-child(1) { animation: spin 1.2s linear infinite; }
.loader-ring:nth-child(2) { inset: 8px; border-top-color: var(--accent); animation: spin 1.6s linear infinite reverse; }
.loader-ring:nth-child(3) { inset: 16px; border-top-color: rgba(96, 165, 250, 0.3); animation: spin 2s linear infinite; }
.loader-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loadingScreen p {
    color: var(--text-light);
    font-size: 16px;
    font-weight: 500;
}

/* ===== Weather Screen ===== */
.weather-card {
    padding: 24px 28px 28px;
}

/* Inline search on weather screen */
.weather-search-bar {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(15, 23, 42, 0.6);
    border: 1.5px solid var(--card-border);
    border-radius: 10px;
    padding: 3px 3px 3px 12px;
    margin-bottom: 20px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.weather-search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.weather-search-bar .search-icon {
    flex-shrink: 0;
    color: #64748b;
}
.weather-search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 8px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    outline: none;
}
.weather-search-bar input::placeholder { color: #64748b; }
.btn-search-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform var(--transition);
}
.btn-search-sm:hover { transform: scale(1.05); }

.location-info {
    text-align: center;
    margin-bottom: 20px;
}
.location-info h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}
.location-info p {
    color: var(--text-light);
    font-size: 13px;
    margin-top: 4px;
}

/* Main weather display */
.weather-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    padding: 16px 0;
}

.weather-main-left {}
.temperature-display {
    font-size: 64px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    letter-spacing: -2px;
}
.unit {
    font-size: 28px;
    font-weight: 400;
    color: var(--text-light);
    vertical-align: top;
}
.feels-like-text {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 6px;
}

.weather-main-right {
    text-align: center;
}
.weather-icon {
    font-size: 64px;
    animation: iconBounce 3s ease-in-out infinite;
    line-height: 1;
}
.weather-desc-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-transform: capitalize;
    margin-top: 4px;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

/* Weather details grid */
.weather-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}
.detail-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--detail-bg);
    border-radius: var(--radius-sm);
    transition: transform var(--transition), background var(--transition);
}
.detail-item:hover {
    transform: translateY(-2px);
    background: rgba(96, 165, 250, 0.12);
}
.detail-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-glow);
    flex-shrink: 0;
}
.detail-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.detail-value {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

/* Action buttons row */
.weather-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.btn-refresh, .btn-locate {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 10px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-refresh {
    background: var(--accent-glow);
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-refresh:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 18px var(--accent-glow);
    transform: translateY(-1px);
}
.btn-locate {
    background: rgba(167, 139, 250, 0.1);
    color: var(--accent);
    border: 1.5px solid var(--accent);
}
.btn-locate:hover {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 18px rgba(167, 139, 250, 0.3);
    transform: translateY(-1px);
}

/* API Usage */
.api-usage-note {
    padding: 12px 16px;
    background: var(--detail-bg);
    border-radius: var(--radius-sm);
}
.usage-stats {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.usage-item {
    flex: 1;
    text-align: center;
}
.usage-label {
    display: block;
    font-size: 10px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.usage-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

/* ===== Error Screen ===== */
.error-card {
    padding: 44px 36px;
    text-align: center;
}
.error-icon {
    margin-bottom: 16px;
}
.error-card h2 {
    font-size: 26px;
    font-weight: 700;
    color: #f87171;
    margin-bottom: 12px;
}
.error-card p {
    color: var(--text-light);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 24px;
}

/* ===== Footer ===== */
.footer {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    text-align: center;
    padding: 24px 16px 16px;
    flex-shrink: 0;
    color: var(--text-light);
    font-size: 12px;
}
.footer p {
    margin: 4px 0;
    line-height: 1.6;
}
.footer a {
    color: var(--text);
    text-decoration: none;
    transition: color var(--transition);
}
.footer a:hover {
    color: var(--primary);
}
.footer-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
}
.footer-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--card-border);
    color: var(--text-light);
    transition: background var(--transition), color var(--transition), transform var(--transition), border-color var(--transition);
}
.footer-links a:hover {
    background: var(--accent-glow);
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
}
.inline-icon {
    display: inline-block;
    vertical-align: middle;
    margin: 0 2px;
}
.heart-icon {
    color: #ef4444;
    animation: heartbeat 1.5s ease-in-out infinite;
}
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    body { padding: 10px; }
    .container { max-width: 100%; }

    .permission-card { padding: 32px 20px 24px; }
    .permission-card h1 { font-size: 24px; }
    .permission-card p { font-size: 14px; }

    .weather-card { padding: 20px 18px 22px; }
    .location-info h2 { font-size: 20px; }

    .weather-main { flex-direction: column; gap: 8px; text-align: center; padding: 8px 0; }
    .weather-main-left { text-align: center; }
    .temperature-display { font-size: 52px; }
    .weather-icon { font-size: 52px; }

    .weather-details { grid-template-columns: 1fr; gap: 10px; }
    .detail-item { padding: 12px; }

    .weather-actions { flex-direction: column; }

    .error-card { padding: 32px 20px; }
    .error-card h2 { font-size: 22px; }
}
