/* --- Stil for Produktmodal --- */

/* Container og Laster */
#produkt-modal-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
}
#produkt-modal-container.aktiv {
    display: flex;
    align-items: center;
    justify-content: center;
}

.min-egendefinerte-produktliste .produkt-tittel {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%; /* For å være sikker */
}

.modal-laster {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1001;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Overlay (bakgrunn) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 21, 43, 0.91);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
    cursor: pointer;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Selve modal-boksen */
.modal-innhold {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    overflow: hidden; /* For å kontrollere scrolling internt */
    position: relative;
    animation: slideInUp 0.4s ease-out;
    cursor: auto;
    display: flex;
}
@keyframes slideInUp {
    from { transform: translateY(50px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Lukkeknapp */
.modal-lukk {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2.5rem;
    color: #888;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    transition: color 0.2s, transform 0.2s;
    z-index: 10;
}
.modal-lukk:hover {
    color: #333;
    transform: scale(1.1);
}

/* Grid for bilde og tekst */
.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
}

/* Bilde-seksjon */
.modal-bilde {
    background: #ffffff;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.modal-bilde .hoved-bilde {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    display: block;
    margin-bottom: 15px;
}

.modal-galleri-thumbnails {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
.modal-galleri-thumbnails img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, opacity 0.2s;
    opacity: 0.7;
}
.modal-galleri-thumbnails img:hover,
.modal-galleri-thumbnails img.aktiv {
    border-color: #2271b1; /* WordPress blåfarge */
    opacity: 1;
}


/* Tekst-seksjon */
.modal-tekst {
    padding: 40px;
    display: flex;
    background: #f2f8ff;
    flex-direction: column;
    overflow-y: auto; /* Gjør kun denne delen scrollbar ved behov */
    max-height: 90vh;
}
.modal-tekst h2 {
    margin-top: 0;
    font-size: 1.4rem;
    color: #333;
    line-height: 1.2;
}
.modal-tekst .kort-beskrivelse {
    font-size: 1.2rem;
    color: #666;
    margin-top: 0;
    padding-bottom: 0;
    border-bottom: 1px solid #eee;
}
.modal-tekst .kort-beskrivelse p {
    margin-top: 0;
}
.modal-tekst .lang-beskrivelse {
    margin-top: 5px;
    flex-grow: 1;
    color: #444;
    line-height: 1.6;
    font-weight: 500;
}
.modal-tekst .modal-knapp {
    margin-top: 20px;
}
.modal-tekst .modal-knapp .button {
    width: 100%;
    text-align: center;
    padding: 15px;
    font-size: 1.1rem;
    font-weight:600;
}

/* Responsivt design for mobil */
@media (max-width: 768px) {
    .modal-innhold {
       max-height: 85vh;
       flex-direction: column;
    }
    .modal-grid {
        grid-template-columns: 1fr;
        overflow-y: auto; /* Hele griden blir scrollbar */
    }
    .modal-bilde {
        padding: 15px;
        order: 1; /* Bilde øverst */
    }
    .modal-bilde .hoved-bilde {
        max-height: 300px;
    }
    .modal-tekst {
        padding: 30px 20px;
        max-height: none;
        order: 2; /* Tekst under */
    }
    .modal-lukk {
        color: #555;
        background-color: rgba(255,255,255,0.7);
        border-radius: 50%;
        width: 35px;
        height: 35px;
        font-size: 2rem;
        display: flex;
        align-items: center;
        justify-content: center;
        top: 5px;
        right: 5px;
    }
}

/* --- NYTT: Hindrer "Se listen"-knappen i å blinke --- */
.woocommerce a.added_to_cart {
    display: none !important;
}

/* --- Stil for Produktmodal --- */

/* Container og Laster */
#produkt-modal-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
}
#produkt-modal-container.aktiv {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99919191919;
}

.min-egendefinerte-produktliste .produkt-tittel {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
}

