/* ========================================================================
   NordicWeather - landing-page.css
   Landing page med NWmobil-design och NWpaint-struktur
   ======================================================================== */

/* Huvudcontainer för landing page med blå gradient - täcker hela skärmen */
.landing-page-container {
    min-height: 100vh;
    background: linear-gradient(180deg, #4A90E2 0%, #5BA3F5 50%, #6BB6FF 100%);
    padding: 2rem 1rem 4rem 1rem;
    position: relative;
    /* Bryt ut från .container med negativa marginaler */
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
}

/* Sätt blå bakgrund på body när landing page visas */
body:has(.landing-page-container) {
    background: linear-gradient(180deg, #4A90E2 0%, #5BA3F5 50%, #6BB6FF 100%) !important;
    overflow-x: hidden;
}

/* Justera header på landing page - blå bakgrund som smälter in */
body:has(.landing-page-container) .site-header {
    margin-bottom: 0 !important;
    box-shadow: none !important;
    background: linear-gradient(180deg, rgba(50, 110, 180, 0.4) 0%, rgba(60, 120, 190, 0.3) 100%) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

/* Styla brand text i header på landing page */
body:has(.landing-page-container) .site-header .brand-nordic {
    color: white !important;
}

body:has(.landing-page-container) .site-header .brand-weather {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* Styla navigation menu button på landing page */
body:has(.landing-page-container) .site-header .nav-menu-button {
    background: rgba(255, 255, 255, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

body:has(.landing-page-container) .site-header .nav-menu-button svg {
    stroke: white !important;
}

body:has(.landing-page-container) .site-header .nav-menu-button:hover {
    background: rgba(255, 255, 255, 0.25) !important;
}

/* Styla sökrutan i header på landing page */
body:has(.landing-page-container) .site-header .header-search-input {
    background: rgba(255, 255, 255, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: white !important;
    backdrop-filter: blur(10px);
}

body:has(.landing-page-container) .site-header .header-search-input::placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
}

body:has(.landing-page-container) .site-header .header-search-input:focus {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
}

body:has(.landing-page-container) .site-header .header-search-icon {
    stroke: rgba(255, 255, 255, 0.8) !important;
}

/* Ta bort padding/margin från site-main och container på landing page */
body:has(.landing-page-container) .site-main {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
}

body:has(.landing-page-container) .site-main .container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    background: transparent !important;
}

/* Ta bort eventuella margins/paddings på body och html */
body:has(.landing-page-container),
html:has(.landing-page-container) {
    margin: 0 !important;
    padding: 0 !important;
}

/* Styla footer på landing page - smält in i blå bakgrunden */
body:has(.landing-page-container) .site-footer {
    background: linear-gradient(180deg, rgba(42, 80, 150, 0.3) 0%, rgba(30, 60, 120, 0.5) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    margin-top: 0 !important; /* Ta bort margin-top */
}

body:has(.landing-page-container) .site-footer .footer-brand {
    color: white;
}

body:has(.landing-page-container) .site-footer .footer-tagline {
    color: rgba(255, 255, 255, 0.8);
}

body:has(.landing-page-container) .site-footer h4 {
    color: rgba(255, 255, 255, 0.95);
}

body:has(.landing-page-container) .site-footer .footer-links a {
    color: rgba(255, 255, 255, 0.85);
}

body:has(.landing-page-container) .site-footer .footer-links a:hover {
    color: white;
}

body:has(.landing-page-container) .site-footer .footer-copyright,
body:has(.landing-page-container) .site-footer .data-attribution {
    color: rgba(255, 255, 255, 0.7);
}

body:has(.landing-page-container) .site-footer .brand-nordic {
    color: white;
}

body:has(.landing-page-container) .site-footer .brand-weather {
    color: rgba(255, 255, 255, 0.9);
}

/* Header med NordicWeather-logga och sökfält */
.landing-header {
    max-width: 1400px;
    margin: 0 auto 2rem auto;
    padding: 0 1rem;
}

.landing-title {
    color: white;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: left;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Ny design badge */
.new-design-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: rgba(231, 76, 60, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
    animation: subtle-pulse 3s ease-in-out infinite;
}

@keyframes subtle-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
    }
    50% {
        transform: scale(1.03);
        box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
    }
}

/* Landing header content */
.landing-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

/* Settings controls */
.settings-control {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.favorites-count-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.favorites-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    white-space: nowrap;
}

.favorites-select {
    width: auto;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.favorites-select:hover {
    background: rgba(255, 255, 255, 0.25);
}

.edit-mode-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.edit-mode-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Sökfält på landing page */
.landing-search {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.landing-search input {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.landing-search input:focus {
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Grid för stadskort - dynamisk layout beroende på antal kort */
.cities-grid {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Default: 2 kolumner */
    gap: 1.5rem;
    padding: 0 1rem;
}

/* Layout för 1 kort - ett stort centrerat kort */
.cities-grid:has(.city-weather-card:only-child) {
    grid-template-columns: 1fr;
    max-width: 500px;
}

/* Layout för 2 kort - 1x2 grid */
.cities-grid:has(.city-weather-card:nth-child(2):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
    max-width: 1000px;
}

/* Layout för 3 kort - 1 stor upptill, 2 mindre under */
.cities-grid:has(.city-weather-card:nth-child(3):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
}

.cities-grid:has(.city-weather-card:nth-child(3):nth-last-child(1)) .city-weather-card:first-child {
    grid-column: 1 / -1; /* Första kortet tar hela bredden */
}

/* Layout för 4+ kort - alltid 2x2, 3x2, eller 4x2 grid */
.cities-grid:has(.city-weather-card:nth-child(4)),
.cities-grid:has(.city-weather-card:nth-child(5)),
.cities-grid:has(.city-weather-card:nth-child(6)),
.cities-grid:has(.city-weather-card:nth-child(7)),
.cities-grid:has(.city-weather-card:nth-child(8)) {
    grid-template-columns: repeat(2, 1fr);
}

/* Fallback om :has() inte stöds */
@supports not (selector(:has(*))) {
    .cities-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Individuellt stadskort - design från NWmobil */
.city-weather-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.city-weather-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Stadnamn med ikon */
.city-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.city-name {
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.home-icon {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
}

/* Väderikon och huvudinfo */
.city-main-weather {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
}

.city-weather-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.city-temperature {
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

.city-weather-desc {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    margin: 0.5rem 0;
    text-align: center;
}

/* Vindinformation */
.city-wind-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.wind-arrow {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

/* TIS/ONS mini-kort */
.city-forecast-mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.forecast-day-mini {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
}

.forecast-day-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.forecast-day-icon {
    width: 32px;
    height: 32px;
    margin: 0.25rem auto;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.15));
}

.forecast-day-temp {
    color: white;
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

/* Laddningsindikator */
.loading-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Felkort för städer som inte kunde hämta väderdata */
.city-weather-card.error-card {
    background: rgba(220, 53, 69, 0.2);
    border: 1px solid rgba(220, 53, 69, 0.4);
    cursor: default;
}

.city-weather-card.error-card:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Responsiv design */
@media (max-width: 768px) {
    .landing-page-container {
        padding: 1rem 0.5rem;
    }

    .landing-title {
        font-size: 1.5rem;
        text-align: center;
        justify-content: center;
    }

    .landing-header-content {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    .settings-control {
        gap: 8px;
        width: 100%;
        justify-content: center;
        position: relative !important;
        flex-direction: row !important;
        align-items: center !important;
    }

    .favorites-label {
        display: none;
    }

    .favorites-select,
    .edit-mode-btn {
        font-size: 0.8rem;
        padding: 5px 10px;
    }

    .cities-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        padding: 0 0.5rem;
    }

    .city-weather-card {
        padding: 1.25rem;
    }
}

/* För ännu mindre skärmar */
@media (max-width: 480px) {
    .new-design-badge {
        font-size: 0.6rem;
        padding: 3px 8px;
    }

    .settings-control {
        gap: 6px;
    }

    .favorites-select,
    .edit-mode-btn {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}

/* För större skärmar - behåll kompakt */
@media (min-width: 1200px) {
    .landing-header-content {
        max-width: 1400px;
        margin: 0 auto;
    }
}

@media (min-width: 769px) {
    .cities-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Animationer */
.city-weather-card {
    animation: fadeInUp 0.6s ease forwards;
}

.city-weather-card:nth-child(1) { animation-delay: 0.1s; }
.city-weather-card:nth-child(2) { animation-delay: 0.2s; }
.city-weather-card:nth-child(3) { animation-delay: 0.3s; }
.city-weather-card:nth-child(4) { animation-delay: 0.4s; }
.city-weather-card:nth-child(5) { animation-delay: 0.5s; }
.city-weather-card:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Säkerställ att korten är synliga efter animation */
.city-weather-card.loaded {
    opacity: 1 !important;
}
/* ========================================================================
   FAVORITES MANAGEMENT - Edit Mode, Undo Toast, Micro-feedback
   ======================================================================== */

/* Edit Mode Styling */
.city-weather-card.edit-mode {
    border: 2px dashed rgba(255, 255, 255, 0.5);
    cursor: default !important;
    pointer-events: none;
}

.city-weather-card.edit-mode .remove-favorite-btn {
    pointer-events: all;
}

/* Shake Animation - som iPhone när man håller ner en app */
@keyframes shake {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    25% {
        transform: translateX(-2px) rotate(-1deg);
    }
    75% {
        transform: translateX(2px) rotate(1deg);
    }
}

.city-weather-card.shake-animation {
    animation: shake 0.5s ease-in-out infinite; /* Skaka kontinuerligt tills edit-mode avslutas */
}

/* Remove Button (X) */
.remove-favorite-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 32px;
    height: 32px;
    background: rgba(255, 50, 50, 0.9);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.remove-favorite-btn:hover {
    background: rgba(255, 20, 20, 1);
    transform: scale(1.1);
}

/* Min Plats (First Card) Styling */
.city-weather-card.my-location {
    border: 2px solid rgba(255, 215, 0, 0.4);
    background: rgba(255, 255, 255, 0.2);
}

.my-location-badge {
    font-size: 0.75rem;
    color: rgba(255, 215, 0, 1);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 0.25rem;
}

/* Undo Toast */
.undo-toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.95);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transition: bottom 0.3s ease;
    backdrop-filter: blur(10px);
}

.undo-toast.show {
    bottom: 30px;
}

.undo-btn {
    background: rgba(74, 144, 226, 0.9);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.undo-btn:hover {
    background: rgba(74, 144, 226, 1);
    transform: scale(1.05);
}

/* Micro-feedback när stad läggs till */
.favorite-added-feedback {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(50, 200, 100, 0.95);
    color: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transition: top 0.3s ease;
    backdrop-filter: blur(10px);
}

.favorite-added-feedback.show {
    top: 30px;
}

/* Förbättrade hover-animationer */
.city-weather-card:not(.edit-mode):hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.city-weather-card:not(.edit-mode):hover .city-temperature {
    font-size: 2.6rem;
    transition: font-size 0.2s ease;
}

.city-weather-card:not(.edit-mode):hover .city-weather-icon {
    transform: scale(1.1);
    transition: transform 0.2s ease;
}

/* REMOVE DUPLICATE - redan hanterad ovan */

/* Tillbaka till favoriter-länk */
.back-to-favorites-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: rgba(74, 144, 226, 0.1);
}

.back-to-favorites-link:hover {
    background: rgba(74, 144, 226, 0.2);
    transform: translateX(-4px);
    color: var(--primary-color);
}

.back-to-favorites-link svg {
    transition: transform 0.2s ease;
}

.back-to-favorites-link:hover svg {
    transform: translateX(-2px);
}
