@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap');

:root {
    --bg-start: #000000;

    --bg-end: #1c2331;
    --card-bg: rgba(30, 40, 50, 0.75);
    --text-primary: #ffffff;
    --text-secondary: rgba(235, 235, 245, 0.6);
    --accent: #f1c40f;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html {
    background: #182335; /* Match top of gradient to prevent black bar on overscroll */
    height: 100%;
}

html::-webkit-scrollbar {
    display: none;
}

body {
    background: linear-gradient(180deg, #182335 0%, #0e121a 100%);
    background-attachment: scroll; 
    color: var(--text-primary);
    min-height: 100vh;
    /* Ensure body expands to fill scrollable area so gradient stretches or repeats? 
       Actually with scroll, gradient stretches to content height. 
       If content > vh, gradient stretches. 
       If we want fixed gradient background effect: */
    background-attachment: fixed; 
}

body::-webkit-scrollbar {
    display: none;
}

body.no-scroll {
    overflow: hidden !important;
    /* Strict lock */
    height: 100vh;
    touch-action: none;
    /* Prevent touch gestures on body when locked */
}

.app-container {
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: 150px;
    /* Aggressive bottom padding */
    max-width: 480px;
    margin: 0 auto;
    /* Center app */
    min-height: 100vh;
    overflow-x: hidden;
    /* Prevent horizontal overflow */
}

/* Header */
.current-weather {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0 10px; /* Greatly reduced top padding from 60px */
    animation: fadeInDown 0.8s ease-out;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Location Badge Clickable */
.location-badge {
    display: inline-block;
    justify-content: center;
    align-items: center;
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 5px; /* Reduced margin */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    
    /* Liquid Glass Effect */
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 0.5px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), inset 0 0 10px rgba(255,255,255,0.05);
    
    padding: 8px 20px;
    border-radius: 24px; /* Slightly softer curve */
    transition: all 0.2s ease;
    position: relative;
    clear: both;
    opacity: 1;
}

.location-badge:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.96);
}


.temp-display {
    font-size: 6.5rem;
    font-weight: 200;
    line-height: 1;
    margin: 5px 0 0 0; /* Reduced top/bottom margin */
    position: relative;
    display: inline-block;
    letter-spacing: -2px;
}

.degree {
    font-size: 3rem;
    position: absolute;
    top: 10px;
    right: -30px;
    font-weight: 300;
}

.condition {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.high-low {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 20px;
    /* Separated from Temp */
    display: inline-block;
    /* Ensure it treats margin properly */
}

.update-time {
    margin-top: 5px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
}

/* Section Title */
.section-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-left: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Unified Glass Style */
.glass-card {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    /* Adapted color to neutral dark */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    padding: 15px;
    margin-bottom: 20px;
}

/* Forecast List */
.forecast-container {
    /* Inherits glass-card via HTML addition, or we extend here */
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    padding: 15px;
    margin-bottom: 20px;
}

/* Chart Container - Unified & Masked */
/* Pull to Refresh Spinner */
.ptr-spinner {
    position: fixed;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    opacity: 0;
    z-index: 1000;
    transition: opacity 0.2s, top 0.2s;
    pointer-events: none;
}

.ptr-spinner.loading {
    opacity: 1;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translateX(-50%) rotate(360deg); }
}

/* Chart Container - Unified */
.chart-dashboard-container {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    padding: 0; 
    margin: 0 auto 20px auto;
    opacity: 0;
    transition: opacity 0.5s;
    width: 100%;
    box-sizing: border-box;
    display: block;
    height: 160px; /* Increased height for interaction */
}

.forecast-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* Continuous list look */
}

.forecast-item {
    display: grid;
    grid-template-columns: 50px 40px 1fr;
    align-items: center;
    padding: 14px 5px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.2s;
}

.forecast-item:last-child {
    border-bottom: none;
}

.forecast-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.day-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.wx-icon {
    font-size: 1.2rem;
    text-align: center;
}

/* Bar Chart in List */
.temp-range {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 15px;
}

.temp-val {
    width: 30px;
    /* fixed width for alignment */
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

.temp-val.min {
    color: rgba(255, 255, 255, 0.6);
}

.bar-track {
    flex: 1;
    height: 5px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    position: relative;
    overflow: hidden;
}

.bar-fill {
    position: absolute;
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
}

.current-temp-dot {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
    z-index: 2;
}

/* Details Grid */
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

/* Dashboard Chart */
/* Merged above */

.detail-card {
    background: rgba(80, 80, 80, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 18px;
    padding: 15px;
    aspect-ratio: 1 / 1;
    /* Square */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    /* Prevent overflow */
    min-width: 0;
    /* Flexbox fix */
}

.detail-header {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.detail-header i,
.detail-header svg {
    opacity: 0.7;
}

.detail-value {
    font-size: 2rem;
    font-weight: 500;
    color: #fff;
    margin-top: 5px;
}

.detail-sub {
    font-size: 0.85rem;
    color: #fff;
    margin-top: auto;
    opacity: 0.9;
    line-height: 1.3;
}

.detail-footer {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* Modal */
/* Modal - iOS Bottom Sheet Style */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: flex-end;
    /* Align to bottom */
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.open .modal-backdrop {
    opacity: 1;
}

.modal-content {
    width: 100%;
    max-width: 600px;
    /* Keep max-width for PC but ensure full width on mobile */
    max-height: 85vh;
    background: rgba(44, 44, 46, 0.95);
    /* Slightly more opaque */
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 24px 24px 0 0;
    /* Top corners rounded */
    padding: 24px;
    padding-bottom: calc(30px + env(safe-area-inset-bottom));
    /* Safe area */
    position: relative;
    transform: translateY(100%);
    /* Start off-screen */
    opacity: 1;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* Prevent chaining to body */
    /* Animation handled in .modal.open */
}

.modal.open .modal-content {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-container {
    height: 280px;
    width: 100%;
}

.close-btn {
    background: rgba(120, 120, 128, 0.3);
    border: none;
    color: #ebebf5;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hide Scrollbar */
/* Hide Scrollbar Global */
::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent;
}

html,
body {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}





/* Dashboard Chart */


/* Selector Modal (Bottom Sheet Style) */
.selector-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: none;
    /* Flex when active */
    align-items: flex-end;
    /* Bottom sheet */
    justify-content: center;
}

.selector-modal.active {
    display: flex;
}

.selector-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s;
}

.selector-modal.active .selector-backdrop {
    opacity: 1;
}

.selector-content {
    background: #1c2331;
    /* Match Theme */
    width: 100%;
    max-width: 600px;
    border-radius: 20px 20px 0 0;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2001;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.selector-modal.active .selector-content {
    transform: translateY(0);
}

.selector-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.selector-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.selector-body {
    overflow-y: auto;
    padding: 0;
    /* iOS smooth scroll */
    -webkit-overflow-scrolling: touch;
}

.selector-group-title {
    padding: 8px 20px;
    font-size: 0.9rem;
    color: #60a5fa;
    /* Blue accent */
    font-weight: 700;
    background: rgba(255, 255, 255, 0.05);
    position: sticky;
    top: 0;
}

.selector-item {
    padding: 12px 20px;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.1s;
}

.selector-item:active {
    background: rgba(255, 255, 255, 0.1);
}