﻿/* ================================
   Generic Modal (Watchlist and other modals)
   ================================ */

.modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: none; /* hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal.show {
    display: flex;
}

/* ================================
   Notification Panel Modal (Flækingavakt)
   ================================ */
#notificationPanelModal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6) !important;
    display: none !important; /* hidden by default */
    align-items: center !important;
    justify-content: center !important;
    z-index: 10000 !important;
}

#notificationPanelModal.show {
    display: flex !important;
}

#notificationPanelModal .modal-content {
    background: #ffffff;
    border-radius: 10px;
    padding: 20px 24px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    position: relative;
}

.modal .modal-content {
    background: #ffffff;
    border-radius: 10px;
    padding: 20px 24px;
    max-width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    position: relative;
}

.modal .close {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.modal .close:hover {
    color: #333;
}

@media (max-width: 640px) {
    .modal .modal-content {
        max-width: calc(100% - 24px);
    }
    
    #notificationPanelModal .modal-content {
        max-width: calc(100% - 24px);
        width: calc(100% - 24px);
    }
}

    /* ================================
   Edit Day List Modal (FULL OVERLAY)
   ================================ */

#editDayModal {
    position: fixed;
    inset: 0; /* top:0 right:0 bottom:0 left:0 */
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6); /* 🔥 dökkur bakgrunnur */
    display: none; /* stjórnað í JS */
    z-index: 10000;
    /* miðja modal-content */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Boxið sjálft */
#editDayModal .modal-content {
    background: #ffffff;
    border-radius: 10px;
    padding: 20px 24px;
    width: 100%;
    max-width: 400px;
    height: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

/* Smá mobile tweak */
@media (max-width: 640px) {
    #editDayModal .modal-content {
        margin: 12px;
        max-width: calc(100% - 24px);
    }
}

#editDayModal {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px); /* Safari */
}
/* Generic modal helpers — apply for any modal-overlay / modal-box elements */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0,0,0,.6);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

/* Fela autocomplete dropdown þegar modal er opinn */
.modal-overlay[style*="display: flex"] ~ * .autocomplete-items,
.modal-overlay[style*="display: flex"] ~ * #itemSpeciesList {
    display: none !important;
}

/* Fela autocomplete dropdown þegar sidebar er opinn (mobile) */
.app-shell.sidebar-open .autocomplete-items,
.app-shell.sidebar-open #itemSpeciesList {
    display: none !important;
}

.modal-box {
    width: min(900px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    background: #ffffff;
    color: #0f172a;
    border-radius: 12px;
    box-shadow: 0 18px 60px rgba(0,0,0,.45);
    border: 1px solid rgba(0,0,0,.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* =========================
   Stats modal (list-view)
   ========================= */

#statsModal.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    /* ✅ Dökkt “scrim” svo ekkert sjáist í gegn */
    background: rgba(0,0,0,.65);
    /* miðja box */
    display: none;
    align-items: center;
    justify-content: center;
    /* smá “safe” padding */
    padding: 12px;
}

/* boxið sjálft */
#statsModal .modal-box {
    width: min(1100px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    background: #ffffff; /* ✅ ekki gegnsætt */
    color: #0f172a;
    border-radius: 16px;
    box-shadow: 0 18px 60px rgba(0,0,0,.45);
    border: 1px solid rgba(0,0,0,.08);
    /* ✅ skipta modal í header / body / footer, body scrolar */
    display: flex;
    flex-direction: column;
    /* ef eitthvað fer úrskeiðis: klippa horn */
    overflow: hidden;
}

/* header */
#statsModal .modal-header {
    position: sticky;
    top: 0;
    background: #ffffff; /* ✅ svo header verði ekki gegnsær þegar scroll */
    z-index: 2;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0,0,0,.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

    #statsModal .modal-header h3 {
        margin: 0;
        font-size: 18px;
    }

/* close button */
#statsModal .modal-close {
    border: 0;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    opacity: .75;
}

    #statsModal .modal-close:hover {
        opacity: 1;
    }

/* body — hér á að scrola */
#statsModal .modal-body {
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* title */
#statsModal #statsModalTitle {
    margin: 2px 0 14px;
    text-align: center;
    opacity: .9;
}

/* ✅ NÝTT: stafli af chart-kortum (1 efst + mánuðir) */
#statsModal .stats-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
}

/* chart cards */
#statsModal .chart-card {
    background: #f8fafc;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 14px;
    padding: 12px;
}

#statsModal .chart-title {
    font-weight: 700;
    margin: 0 0 10px;
}

/* canvas hæð – Chart.js þarf fasta hæð */
#statsModal .chart-wrap {
    height: 260px;
    position: relative;
}

/* (valfrjálst) aðeins hærra á stórum skjáum */
@media (min-width: 900px) {
    #statsModal .chart-wrap {
        height: 320px;
    }
}

/* footer (ef þú vilt sticky footer líka, þá er þetta fín grunnstilling) */
#statsModal .modal-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(0,0,0,.08);
    background: #ffffff;
}

/* error */
#statsModal #statsModalErr {
    display: none; /* JS kveikir á þessu */
    margin: 10px 0 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(251,113,133,.14);
    border: 1px solid rgba(251,113,133,.35);
    color: #7f1d1d;
}

/* =============================
   Stats modal (list-view) ENDAR
   ============================= */

/* =========================
   Species History modal
   ========================= */

#speciesHistoryModal.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,.65);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

#speciesHistoryModal .modal-box {
    width: min(900px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    background: #ffffff;
    color: #0f172a;
    border-radius: 16px;
    box-shadow: 0 18px 60px rgba(0,0,0,.45);
    border: 1px solid rgba(0,0,0,.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* =========================
   Location modal (GPS)
   ========================= */

#locationModal.modal-overlay {
    z-index: 10001 !important; /* ✅ Ofan á öllum öðrum modölum */
    background: rgba(0,0,0,.75);
}

#locationModal .modal-box {
    width: min(800px, calc(100vw - 24px));
    max-width: 800px;
}