.modal-laster {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1001;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Overlay (bakgrunn) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 21, 43, 0.91);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
    cursor: pointer;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Selve modal-boksen */
.modal-innhold {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    animation: slideInUp 0.4s ease-out;
    cursor: auto;
    display: flex;
}
@keyframes slideInUp {
    from { transform: translateY(50px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Lukkeknapp */
.modal-lukk {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2.5rem;
    color: #888;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    transition: color 0.2s, transform 0.2s;
    z-index: 10;
}
.modal-lukk:hover {
    color: #333;
    transform: scale(1.1);
}

/* Grid for bilde og tekst */
.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
}

/* Bilde-seksjon */
.modal-bilde {
    background: #ffffff;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.modal-bilde .hoved-bilde {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    display: block;
    margin-bottom: 15px;
}

.modal-galleri-thumbnails {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
.modal-galleri-thumbnails img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, opacity 0.2s;
    opacity: 0.7;
}
.modal-galleri-thumbnails img:hover,
.modal-galleri-thumbnails img.aktiv {
    border-color: #2271b1;
    opacity: 1;
}

/* Tekst-seksjon */
.modal-tekst {
    padding: 40px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 90vh;
}
.modal-tekst h2 {
    margin-top: 0;
    margin-bottom: 5px; /* Litt luft under tittelen */
    font-size: 1.6rem;
    color: #333;
    line-height: 1.2;
}

/* NYTT: Stil for kategori-lenker */
.modal-kategori {
    font-size: 1rem;
    color: #777;
    margin-bottom: 15px;
}
.modal-kategori a {
    color: #2271b1;
    text-decoration: none;
    font-weight: 600;
}
.modal-kategori a:hover {
    text-decoration: underline;
}

.modal-tekst .kort-beskrivelse {
    font-size: 1.2em;
    color: #666;
    border-bottom: 1px solid #eee;
}
.modal-tekst .lang-beskrivelse {
    margin-top: 5px;
    flex-grow: 1;
    font-size: 1.1rem;
    color: #444;
    line-height: 1.6;
}
.modal-tekst .modal-knapp {
    margin-top: 20px;
}
.modal-tekst .modal-knapp .button {
    width: 100%;
    text-align: center;
    padding: 15px;
    font-size: 1rem;
font-weight: 600;
}

/* Responsivt design */
@media (max-width: 768px) {
    .modal-innhold {
       max-height: 85vh;
       flex-direction: column;
    }
    .modal-grid {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    .modal-bilde {
        padding: 15px;
        order: 1;
    }
    .modal-bilde .hoved-bilde {
        max-height: 300px;
    }
    .modal-tekst {
        padding: 30px 20px;
        max-height: none;
        order: 2;
    }
    .modal-lukk {
        color: #555;
        background-color: rgba(255,255,255,0.7);
        border-radius: 50%;
        width: 35px;
        height: 35px;
        font-size: 2rem;
        display: flex;
        align-items: center;
        justify-content: center;
        top: 5px;
        right: 5px;
    }
}

/* Diverse tillegg */
.woocommerce a.added_to_cart {
    display: none !important;
}

.knappe-container .button.loading,
.modal-knapp .button.loading {
    background-color: #d1d1d1 !important;
    color: transparent !important;
    position: relative;
    pointer-events: none;
    cursor: wait;
}

.knappe-container .button.loading::after,
.modal-knapp .button.loading::after {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -10px;
    margin-left: -10px;
}

.knappe-container .sm-fjern-fra-liste,
.modal-knapp .sm-fjern-fra-liste {
    background-color: #D32F2F;
    color: #ffffff;
    border-color: #D32F2F;
}

.knappe-container .sm-fjern-fra-liste:hover,
.modal-knapp .sm-fjern-fra-liste:hover {
    background-color: #B71C1C;
    border-color: #B71C1C;
    color: #ffffff;
}