@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    min-height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #00B4DB, #0083B0);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.back-arrow {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    transition: background 0.3s ease, transform 0.2s ease;
}

.back-arrow:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.weather-app {
    width: 100%;
    max-width: 1000px;
    margin: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

.search-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.search-box {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 280px;
}

.search-input {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 16px;
    min-width: 200px;
}

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

.search-button,
.location-button {
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    transition: background 0.3s ease;
    min-width: 44px;
}

.search-button:hover,
.location-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.unit-toggle {
    display: flex;
    gap: 5px;
}

.temp-unit {
    padding: 8px 15px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.temp-unit:first-child {
    border-radius: 10px 0 0 10px;
}

.temp-unit:last-child {
    border-radius: 0 10px 10px 0;
}

.temp-unit.active {
    background: rgba(255, 255, 255, 0.3);
    font-weight: 600;
}

.loader {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.error-container {
    text-align: center;
    color: #fff;
    padding: 20px;
}

.error-container i {
    font-size: 48px;
    margin-bottom: 10px;
}

.current-weather {
    color: #fff;
    margin-bottom: 40px;
}

.weather-header {
    margin-bottom: 30px;
}

.city-name {
    font-size: 32px;
    font-weight: 600;
}

.current-date {
    font-size: 16px;
    opacity: 0.8;
}

.weather-main {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.weather-icon {
    width: 80px;
    height: 80px;
}

.temperature {
    font-size: 48px;
    font-weight: 600;
}

.weather-description {
    font-size: 18px;
    text-transform: capitalize;
}

.weather-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.detail {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
}

.detail i {
    font-size: 24px;
}

.detail-info span {
    font-size: 18px;
    font-weight: 600;
}

.detail-info p {
    font-size: 14px;
    opacity: 0.8;
}

.forecast {
    color: #fff;
}

.forecast h2 {
    margin-bottom: 20px;
}

.forecast-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.forecast-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
}

.forecast-date {
    font-size: 14px;
    margin-bottom: 10px;
}

.forecast-icon {
    width: 50px;
    height: 50px;
    margin: 10px auto;
}

.forecast-temp {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 5px;
}

.forecast-description {
    font-size: 14px;
    opacity: 0.8;
    text-transform: capitalize;
}

.hidden {
    display: none !important;
}

@media (max-width: 768px) {
    body {
        padding: 0;
        align-items: flex-start;
        min-height: 100vh;
        height: auto;
    }

    .back-arrow {
        position: absolute;
        top: 15px;
        left: 15px;
        z-index: 100;
    }

    .weather-app {
        margin: 10px;
        padding: 15px;
        margin-top: 50px;
        border-radius: 15px;
        min-height: calc(100vh - 20px);
    }

    .app-header {
        margin-bottom: 1.5rem;
    }

    .logo-container {
        gap: 0.5rem;
    }

    .logo {
        width: 40px;
        height: 40px;
    }

    .logo-text {
        font-size: 1.2rem;
    }

    .search-container {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        margin-bottom: 20px;
        width: 100%;
    }

    .search-box {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-width: unset;
        gap: 10px;
    }

    .search-input-group {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    .search-input {
        min-width: unset;
        width: 100%;
        font-size: 14px;
        padding: 10px 15px;
    }

    .search-button {
        padding: 10px 15px;
        white-space: nowrap;
    }

    .location-button {
        width: 100%;
        padding: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .location-button i {
        margin-right: 5px;
    }

    .location-button::after {
        content: "Use Current Location";
        font-size: 14px;
    }

    .unit-toggle {
        width: 100%;
        justify-content: center;
        gap: 0;
    }

    .temp-unit {
        flex: 1;
        max-width: 100px;
        font-size: 14px;
        padding: 8px 12px;
    }

    .weather-main {
        flex-direction: row;
        justify-content: center;
        text-align: left;
        gap: 15px;
        padding: 15px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 10px;
        margin-bottom: 20px;
    }

    .weather-icon {
        width: 70px;
        height: 70px;
    }

    .temperature {
        font-size: 2.5rem;
        line-height: 1;
        margin-bottom: 5px;
    }

    .weather-description {
        font-size: 1rem;
    }

    .weather-details {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .detail {
        padding: 12px;
    }

    .detail i {
        font-size: 1.2rem;
    }

    .detail-info span {
        font-size: 1rem;
    }

    .detail-info p {
        font-size: 0.8rem;
    }

    .forecast h2 {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }

    .forecast-container {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .forecast-card {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        text-align: left;
        gap: 12px;
        padding: 12px;
    }

    .forecast-date {
        font-size: 0.9rem;
        margin-bottom: 0;
    }

    .forecast-icon {
        width: 40px;
        height: 40px;
        margin: 0;
    }

    .forecast-temp {
        font-size: 1.1rem;
        margin-bottom: 2px;
    }

    .forecast-description {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .weather-app {
        padding: 12px;
    }

    .weather-details {
        grid-template-columns: 1fr;
    }

    .detail {
        padding: 10px;
    }

    .weather-main {
        padding: 12px;
    }

    .temperature {
        font-size: 2.2rem;
    }

    .city-name {
        font-size: 1.3rem;
    }

    .current-date {
        font-size: 0.9rem;
    }

    .city-select-modal .modal-content {
        padding: 15px;
        margin: 15px;
    }

    .city-option {
        padding: 10px;
        font-size: 0.9rem;
    }
}

.city-select-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.city-select-modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.city-select-modal .modal-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

.city-select-modal h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.city-select-modal p {
    color: #333;
    margin-bottom: 1.5rem;
}

.city-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.city-option {
    background: rgba(255, 255, 255, 0.8);
    padding: 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.city-option:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.city-name-main {
    font-weight: 600;
    color: #333;
}

.city-details {
    color: #666;
    font-size: 0.9rem;
}

.close-modal {
    display: block;
    width: 100%;
    padding: 0.8rem;
    border: none;
    background: #e0e0e0;
    color: #333;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s ease;
}

.close-modal:hover {
    background: #d0d0d0;
}

.app-header {
    margin-bottom: 2rem;
    text-align: center;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.logo {
    width: 60px;
    height: 60px;
    border-radius: 15px;
}

.logo-text {
    color: #fff;
    font-size: 1.4rem;
    font-weight: 600;
}

@media screen and (max-height: 500px) and (orientation: landscape) {
    body {
        align-items: flex-start;
        padding: 0;
        height: auto;
        min-height: 100vh;
        position: relative;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .weather-app {
        margin: 10px;
        padding: 15px;
        height: auto;
        min-height: calc(100vh - 20px);
    }

    .search-container {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .search-box {
        flex-direction: row;
        min-width: auto;
    }

    .location-button {
        width: auto;
    }

    .location-button::after {
        content: none;
    }

    .weather-details {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }

    .forecast-container {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
    }

    .forecast-card {
        padding: 10px;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .forecast-icon {
        margin: 5px auto;
    }

    /* Prevent touch action issues */
    * {
        touch-action: pan-x pan-y;
        -webkit-touch-callout: none;
    }
}