:root {
    /* Enhanced Glass Effects */
    --glass-bg: rgba(20, 20, 40, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-highlight: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);

    /* Vibrant Color Palette */
    --primary-text: #ffffff;
    --secondary-text: rgba(255, 255, 255, 0.7);
    --accent-color: #ff2e63;
    /* Vibrant Pink/Red */
    --accent-secondary: #08d9d6;
    /* Vibrant Teal */

    /* Dynamic Gradients */
    --bg-gradient-1: #252a34;
    --bg-gradient-2: #08d9d6;
    --bg-gradient-3: #ff2e63;

    --font-main: 'Inter', sans-serif;

    /* Animations */
    --transition-speed: 0.4s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
    user-select: none;
    /* Premium app feel */
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll */
    background: radial-gradient(circle at top left, #1a1a2e, #16213e, #0f3460);
    color: var(--primary-text);
    display: flex;
}

/* Animated Background Mesh (Pseudo-elements) */
body::before,
body::after {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.4;
    animation: floatingOrb 20s infinite ease-in-out alternate;
}

body::before {
    background: var(--accent-secondary);
    top: -100px;
    left: -100px;
}

body::after {
    background: var(--accent-color);
    bottom: -100px;
    right: -100px;
    animation-delay: -10s;
}

@keyframes floatingOrb {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(50px, 50px);
    }
}

/* App Full Screen Container */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 25, 0.3);
    /* Slight overlay */
    backdrop-filter: blur(5px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    height: 100%;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2.5rem 1.5rem;
    z-index: 10;
    animation: slideRight 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 4rem;
    padding-left: 0.5rem;
}

.brand-icon {
    font-size: 2rem;
    color: var(--accent-secondary);
    filter: drop-shadow(0 0 10px rgba(8, 217, 214, 0.5));
}

.brand h2 {
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(to right, #fff, var(--secondary-text));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--secondary-text);
    padding: 1rem 1.5rem;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.nav-links a::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-secondary);
    opacity: 0;
    transition: 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0));
    color: #fff;
    padding-left: 2rem;
    /* Slide effect */
}

.nav-links a.active::before {
    opacity: 1;
}

.nav-links i {
    width: 24px;
    text-align: center;
    font-size: 1.2rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
    /* Allow scrolling if content overflows */
    overflow-x: hidden;
    position: relative;
    height: 100%;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    animation: slideDown 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
    flex-shrink: 0;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    border-radius: 16px;
    padding: 0.8rem 1.5rem;
    width: 450px;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.search-box:focus-within {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-secondary);
    box-shadow: 0 0 20px rgba(8, 217, 214, 0.2);
    transform: translateY(-2px);
}

.search-box i {
    color: var(--secondary-text);
    margin-right: 1rem;
}

.search-box input {
    border: none;
    background: transparent;
    color: #fff;
    width: 100%;
    font-size: 1.1rem;
    outline: none;
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.search-box button {
    background: var(--accent-color);
    border: none;
    color: #fff;
    padding: 0.6rem 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    margin-left: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(255, 46, 99, 0.3);
}

.search-box button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 15px rgba(255, 46, 99, 0.5);
}

.unit-toggle {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--secondary-text);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.unit-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.active-unit {
    color: var(--accent-secondary);
    text-shadow: 0 0 10px rgba(8, 217, 214, 0.6);
}

/* Dashboard Grid */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    /* Changed for new layout */
    gap: 1.5rem;
    height: auto;
    width: 100%;
    min-height: 100%;
    animation: fadeIn 1s ease-out;
    padding-bottom: 2rem;
}

/* Horizontal Weather Card */
.current-weather-horizontal {
    background: var(--glass-bg);
    border-radius: 24px;
    padding: 2rem 3rem;
    /* Increased padding */
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    min-height: 250px;
    /* Increased from 180px */
    width: 100%;
}

.horizontal-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}

.horizontal-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 2;
}

.weather-info-horizontal {
    display: flex;
    align-items: center;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
    /* Safety wrap */
}

.horizontal-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
}

.weather-details-grid-horizontal {
    display: flex;
    gap: 3rem;
}

/* Internal Elements for Horizontal Card */
.current-weather-horizontal #temp {
    font-size: clamp(3rem, 5vw, 6rem);
    /* Adjusted clamp */
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(to bottom, #fff, rgba(255, 255, 255, 0.7));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
    margin: 0;
}

.current-weather-horizontal #city-name {
    margin-top: 1rem;
    font-size: 2rem;
    letter-spacing: 1px;
    font-weight: 300;
}

.current-weather-horizontal .card-header p {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    color: var(--secondary-text);
}

/* Base Card Style */
.weather-card,
.chart-card {
    background: var(--glass-bg);
    border-radius: 24px;
    padding: 1.5rem;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 350px;
    /* Set a solid default base height for all charts */
}

/* Card Hover Effects */
.weather-card:hover,
.chart-card:hover {
    transform: translateY(-8px);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

/* Glass Highlight Gradient on Cards */
.weather-card::after,
.chart-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

.weather-status {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 100%;
    flex-wrap: wrap;
    /* Flexible wrap */
}

#icon {
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

#weather {
    font-size: 1.1rem;
    font-weight: 500;
    text-transform: capitalize;
    text-align: center;
}

.detail-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 18px;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.3s;
}

.detail-item:hover {
    transform: scale(1.02);
    background: rgba(0, 0, 0, 0.3);
}

.detail-item i {
    font-size: 1.5rem;
    color: var(--accent-secondary);
}

