* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #e8f4ff;

    display: flex;
    justify-content: center;
    align-items: center;

    min-height: 100vh; /*viewport height 100 is full height of browser window*/

}

.container {
    width:95%;
    max-width:800px;

    margin:40px auto;

    padding:35px;

    border-radius:20px;
  
    background:rgba(255,255,255,.92);

    backdrop-filter:blur(12px);

    box-shadow: 0 12px 30px rgba(0,0,0,0.12);

    text-align: center;
}

h1 {
    margin-bottom: 25px;
        color:#1e293b;

}

form {
    margin-bottom: 25px;
}
.search-row{
    display:flex;
    gap:15px;
   
}

.search-row input{
    flex:1;

}
#search-btn:hover{
    background:#1976d2;
}

.search-row button{
    width:120px;
    background:#2196f3;
    color:white;
}
    
    .controls{
    
    display:grid;
    
    grid-template-columns:
    1fr 1fr 90px;
    
    gap:10px;
    
    }

#location-btn {
    width: 100%;
    margin-top: 3px;
    flex:2;
    background:#1c4a7a;

    color:white;
}

input {
    flex: 1;

    padding: 14px;

    border: 1px solid #ccc;

    border-radius: 10px;

    font-size: 16px;

    transition: 0.3s;
}

input:focus {
    outline: none;
    border-color: #2196f3;
}

button{

    height:52px;

    border-radius:14px;

    font-size:15px;

    font-weight:600;
}

button:hover{

    transform:translateY(-2px);

}

#weather-card{
    display:flex;
    flex-direction:column;
    align-items:center;
    text-align:center;
    width:100%;
    gap: 8px;
}

#temperature{

    font-size:72px;
    
    font-weight:700;
    margin:5px 0;

    
    }
    
    #city-name{
    
    font-size:42px;
    color:#1f2937;


    
    }
    
    #description{
    
    font-size:22px;
    
    opacity:.85;
    color:#475569;

    
    }

#weather-card p {
    margin: 10px 0;

    font-size: 18px;
}

#weather-icon {
    width: 120px;
    height: 120px;

    margin: 10px auto;

    display: block;
}

#loading{

    color:#2196f3;

    font-weight:bold;

    margin-bottom:15px;
}

#error-message{

    color:#d32f2f;

    font-weight:bold;

    margin-bottom:15px;

    min-height:24px;
}

button:disabled{

    background:#9e9e9e;

    cursor:not-allowed;
}

@media (max-width: 500px) {

    .search-row {
        flex-direction: column;
    }

    .search-row button {
        width: 100%;
    }

}
#temperature{
    margin-bottom:8px;
}

.temp-range{
    color:#666;
    margin-bottom:18px;
    font-size:15px;
}
#last-updated {
    margin-top: 20px;
    font-size: 14px;
    color:#94a3b8;
}


#forecast-container::-webkit-scrollbar{

    height:8px;

}
#forecast-container{
    display:flex;
    justify-content:center;

    gap:15px;

    overflow-x:auto;

    padding:10px;

    width:100%;
}

.forecast-card{

    min-width:140px;

    padding:18px;

    border-radius:15px;

    background:white;

    text-align:center;

    flex-shrink:0;

    box-shadow:
    0 8px 18px rgba(0,0,0,.12);

    transition:.25s;

}

.forecast-card:hover{

    transform:translateY(-5px);

}
:root {
    --bg: #e8f4ff;
    --card: #ffffff;
    --text: #222;
    --muted: #666;
}

body {
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s, color 0.3s;
}

.container {
    background: var(--card);
}

#last-updated{

    margin-top:20px;
    
    opacity:.7;
    
    }
body.dark{

    background:#121212;

    color:white;

}

body.dark .container{

    background:#1d1d1d;

}

body.dark .detail-card,

body.dark .forecast-card,

body.dark #history-list li,

body.dark .favorite-city{

    background:#2a2a2a;

    color:white;

}

#favorites {
    margin-top: 35px;
    border-top: 1px solid #ddd;
    padding-top: 20px;
}

.favorite-actions {
    margin-bottom: 15px;
}

#save-favorite {
    width: 100%;
}

#favorites-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.favorite-city{

    background:white;

    padding:15px;

    border-radius:12px;

    margin-bottom:10px;

    cursor:pointer;

    transition:.2s;

    box-shadow:
    0 4px 10px rgba(0,0,0,.08);

}

.favorite-city:hover{

    transform:translateX(6px);

}
#history {
    margin-top: 35px;
    border-top: 1px solid #ddd;
    padding-top: 20px;
}
#history-list{

    list-style:none;

    padding:0;

}

#history-list li{

    padding:14px;

    background:white;

    border-radius:12px;

    margin-bottom:10px;

    cursor:pointer;

    transition:.2s;

}

#history-list li:hover{

    transform:translateX(6px);

}

