/* ==========================================================================
   1. RESET E VARIÁVEIS
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root {
    --primary-color: #3b82f6;
    --transition-speed: 0.3s;
    --border-radius-lg: 28px;
    --border-radius-md: 14px;
}

/* ==========================================================================
   2. LAYOUT DO BODY E TEMAS DINÂMICOS
   ========================================================================== */
body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7fd8ff, #5aa9ff);
    transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1), color var(--transition-speed);
    padding: 20px;
    color: #1e293b;
}

/* Estados de Clima */
body.sunny  { background: linear-gradient(135deg, #fbbf24, #fde68a); }
body.cloudy { background: linear-gradient(135deg, #cbd5f5, #94a3b8); }
body.rainy  { background: linear-gradient(135deg, #64748b, #1e293b); }

/* Modo Noturno Unificado */
body.dark-mode {
    background: linear-gradient(135deg, #0f172a, #020617) !important;
    color: #ffffff !important;
}

/* ==========================================================================
   3. CONTAINER PRINCIPAL (APP)
   ========================================================================== */
.app {
    position: relative;
    width: 100%;
    max-width: 450px;
    padding: 50px 35px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-lg);
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.1);
    animation: fadeUp 0.8s ease-out;
}

body.dark-mode .app {
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.app h1 { margin-bottom: 35px; }

/* ==========================================================================
   4. INPUTS E BOTÕES DE BUSCA
   ========================================================================== */
input {
    width: 100%;
    padding: 16px;
    margin-bottom: 20px;
    border-radius: var(--border-radius-md);
    border: 1px solid #ddd;
    outline: none;
    transition: var(--transition-speed);
}

body.dark-mode input {
    background: #1e293b;
    border-color: #334155;
    color: white;
}

/* Grupo de Botões (Buscar + Estrela) */
.button-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-bottom: 35px;
}

button {
    border: none;
    cursor: pointer;
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

button:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

#searchBtn {
    flex-grow: 1;
    height: 55px;
    font-size: 16px;
    font-weight: 700;
    border-radius: var(--border-radius-md);
}

#saveCity {
    flex-grow: 0;
    width: 65px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: var(--border-radius-md);
}

/* ==========================================================================
   5. INTERFACE DE CLIMA (RESULTADOS)
   ========================================================================== */
.main-icon {
    font-size: 80px;
    margin: 20px 0;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.1));
}

.temp {
    font-size: 38px;
    font-weight: 800;
    margin-bottom: 30px;
}

.weather-details {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 18px;
    margin-bottom: 30px;
}

body.dark-mode .weather-details { background: rgba(255, 255, 255, 0.08); }

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 14px;
}

.detail-item strong { font-size: 16px; }

/* Carrossel Horário */
.hourly-forecast {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding: 15px 0;
    scrollbar-width: none;
}

.hour-item {
    flex: 0 0 75px;
    padding: 15px 10px;
    background: rgba(0,0,0,0.03);
    border-radius: 16px;
    text-align: center;
}

body.dark-mode .hour-item { background: rgba(255,255,255,0.05); }

/* Previsão Diária */
.forecast {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 15px;
}

.day {
    padding: 15px 5px;
    border-radius: 16px;
    background: rgba(0,0,0,0.02);
}

/* ==========================================================================
   6. FAVORITOS E DARK MODE TOGGLE
   ========================================================================== */
#toggleDark {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 46px;
    height: 46px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: float 3s ease-in-out infinite;
    z-index: 10;
}

body.dark-mode #toggleDark { background: #334155; }
#toggleDark.animate { transform: rotate(360deg) scale(1.2); }

/* Pílulas de Favoritos */
.fav-wrapper {
    display: inline-flex;
    align-items: center;
    position: relative;
    margin: 5px;
}

.fav-btn {
    padding: 10px 35px 10px 15px !important;
    border-radius: 25px;
    font-weight: 600;
    text-transform: lowercase;
}

body.dark-mode .fav-btn {
    background: #2d3748 !important;
    color: #ffffff !important;
}

.remove-fav {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.1);
    color: inherit;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
}

body.dark-mode .remove-fav { background: rgba(255, 255, 255, 0.2); }

/* ==========================================================================
   7. SKELETON SCREEN
   ========================================================================== */
.skeleton-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.skeleton {
    background: #eee;
    background: linear-gradient(90deg, #ececec 8%, #f5f5f5 18%, #ececec 33%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 10px;
    margin-bottom: 15px;
}

body.dark-mode .skeleton {
    background: #2c3e50;
    background: linear-gradient(90deg, #2c3e50 8%, #3e5871 18%, #2c3e50 33%);
}

.skeleton-text-title { width: 60%; height: 25px; }
.skeleton-icon { width: 80px; height: 80px; border-radius: 50%; }
.skeleton-text-temp { width: 40%; height: 35px; }

/* ==========================================================================
   8. ANIMAÇÕES
   ========================================================================== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeUp 0.5s ease-in; }

/* Cores Dinâmicas por Temperatura */
body.cold { 
    background: linear-gradient(135deg, #3a7bd5, #00d2ff) !important; 
}
body.mild { 
    background: linear-gradient(135deg, #00b09b, #96c93d) !important; 
}
body.warm { 
    background: linear-gradient(135deg, #f83600, #f9d423) !important; 
}
body.hot { 
    background: linear-gradient(135deg, #ff416c, #ff4b2b) !important; 
}

/* Garante que o Modo Noturno ainda funcione sobrepondo as cores acima */
body.dark-mode {
    background: linear-gradient(135deg, #0f172a, #020617) !important;
    color: #ffffff !important;
}

/* Suaviza a transição de uma cor para outra */
body {
    transition: background 0.8s ease-in-out, color 0.3s;
}