.detail-item .label {
    font-size: 0.9rem;
    color: var(--secondary-text);
    display: block;
    margin-bottom: 0.2rem;
}

.detail-item span:last-child {
    font-size: 1.2rem;
    font-weight: 700;
}

/* Charts Section */
.charts-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
}

.chart-card h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--secondary-text);
    flex-shrink: 0;
}

.chart-card h3::before {
    content: '•';
    color: var(--accent-color);
    margin-right: 0.5rem;
    font-size: 1.5rem;
    vertical-align: middle;
}

.chart-container {
    flex: 1;
    position: relative;
    width: 100%;
    min-height: 250px;
    /* Ensure charts have space */
}

.chart-row {
    display: flex;
    gap: 1.5rem;
    flex: 1;
    min-height: 350px;
    /* Increased row height */
}

.half-width {
    flex: 1;
}

/* Animations */
@keyframes slideRight {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Body Theme Modifiers (Subtle Tweaks for dynamic feel) */
body.rain-theme {
    --accent-secondary: #4facfe;
}

body.clear-theme {
    --accent-secondary: #fbd38d;
    --accent-color: #ff8c00;
}

body.cloud-theme {
    --accent-secondary: #a8edea;
    --accent-color: #636fa4;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .current-weather-horizontal {
        padding: 1.5rem;
    }

    .weather-details-grid-horizontal {
        gap: 1.5rem;
    }
}

@media (max-width: 1024px) {
    .current-weather-horizontal {
        flex-direction: column;
        gap: 2rem;
        text-align: center;
        padding: 2rem;
        height: auto;
    }

    .horizontal-left,
    .horizontal-right {
        width: 100%;
        justify-content: center;
    }

    .weather-info-horizontal {
        flex-direction: column;
        gap: 0.5rem;
    }

    .weather-details-grid-horizontal {
        gap: 1.5rem;
        margin-top: 1rem;
        width: 100%;
        justify-content: center;
    }

    .dashboard-grid {
        height: auto;
    }

    .charts-section {
        height: auto;
    }

    .chart-row {
        flex-direction: row;
        height: auto;
        min-height: 300px;
    }
}

@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
        display: block;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        padding: 1rem;
        align-items: center;
        justify-content: space-between;
        height: auto;
        position: sticky;
        top: 0;
    }

    .brand {
        margin-bottom: 0;
    }

    .nav-links {
        flex-direction: row;
        gap: 0.5rem;
    }

    .nav-links a span {
        display: none;
    }

    .nav-links a {
        padding: 0.8rem;
    }

    .main-content {
        padding: 1.5rem;
        height: auto;
    }

    .top-bar {
        flex-direction: column;
        gap: 1rem;
    }

    .search-box {
        width: 100%;
    }

    .weather-details-grid-horizontal {
        flex-direction: column;
        align-items: center;
    }

    .detail-item {
        width: 100%;
        justify-content: center;
    }

    .chart-row {
        flex-direction: column;
        min-height: auto;
    }
}

/* ... (existing styles) ... */

/* Tables Page Styles */

/* Table Container */
.weather-table {
    background: var(--glass-bg);
    border-radius: 24px;
    padding: 2rem;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    margin-bottom: 2rem;
    overflow-x: auto;
}

.weather-table h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--primary-text);
}

/* Sorting Menu */
.sorting-menu {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.sorting-menu label {
    color: var(--secondary-text);
    font-weight: 500;
}

.sorting-menu select {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--primary-text);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    outline: none;
    cursor: pointer;
    font-family: var(--font-main);
}

.sorting-menu select option {
    background: #1a1a2e;
    /* Dark background for dropdown options */
    color: var(--primary-text);
}

/* Table Styling */
#forecast_table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
    margin-top: 1rem;
}

#forecast_table th {
    text-align: left;
    padding: 1rem;
    color: var(--secondary-text);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

#forecast_table td {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    color: var(--primary-text);
}

#forecast_table tr:hover td {
    background: rgba(255, 255, 255, 0.08);
}

#forecast_table td:first-child {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

#forecast_table td:last-child {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

.pagination button {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--primary-text);
    padding: 0.5rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination button:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 46, 99, 0.4);
}

/* Chatbot Styles */
.chatbot-icon {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: var(--accent-secondary);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(8, 217, 214, 0.4);
    transition: all 0.3s ease;
    z-index: 1000;
}

.chatbot-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(8, 217, 214, 0.6);
}

.chatbot-icon img {
    width: 30px;
    height: 30px;
    filter: brightness(0) invert(1);
    /* Make icon white */
}

.chatbot {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 350px;
    height: 400px;
    background: rgba(20, 20, 40, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    animation: slideDown 0.4s ease-out reverse;
    /* Or a custom pop-up animation */
}

.chatbot-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.chatbot-header h2 {
    font-size: 1.1rem;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--secondary-text);
    font-size: 1.2rem;
    cursor: pointer;
}

.chatbox {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    padding: 0.8rem 1.2rem;
    border-radius: 18px;
    max-width: 80%;
    line-height: 1.5;
    font-size: 0.95rem;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.bot-message {
    background: rgba(255, 255, 255, 0.1);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.user-message {
    background: linear-gradient(135deg, var(--accent-color), #ff5757);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    color: white;
    box-shadow: 0 4px 15px rgba(255, 46, 99, 0.3);
}

.chatbot input {
    background: rgba(0, 0, 0, 0.2);
    border: none;
    padding: 1rem;
    color: #fff;
    outline: none;
    border-top: 1px solid var(--glass-border);
}

#ask {
    margin: 0.5rem;
    border-radius: 12px;
}