/* Base Styles with Smooth Transitions */
* { margin: 0; padding: 0; box-sizing: border-box; transition: background-color 0.5s ease, color 0.3s ease; }

body {
    font-family: 'Poppins', sans-serif;
    background: rgba(132, 138, 140, 0.267);
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}

body.dark-mode { background: rgba(3, 32, 83, 0.97); }

/* Header Styles with Fixed Positioning */
header.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5%;
    background-color: rgba(0, 0, 0, 0.043);
    position: sticky;
    top: 0;
    z-index: 1000;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

body.dark-mode header.navbar { background-color: rgba(3, 32, 83, 0.97); }

/* Logo with Gradient Text */
.logo {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.logo i { font-size: 1.6rem; animation: pulse 2s infinite; }


/* Time Display */
.datetime-container { position: absolute; left: 50%; transform: translateX(-50%); }

.datetime {
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: flex;
    gap: 8px;
}

body.dark-mode .datetime {
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Theme Toggle with Animation */
.theme-toggle {
    background: none;
    border: 1.5px solid #805ad5;
    font-size: 1.3rem;
    cursor: pointer;
    color: #805ad5;
    background-color: transparent;
    transition: all 0.3s ease;
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

body.dark-mode .theme-toggle { color: #805ad5; border: 1.5px solid #805ad5; }

.theme-toggle i { transition: transform 0.3s ease; }

.theme-toggle:hover i { transform: rotate(30deg); }

body.dark-mode .theme-toggle:hover i { transform: rotate(90deg); }

/* Main Content Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
    animation: fadeIn 0.6s ease-out;
}

/* Card Styling with Glass Morphism */
.card {
    border-radius: 15px;
    box-shadow: 0 0 10px rgba(140, 127, 127, 0.1);
    padding: 25px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1.4px solid #805ad5;
    transition: all 0.4s ease;
}

body.dark-mode .card { box-shadow: 0 0 8px #805ad5; border: 1.4px solid #805ad5; }

/* Search Box with Floating Effect */
.search-box { margin-bottom: 25px; }

.search-bar {
    display: flex;
    align-items: center;
    border-radius: 12px;
    padding: 8px;
    border: 1.5px solid #805ad5;
    transition: all 0.3s ease;
}

/* Dark Mode Styles */
body.dark-mode .search-bar { border: 1.5px solid #805ad5; }

.search-bar input {
    flex: 1;
    background-color: transparent;
    border: none;
    outline: none;
    padding: 10px 15px;
    font-size: 1rem;
    color: #805ad5;
    font-weight: 500;
}

.search-bar button {
    border: 1.5px solid #805ad5;
    border-radius: 12px;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    padding: 0 20px;
    height: 42px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.search-bar button:hover { box-shadow: 0 0 15px rgba(150, 185, 224, 0.5); }

.search-bar button i {
    font-size: 1rem;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Error Message with Shake Animation */
.error {
    background: linear-gradient(135deg, #fc8181 0%, #e53e3e 100%);
    color: white;
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
    align-items: center;
    gap: 10px;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    20%,
    60% {
        transform: translateX(-5px);
    }
    40%,
    80% {
        transform: translateX(5px);
    }
}

body.dark-mode .error { background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%); }

/* Current Weather Section with Weather Animations */
.weather { display: flex; flex-direction: column; gap: 25px; }

.current-weather {
    display: flex;
    align-items: center;
    text-align: center;
    gap: 25px;
    flex-wrap: wrap;
    justify-content: center;
}

.weather-icon {
    width: 250px;
    height: 250px;
    object-fit: contain;
    position: relative;
    animation: floatIcon 3s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(128, 90, 213, 0.3));
}

/* Float animation for all weather icons */
@keyframes floatIcon {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-6px);
    }
}

/* Sun Animation for Clear Weather */
.sunny .weather-icon { animation: sunGlow 3s infinite alternate; }

@keyframes sunGlow {
    0% {
        filter: drop-shadow(0 0 8px rgba(255, 204, 0, 0.6));
    }
    100% {
        filter: drop-shadow(0 0 16px rgba(255, 204, 0, 1));
    }
}

/* Cloud Animation for Cloudy Weather */
.cloudy .weather-icon { animation: cloudFloat 5s infinite ease-in-out; }

@keyframes cloudFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Rain Animation for Rainy Weather */
.rainy .weather-icon { position: relative; }

.rainy .weather-icon::after {
    content: "";
    position: absolute;
    bottom: -12px;
    left: 0;
    width: 100%;
    height: 18px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><path d="M10 0 Q15 15 20 0 Q25 15 30 0 Q35 15 40 0 Q45 15 50 0 Q55 15 60 0 Q65 15 70 0 Q75 15 80 0 Q85 15 90 0" stroke="%233182ce" fill="none" stroke-width="1"/></svg>') repeat-x;
    animation: rainFall 0.8s linear infinite;
    opacity: 0.5;
    pointer-events: none;
}

body.dark-mode .rainy .weather-icon::after {
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><path d="M10 0 Q15 15 20 0 Q25 15 30 0 Q35 15 40 0 Q45 15 50 0 Q55 15 60 0 Q65 15 70 0 Q75 15 80 0 Q85 15 90 0" stroke="%2363b3ed" fill="none" stroke-width="1"/></svg>') repeat-x;
}

@keyframes rainFall {
    0% {
        transform: translateY(-8px);
    }
    100% {
        transform: translateY(8px);
    }
}

.weather-info { flex: 1; }

.temperature {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1;
    margin-bottom: 5px;
    display: inline-block;
}

body.dark-mode .temperature {
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.city {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 5px;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

body.dark-mode .city {
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.description {
    font-size: 1.1rem;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-transform: capitalize;
    font-weight: 500;
}

body.dark-mode .description {
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Weather Details Grid with Hover Effects */
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; }

.info-box {
    background: transparent;
    border: 1.5px solid transparent;
    border-image: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    border-image-slice: 1;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    border-radius: 12px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

body.dark-mode .info-box {
    background: transparent;
    border: 1.5px solid transparent;
    border-image: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    border-image-slice: 1;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.info-box:hover { transform: translateY(1px); box-shadow: 0 0 15px rgba(49, 130, 206, 0.15); }

body.dark-mode .info-box:hover { box-shadow: 0 0 15px rgba(99, 179, 237, 0.15); }

.info-box img { width: 45px; height: 45px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1)); }

body.dark-mode .info-box img { filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) invert(0.8); }

.info-box p {
    font-size: 0.9rem;
    font-weight: 500;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

body.dark-mode .info-box p {
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Forecast Container */
.forecast {
    margin: 30px auto 0;
    border-top: 1.5px solid #805ad5;
    padding-top: 20px;
    max-width: 1200px;
    width: 100%;
    padding-left: 16px;
    padding-right: 16px;
    box-sizing: border-box;
}

body.dark-mode .forecast { border-top-color: #805ad5; }

/* Forecast Heading */
.forecast h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #805ad5;
    gap: 10px;
    transition: all 0.3s ease;
    justify-content: center;
    text-align: center;
}

body.dark-mode .forecast h3 { color: #805ad5; }

.forecast h3 i { transition: transform 0.3s ease; }

.forecast.active h3 i { transform: rotate(180deg); }

/* Forecast Cards Grid */
.forecast-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    justify-content: center;
    padding-bottom: 10px;
    animation: fadeIn 0.5s ease-out;
    margin: 0 auto;
}

/* Individual Forecast Card */
.forecast-card {
    background-color: transparent;
    border: 1.5px solid transparent;
    border-image: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    border-image-slice: 1;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
}

body.dark-mode .forecast-card { box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); }

.forecast-card:hover { transform: translateY(-2px); box-shadow: 0 0 15px rgba(49, 130, 206, 0.15); }

body.dark-mode .forecast-card:hover { box-shadow: 0 0 15px rgba(99, 179, 237, 0.15); }

/* Forecast Text Elements */
.forecast-day,
.forecast-temp,
.forecast-desc,
.detail-label,
.detail-value {
    font-weight: 600;
    font-size: 1rem;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Forecast Icon */
.forecast-icon { width: 80px; height: 80px; object-fit: contain; }

/* Forecast Detail Box */
.forecast-detail {
    background: transparent;
    border: 1.5px solid #805ad5;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    padding: 20px;
    margin-top: 20px;
    display: none;
    animation: fadeIn 0.5s ease-out;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Detail Row */
.detail-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1.3px solid #805ad5; }

body.dark-mode .detail-row { border-bottom-color: #805ad5; }

.detail-row:last-child { border-bottom: none; }

/* Footer with Gradient Border */
footer {
    text-align: center;
    padding: 25px;
    margin-top: 50px;
    background: transparent;
    font-size: 0.95rem;
    color: #4a5568;
    position: relative;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode footer { background:transparent; color: #a0aec0;  border-top: 1px solid rgba(255, 255, 255, 0.1); }

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3182ce 0%, #805ad5 100%);
}

body.dark-mode footer::before { background: linear-gradient(90deg, #63b3ed 0%, #9f7aea 100%); }

footer p { margin-bottom: 5px; }

footer a {
    color: #3182ce;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
}

body.dark-mode footer a { color: #63b3ed; }

footer a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: width 0.3s ease;
}

footer a:hover::after { width: 100%; }

/* Keyframe Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Dynamic Weather Classes */
.clear-sky { background: linear-gradient(135deg, #56ccf2 0%, #2f80ed 100%); }

body.dark-mode .clear-sky { background: linear-gradient(135deg, #1a3a8f 0%, #0d1b3a 100%); }

.clouds { background: linear-gradient(135deg, #bdc3c7 0%, #2c3e50 100%); }

body.dark-mode .clouds { background: linear-gradient(135deg, #4a5568 0%, #1a202c 100%); }

.rain { background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%); }

body.dark-mode .rain { background: linear-gradient(135deg, #2c3e50 0%, #0a1220 100%); }

.snow { background: linear-gradient(135deg, #e6e9f0 0%, #eef1f5 100%); }

body.dark-mode .snow { background: linear-gradient(135deg, #a0aec0 0%, #718096 100%); }

.thunderstorm { background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%); }

body.dark-mode .thunderstorm { background: linear-gradient(135deg, #0a1220 0%, #1a202c 50%, #2d3748 100%); }

.mist { background: linear-gradient(135deg, #606c88 0%, #3f4c6b 100%); }

body.dark-mode .mist { background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%); }

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid #3182ce;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

/* Animations */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ************************************** Responsive Design Code ***************************************** */

/* Tablets & small laptops */
@media (max-width: 992px) {
  .container { padding: 0 15px; }
    
  .card { padding: 20px; }

  .details { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    
}

/* Tablets & Big Phones */
@media (max-width: 768px) {
  header.navbar {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
  }

  .datetime-container { position: static; transform: none; margin: 0 15px; }

  .current-weather { flex-direction: column; text-align: center; }

  .weather-icon {  margin: 0 auto; }

  .details { grid-template-columns: 1fr 1fr; }

  .forecast h3 { font-size: 0.9rem; flex-direction: column; }

  .forecast-detail {  padding: 10px; }

  .forecast-card { padding: 8px 10px; }

  .forecast-icon { width: 60px; height: 60px; }

  .forecast-day,
  .forecast-temp,
  .forecast-desc { font-size: 0.8rem; }

  .temperature { font-size: 2.5rem; }

  .city { font-size: 1.4rem; }

  .search-bar { padding: 6px 10px; flex-direction: row; }

  .search-bar button { padding: 0 15px; height: 38px; font-size: 0.9rem; }
}

/* Mobile Phones */
@media (max-width: 576px) {
  .container { padding: 0 10px; }

  .card { padding: 15px; }

  .search-bar input { padding: 8px 10px; font-size: 0.9rem; }

  .forecast-icon { width: 30px; height: 30; }

  .forecast-day,
  .forecast-temp,
  .forecast-desc { font-size: 0.5rem; }

  .details { grid-template-columns: 1fr; }

  .temperature { font-size: 2.3rem; }

  .city { font-size: 1.3rem; }

  .forecast-cards { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
}

/* Mini Devices - 300px to 360px (Small Androids/iPhones) */
@media (max-width: 360px) {
  .forecast h3 { font-size: 0.6rem; text-align: center; }

  .forecast-cards { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));  gap: 6px; }

  .forecast-card { padding: 2px 2px; }

  .forecast-icon { width: 40px; height: 40px; }

  .forecast-day,
  .forecast-temp,
  .forecast-desc { font-size: 0.5rem; }

  .search-bar { flex-direction: column; gap: 6px; align-items: stretch; }

  .search-bar input { width: 100%; font-size: 0.85rem; }

  .search-bar button { width: 100%; padding: 8px; font-size: 0.85rem;}

  .temperature { font-size: 2rem; }

  .city { font-size: 1.2rem; }
}
