﻿/* =========================================================
   Layout shell: Sidebar + Main using CSS Grid
   Desktop: 2 dálkar
   Mobile: drawer sidebar + overlay
   Topbar: fixed (öruggara en sticky)
   ========================================================= */

/* ===== Checklist toolbar spacing (FIX) ===== */
.checklist-toolbar {
    display: flex !important;
    align-items: center !important;
    gap: 16px !important;
    flex-wrap: wrap !important;
}

.checklist-toggle {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
}

#listCount {
    margin-left: auto !important;
    padding: 6px 10px !important;
    border: 1px solid rgba(0,0,0,0.18) !important;
    border-radius: 999px !important;
    background: #f8fafc !important;
    font-size: 14px !important;
    white-space: nowrap !important;
}

/* (ATH) Þessi tvö blokk eru tvítekin við ofan. Ég læt þau vera (þú baðst um að eyða ekki),
   en þau verða "yfirskrifuð" af !important reglunum ofar. */
.checklist-toolbar {
    display: flex;
    align-items: center;
    gap: 20px;
}

    .checklist-toolbar label {
        font-weight: 500;
    }

#listCount {
    margin-left: auto;
    padding: 6px 12px;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid #d1d5db;
    font-size: 14px;
}

/* ===== Checklist toolbar spacing (FIX) endar ===== */

:root {
    --sidebar-bg: #1f2933;
    --sidebar-border: rgba(255,255,255,0.08);
    --text-soft: #9ca3af;
    --primary: #2563eb;
    --page-bg: #f2f4f6;
    --sidebar-w: 220px;
    --sidebar-w-md: 200px;
    --topbar-h: 56px;
}

/* Öryggi: tryggir fulla hæð og stöðugt layout */
html, body {
    height: 100%;
}

body {
    background: var(--page-bg);
    margin: 0;
}

/* =========================================================
   ✅ GLOBAL RULES (desktop + mobile)
   ========================================================= */



/* Modal basic (global) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 9999;
}

/* ATH: Hér er ".modal" generic. Í þínu editModal ertu að nota ".modal-box".
   Við látum þetta vera, en sértækari reglur neðar sjá um editModal. */
.modal {
    background: #fff;
    width: min(900px, 100%);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    overflow: hidden;
}

.modal-header, .modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-footer {
    border-bottom: 0;
    border-top: 1px solid #e5e7eb;
}

.modal-body {
    padding: 16px;
}

.modal-close {
    border: 0;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
}

/* ===== Layout container (DESKTOP/TABLET) ===== */
.app-shell {
    min-height: 100vh;
    width: 100%;
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    overflow-x: hidden;
    overflow-y: visible; /* ✅ sticky virkar ekki ef ancestor "klippir" */
}

/* ================= Sidebar ================= */
.sidebar {
    background: var(--sidebar-bg);
    color: #fff;
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 18px 16px;
    box-sizing: border-box;
    /* ✅ LÍMD Á DESKTOP */
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    align-self: start; /* mikilvægt í grid */
}


.sidebar-header {
    padding: 10px 10px 18px 10px;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 14px;
}

.brand {
    font-weight: 800;
    letter-spacing: 0.2px;
    font-size: 18px;
}

.brand-sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-soft);
}

.nav-section {
    margin-top: 14px;
}

.nav-title {
    font-size: 12px;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 10px 10px 8px 10px;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    margin: 4px 0;
}

.nav-link {
    display: block;
    padding: 10px 10px;
    border-radius: 10px;
    text-decoration: none;
    color: #fff;
    font-size: 14px;
}

    .nav-link:hover {
        background: rgba(255,255,255,0.10);
    }

.nav-item.is-active .nav-link {
    background: var(--primary);
}

.login-hint {
    margin: 14px 10px 0 10px;
    font-size: 12px;
    color: var(--text-soft);
    display: flex;
    align-items: center;
    gap: 8px;
}

    .login-hint .dot {
        width: 8px;
        height: 8px;
        background: #f59e0b;
        border-radius: 50%;
    }

/* ================= Main area ================= */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ===== TOPBAR (FIXED) ===== */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--topbar-h);
    z-index: 40;
    background: #ffffff;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
    padding: 0 18px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.topbar-title {
    font-weight: 700;
    font-size: 16px;
}

.topbar-actions {
    display: flex;
    gap: 10px;
}

.topbar-btn {
    border: none;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13px;
    cursor: pointer;
}

    .topbar-btn.ghost {
        background: #e5e7eb;
        color: #111827;
    }

    .topbar-btn:hover {
        filter: brightness(0.95);
    }

/* Þar sem topbar er fixed þarf main-inner að færa sig niður */
.main-inner {
    padding: 22px;
    padding-top: calc(22px + var(--topbar-h));
    min-width: 0;
}

/* Burger (sést bara á mobile) */
.burger {
    display: none;
    border: none;
    background: #e5e7eb;
    color: #111827;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 16px;
    cursor: pointer;
}

/* ================= Responsive ================= */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: var(--sidebar-w-md) minmax(0, 1fr);
    }

    .sidebar {
        width: var(--sidebar-w-md);
    }

    .topbar {
        left: var(--sidebar-w-md);
    }
}