.spinner{

    width:55px;

    height:55px;

    border:6px solid rgba(255,255,255,.3);

    border-top:6px solid white;

    border-radius:50%;

    animation:spin .8s linear infinite;

    margin:auto;

}

@keyframes spin{

    from{

        transform:rotate(0);

    }

    to{

        transform:rotate(360deg);

    }

}

.error-card {
    background: #ffebee;
    color: #b71c1c;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
}

.error-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.weather-details{
    display:grid;
    grid-template-columns:repeat(3, 1fr);
    gap:18px;

    width:100%;
    max-width:650px;

    margin:25px auto;
}

.detail-card{

    padding:14px;

    border-radius:15px;

    background:rgba(255,255,255,.25);

    backdrop-filter:blur(10px);

    box-shadow:
    0 6px 20px rgba(0,0,0,.12);

    transition:.25s;

}

.detail-card:hover{

    transform:translateY(-4px);
    box-shadow:0 10px 25px rgba(0,0,0,.15);


}


.detail-card span{

    color:#64748b;


    font-size:14px;

}

.detail-card h3{

    margin-top:8px;
    color:#1e293b;

    font-size:24px;

}
.tabs{
    display:flex;
    justify-content:center;
    gap:12px;

    margin:25px auto;

    width:100%;
    max-width:550px;
}

.tab-btn{

    flex:1;

    padding:12px;

    border:none;

    border-radius:10px;

    cursor:pointer;

    background:#ececec;

    transition:.3s;

}

.tab-btn.active{

    background:#2196f3;

    color:white;

}

.tab-panel{

    display:none;

    margin-top:20px;

}

.tab-panel.active{

    display:block;

}

.action-buttons{
    display:flex;
    justify-content:center;
    gap:15px;

    width:100%;
    max-width:500px;

    margin:20px auto;
}

.action-buttons button{

    flex:1;

}
.header{
    text-align:center;
    margin-bottom:25px;
}

.title-area h1{
    font-size:42px;
    margin-bottom:8px;
}

.subtitle{

        color:#64748b;

    font-size:16px;
}
.controls{
    display:flex;
    gap:15px;
    margin-top:15px;
}

#theme-toggle{
    flex:2;

    background:#111827;

    color:white
}

#unit-toggle{
    flex:1;
    background:white;

    border:2px solid #2196f3;

    color:#2196f3;
}

.controls button{

    flex:1;

}
.weather-main{

    display:grid;

    grid-template-columns:320px 1fr;

    gap:35px;

    align-items:center;

}
/* =========================
   Mobile Responsive Design
   ========================= */

   @media (max-width: 600px) {

    body {
        padding: 20px;
        align-items: flex-start;
    }

    .container {
        width: 100%;
        padding: 20px;
        margin-top: 20px;
    }

    /* Header */

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    h1 {
        font-size: 28px;
    }

    /* Search */

    .search-row {
        flex-direction: column;
    }

    .search-row input,
    .search-row button {
        width: 100%;
    }

    .controls {
        flex-direction: column;
    }

    .controls button {
        width: 100%;
    }

    /* Buttons */

    button {
        padding: 12px;
        font-size: 16px;
    }

    .action-buttons {
        flex-direction: column;
    }

    /* Weather */

    #temperature {
        font-size: 44px;
    }

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

    .detail-card {
        padding: 14px;
    }

    /* Tabs */

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
    }

    /* Forecast */

    #forecast-container {
        gap: 10px;
        overflow-x: auto;
    }

    .forecast-card {
        min-width: 100px;
        padding: 12px;
    }

    .forecast-card img {
        width: 50px;
    }

}
/* =========================
   Dark Mode
========================= */

body.dark {
    background: #121212 !important;
    color: #f5f5f5;
}

body.dark .container {
    background: #1e1e1e;
    color: #f5f5f5;
}

body.dark h1,
body.dark h2,
body.dark h3,
body.dark p,
body.dark span,
body.dark li {
    color: #f5f5f5;
}

body.dark input {
    background: #2d2d2d;
    color: white;
    border: 1px solid #555;
}

body.dark input::placeholder {
    color: #bbbbbb;
}

body.dark .detail-card,
body.dark .forecast-card {
    background: #2a2a2a;
    color: white;
    border: 1px solid #444;
}

body.dark .tab-btn {
    background: #333;
    color: white;
}

body.dark .tab-btn.active {
    background: #2196f3;
}

body.dark button {
    color: white;
}

body.dark #history-list li,
body.dark .favorite-city {
    background: #2a2a2a;
    color: white;
}

body.dark #weather-card {
    background: rgba(40, 40, 40, 0.9);
}

body.dark #error-message {
    color: #ff8a80;
}
body.dark #city-name {
    color: #ffffff;
}
body.dark .action-buttons button {
    background: #2196f3;
    color: white;
    border: none;
}

body.dark .action-buttons button:hover {
    background: #1976d2;
}