/* ================= Mobile: sidebar drawer + overlay ================= */
@media (max-width: 720px) {
    .app-shell {
        display: block;
    }

    .burger {
        display: inline-flex;
    }

    /* Á mobile á topbar að ná fullri breidd */
    .topbar {
        left: 0;
        right: 0;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--sidebar-w);
        max-width: 85vw;
        transform: translateX(-110%);
        transition: transform 220ms ease;
        z-index: 1100;
        overflow-y: auto;
    }

    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }


    .app-shell::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.35);
        opacity: 0;
        pointer-events: none;
        transition: opacity 220ms ease;
        z-index: 1050;
    }

    .app-shell.sidebar-open::before {
        opacity: 1;
        pointer-events: auto;
    }

    /* (ATH) Sticky sidebar reglan var að stangast á við drawer - látum hana áfram óvirka */
    /*
    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
    }
    */

    /* Sort box eins og á index (ekki risa stórt) */
    .sort-box {
        max-width: 340px;
    }

        .sort-box select {
            width: 100%;
        }

    /* Modal basic (mobile) */
    .modal-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.35);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 16px;
        z-index: 9999;
    }

    .modal-box {
        background: #fff;
        width: min(900px, 100%);
        border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.25);
        overflow: hidden;
    }

    .modal-header, .modal-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        border-bottom: 1px solid #e5e7eb;
    }

    .modal-footer {
        border-bottom: 0;
        border-top: 1px solid #e5e7eb;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-close {
        border: 0;
        background: transparent;
        font-size: 18px;
        cursor: pointer;
    }
}

/* =========================================================
   ✅ Edit modal: tryggir að boxið verði "alvöru modal"
   ========================================================= */
#editModal.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 9999;
}

    #editModal.modal-overlay .modal-box {
        background: #fff;
        width: min(900px, 100%);
        max-height: 90vh;
        border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.25);
        overflow: auto;
    }

/* =========================================================
   ✅ Modal footer layout (Valkostur A)
   - Blár + Rauður hópur færist aðeins til vinstri (sama “edge-distance” og Hætta við)
   - Hætta við lengst til hægri
   ========================================================= */
.modal-footer-custom {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Hópurinn (Vista + Eyða) */
.modal-footer-center {
    display: flex;
    gap: 10px;
    /* Þetta færir hópinn frá vinstri eins og paddingið í footer (12px 16px) */
    margin-left: 16px;
    margin-right: auto;
}

    /* Jafnar stærð á Vista/Eyða inni í modal (án þess að rugla takka alls staðar) */
    .modal-footer-center .save-btn,
    .modal-footer-center .delete-btn {
        padding: 6px 12px;
        font-size: 14px;
        min-width: 150px; /* stilltu: 140px / 150px eftir smekk */
        text-align: center;
    }

/* Hætta við fer lengst til hægri */
.modal-footer-custom > .topbar-btn {
    margin-left: auto;
}

/* ✅ Mobile safety: ef verður þröngt */
@media (max-width: 520px) {
    .modal-footer-custom {
        flex-wrap: wrap;
    }

    .modal-footer-center {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    .modal-footer-custom > .topbar-btn {
        width: 100%;
    }
}
#editModalTitle .english-name,
#editModalTitle .scientific-name {
    font-size: 0.82em;
    opacity: 0.75;
}

#editModalTitle .name-sep {
    opacity: 0.55;
    margin: 0 6px;
}

/* ===== Stats overview (scoped) ===== */
.stats-overview .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.stats-overview .stat-item {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
}

    .stats-overview .stat-item div {
        font-size: 14px;
        color: #64748b;
        margin-bottom: 6px;
    }

    .stats-overview .stat-item strong {
        font-size: 28px;
        font-weight: 700;
        color: #0f172a;
    }
/* ===== Milestones (Persónuleg met) ===== */
.stats-milestones .milestones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 14px;
}

.stats-milestones .milestone-item {
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.10);
    border-radius: 12px;
    padding: 14px 14px;
}

.stats-milestones .milestone-label {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 6px;
}

.stats-milestones .milestone-item strong {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
}

.stats-milestones .milestone-sub {
    margin-top: 6px;
    font-size: 13px;
    opacity: 0.85;
}
/* =========================================
   FIX: Sticky sidebar on desktop
   Setja NEÐST í layout.css
   ========================================= */

/* 1) tryggja að viewport scroll sé á body */
html, body {
    height: 100%;
    overflow-y: auto; /* ✅ scroll á body */
    overflow-x: hidden; /* ✅ forðast lárétt */
}
/* 2-4) Sticky sidebar: BARA fyrir desktop/tablet (ekki mobile) */
@media (min-width: 721px) {
    /* 2) EKKI leyfa wrapperum að "klippa" sticky */
    .app-shell,
    .main,
    .main-inner {
        overflow: visible !important; /* ✅ sticky drepst ef parent overflow != visible */
    }

    /* 3) Grid: ekki teygja items á undarlegan hátt */
    .app-shell {
        align-items: start; /* ✅ mikilvægt í grid */
    }

    /* 4) Sticky sidebar (desktop/tablet) */
    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
        align-self: start; /* ✅ grid item */
    }
}

        Bæta fugli á lista ramminn
    Býr til meira pláss undir rammanum
   ========================================= */
#addBirdBox {
    margin-bottom: 40px;
}
/* =========================================
   Bæta fugli á lista ramminn ENDAR
   ========================================= */