/**
 * MAPPE: /assets/css/base/
 * FIL: mobile.css
 * VERSION: 2.0
 * 
 * BRUGES AF: ALLE sider (kun på mobile enheder)
 * 
 * INDLÆSES MED:
 * <link rel="stylesheet" href="/assets/css/base/mobile.css" media="(max-width: 768px)">
 * 
 * BESKRIVELSE:
 * Globalt mobile-fundament. Denne fil loader KUN på enheder ≤768px.
 * Desktop-browsere ignorerer den fuldstændigt.
 * 
 * AFHÆNGIGHEDER:
 * - /assets/css/base/variables.css
 */

/* ============================================
   1. MOBILE CSS VARIABLER
   ============================================ */

:root {
    --mobile-bottom-nav-height: 60px;
    --mobile-header-height: 52px;
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    --mobile-touch-min: 44px;
}

/* ============================================
   2. SAFE AREA & BODY
   ============================================ */

html, body {
    overflow-x: hidden;
    width: 100%;
}

body {
    padding-bottom: calc(var(--mobile-bottom-nav-height) + var(--mobile-safe-bottom) + 8px) !important;
}

/* ============================================
   3. TOUCH TARGETS
   ============================================ */

a, button, input[type="submit"], input[type="button"],
select, .btn-primary, .btn-secondary, .btn-danger {
    min-height: var(--mobile-touch-min);
}

/* Links i løbende tekst behøver ikke min-height */
p a, li a, td a, span a, .footer-sektion a,
.breadcrumb a, .breadcrumb span,
.produkt-card-info a, .butik-kort a {
    min-height: auto;
}

/* ============================================
   4. TYPOGRAPHY
   ============================================ */

body {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

input, textarea, select {
    font-size: 16px !important;
}

/* ============================================
   5. CONTAINER
   ============================================ */

.container {
    padding-left: var(--spacing-sm, 1rem);
    padding-right: var(--spacing-sm, 1rem);
}

/* ============================================
   6. NAVIGATION — SKJUL DESKTOP + BURGER
   ============================================ */

.navigation {
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-indhold {
    grid-template-columns: 1fr;
    padding: 8px 0;
    min-height: var(--mobile-header-height);
    justify-items: start;
}

.nav-center {
    display: none !important;
}

.nav-right {
    display: none !important;
}

.desktop-nav {
    display: none !important;
}

/* SKJUL burger-menu — bottom nav erstatter den */
.burger-btn {
    display: none !important;
}

.mobile-menu {
    display: none !important;
}

/* SKJUL feedback-knap i top-header */
.nav-left .feedback-btn {
    display: none !important;
}

/* SKJUL skift-by link i top-header */
.skift-by-link {
    display: none !important;
}

/* Logo — brug px for konsistens med logo.css */
.logo {
    font-size: 22px;
}

.by-navn {
    font-size: 14px;
}

/* ============================================
   7. BOTTOM NAVIGATION BAR
   ============================================ */

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: var(--surface);
    border-top: 1px solid var(--gray-200);
    padding-bottom: var(--mobile-safe-bottom);
    box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s ease;
    will-change: transform;
    backface-visibility: hidden;
}

.mobile-bottom-nav-inner {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: var(--mobile-bottom-nav-height);
    max-width: 500px;
    margin: 0 auto;
}

.mobile-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--gray-500);
    font-size: 0.625rem;
    font-weight: 500;
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 2px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease;
    letter-spacing: 0.01em;
    font-family: inherit;
}

.mobile-bottom-nav-item:active {
    color: var(--tekst, #111827);
}

/* Aktiv fane: brug --tekst (tema-adaptiv forgrund: mørk på lys / lys på mørk,
   AA-kontrast i begge temaer) + orange brand-signal via ikon. BEMÆRK: brug ALDRIG
   --primær her — den er ikke tema-redefineret og blev derfor usynlig (mørk-på-mørk)
   i dark mode. Orange tekst-label var kun ~3:1 på hvid → WCAG-fejl, derfor ikon-only. */
.mobile-bottom-nav-item.active {
    color: var(--tekst, #111827);
    font-weight: 600;
}

.mobile-bottom-nav-item.active svg {
    stroke: var(--accent, #FF6B30);
}

/* A11y: synligt keyboard-fokus */
.mobile-bottom-nav-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
}

.mobile-bottom-nav-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
    flex-shrink: 0;
}

.mobile-bottom-nav-item .nav-label {
    line-height: 1;
    white-space: nowrap;
}

.mobile-bottom-nav-item .nav-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-bottom-nav-item .bottom-nav-badge {
    position: absolute;
    top: -5px;
    right: -10px;
    background: var(--fejl);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: var(--radius-md);
    padding: 0 4px;
}

/* User-select off på nav */
.mobile-bottom-nav,
.mobile-bottom-nav-item {
    -webkit-user-select: none;
    user-select: none;
}

/* ============================================
   8. KONTO BOTTOM SHEET
   ============================================ */

.mobile-sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
}

.mobile-sheet-overlay.open {
    display: block;
    background: rgba(0, 0, 0, 0.4);
}

.mobile-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1101;
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: var(--mobile-safe-bottom);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-sheet-overlay.open .mobile-sheet {
    transform: translateY(0);
}

.mobile-sheet-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 4px;
    cursor: grab;
}

.mobile-sheet-handle span {
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: var(--radius-sm);
}

.mobile-sheet-content {
    padding: 4px 20px 24px;
}

/* Bruger info */
.sheet-bruger-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0 16px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 8px;
}

.sheet-bruger-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primær, #0D1B2A);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sheet-bruger-navn {
    font-weight: 600;
    color: var(--tekst);
    font-size: 1rem;
}

.sheet-bruger-email {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 2px;
}

/* Menu items */
.sheet-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 8px;
    color: var(--tekst);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    min-height: var(--mobile-touch-min);
    transition: background 0.12s ease;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.sheet-menu-item:active {
    background: var(--gray-100);
}

.sheet-menu-item svg {
    width: 20px;
    height: 20px;
    color: var(--gray-500);
    flex-shrink: 0;
}

.sheet-menu-item .sheet-badge {
    margin-left: auto;
    background: var(--fejl, #e74c3c);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: var(--radius-md);
    padding: 0 6px;
}

.sheet-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 6px 0;
}

.sheet-menu-item.logout {
    color: var(--fejl, #e74c3c);
}

.sheet-menu-item.logout svg {
    color: var(--fejl, #e74c3c);
}

/* Guest section (ikke logget ind) */
.sheet-guest-section {
    text-align: center;
    padding: 16px 0 8px;
}

.sheet-guest-icon {
    margin-bottom: 12px;
}

.sheet-guest-text {
    color: var(--gray-500);
    margin-bottom: 20px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.sheet-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px;
    background: var(--accent, #FF6B30);
    color: var(--tekst-paa-accent) !important;
    text-align: center;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    min-height: var(--mobile-touch-min);
}

.sheet-login-btn:active {
    background: var(--accent-hover);
}

.sheet-register-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px;
    text-align: center;
    color: var(--sekundær, #2563EB) !important;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    margin-top: 8px;
    min-height: var(--mobile-touch-min);
}

/* ============================================
   9. BREADCRUMBS
   ============================================ */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 10px 0;
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.breadcrumb::-webkit-scrollbar {
    display: none;
}

.breadcrumb a {
    color: var(--sekundær, #2563EB);
    text-decoration: none;
    flex-shrink: 0;
}

.breadcrumb > span {
    flex-shrink: 0;
}

/* Sidste element (current page) kan trunceres */
.breadcrumb > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 45vw;
}

/* ============================================
   10. GRIDS
   ============================================ */

.butikker-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md, 1.5rem);
}

.produkter-grid,
.produkt-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm, 1rem);
}

.stats-grid {
    grid-template-columns: repeat(2, 1fr);
}

.dashboard-grid,
.by-grid {
    grid-template-columns: 1fr;
}

/* ============================================
   11. CARDS
   ============================================ */

.butik-kort {
    padding: var(--spacing-md, 1.5rem);
}

.butik-kort img,
.butik-kort .butik-logo img {
    height: 160px;
}

.produkt-card img,
.produkt-billede {
    height: 140px;
}

.produkt-card-info {
    padding: var(--spacing-sm, 1rem);
}

.produkt-card h4 {
    font-size: 0.9rem;
}

/* ============================================
   12. TABELLER
   ============================================ */

/* Standard tabeller: horisontal scroll */
table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Tabel-til-kort pattern: brug klassen .mobile-cards på <table> */
table.mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-x: visible;
    border: none;
    background: transparent;
}
table.mobile-cards thead { display: none; }
table.mobile-cards tbody {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
table.mobile-cards tbody tr {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    padding: 1rem;
    gap: 0.375rem;
    box-shadow: var(--shadow-xs);
}
table.mobile-cards tbody tr:hover {
    background: var(--surface);
}
table.mobile-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.125rem 0;
    border: none;
    font-size: 0.9rem;
    gap: 0.5rem;
}
table.mobile-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--gray-500);
    font-size: 0.8rem;
    flex-shrink: 0;
    min-width: 35%;
}
/* Handlings-cellen: fuld bredde knap */
table.mobile-cards td.handlinger,
table.mobile-cards td:last-child:has(.btn-primary, .btn-lille, a[href]) {
    justify-content: stretch;
    margin-top: 0.375rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--gray-100);
}
table.mobile-cards td.handlinger a,
table.mobile-cards td.handlinger button {
    flex: 1;
    text-align: center;
}

/* ============================================
   13. MODALS → BOTTOM SHEETS
   ============================================ */

.modal-content {
    width: 95%;
    margin: 5% auto;
    padding: var(--spacing-md, 1.5rem);
}

.modal-handlinger {
    flex-direction: column;
}

/* Byvalg modal → bottom sheet */
#byvalg-modal .modal-content {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    transform: none;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 85vh;
    width: 100%;
    max-width: 100%;
    animation: mobileSheetUp 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: calc(16px + var(--mobile-safe-bottom));
    margin: 0;
}

@keyframes mobileSheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Feedback modal → bottom sheet */
.feedback-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
}

.feedback-modal-v2 {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
    max-height: 90vh !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    animation: mobileSheetUp 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

/* ============================================
   14. FORMS
   ============================================ */

.form-handlinger {
    flex-direction: column;
}

.form-handlinger .btn-primary,
.form-handlinger .btn-secondary {
    width: 100%;
    text-align: center;
}

.form-actions {
    flex-direction: column;
}

.form-actions button {
    width: 100%;
}

/* Form grids: altid 1 kolonne på mobil */
.form-grid,
.form-row {
    grid-template-columns: 1fr !important;
}

/* ============================================
   14b. KNAPPER
   ============================================ */

.btn-fuld {
    width: 100%;
}

/* ============================================
   14c. HEADER-STACKING (butiksejersider)
   ============================================ */

.top-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch !important;
}

.top-header .header-left,
.top-header .header-right {
    width: 100%;
}

.header-actions,
.top-header .header-right {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.header-actions > a,
.header-actions > button,
.top-header .header-right > a,
.top-header .header-right > button {
    flex: 1;
    min-width: 0;
    text-align: center;
    justify-content: center;
    white-space: nowrap;
    font-size: 0.85rem;
}

/* ============================================
   14c2. ADMIN-HEADER STACKING (ordrer, lager, produkter osv.)
   ============================================ */

.admin-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem;
}

.admin-header h1 {
    font-size: 1.5rem;
}

.admin-header .butik-navn {
    font-size: 0.85rem;
}

.header-handlinger,
.admin-header > div:last-child {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.header-handlinger > a,
.header-handlinger > button {
    flex: 1;
    text-align: center;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

/* Stats-kort grid (ordrer, dashboard) */
.ordre-statistik,
.stats-oversigt {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem;
}

.stat-kort {
    padding: 1rem;
}

.stat-værdi {
    font-size: 1.5rem;
}

/* Variant-rækker kompakt */
.variant-row td:first-child {
    padding-left: 1rem !important;
}

/* ============================================
   14d. SIDEBAR → HORISONTAL SCROLL (indstillinger)
   ============================================ */

.sidebar-nav,
.side-nav {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.25rem;
    padding-bottom: 0.5rem;
}

.sidebar-nav::-webkit-scrollbar,
.side-nav::-webkit-scrollbar {
    display: none;
}

.sidebar-nav .nav-item,
.side-nav .nav-item,
.sidebar-nav a,
.side-nav a {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    min-height: var(--mobile-touch-min);
    display: flex;
    align-items: center;
}

/* ============================================
   15. FOOTER
   ============================================ */

.footer-indhold {
    grid-template-columns: 1fr;
    gap: var(--spacing-md, 1.5rem);
}

/* ============================================
   16. GENERELLE FORBEDRINGER
   ============================================ */

html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

* {
    -webkit-tap-highlight-color: rgba(255, 107, 48, 0.08);
}

img {
    max-width: 100%;
    height: auto;
}

.desktop-only {
    display: none !important;
}

.mobile-only {
    display: block !important;
}

/* ============================================
   17. BY FORSIDE SPECIFIK
   ============================================ */

.page-header {
    padding: 1.5rem 0 2rem;
}

.page-header h1 {
    font-size: 1.6rem;
}

.page-header-description {
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

/* Tag chips scrollbar horisontalt */
.filter-chips,
.tag-filter-container {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}

.filter-chips::-webkit-scrollbar,
.tag-filter-container::-webkit-scrollbar {
    display: none;
}

.section-header {
    flex-direction: column;
    gap: 0.75rem;
}

/* ============================================
   18. ALERTS
   ============================================ */

.alert {
    font-size: 0.9rem;
    padding: 10px 14px;
}

/* ============================================
   19. TELEFON (≤480px)
   ============================================ */

@media (max-width: 480px) {
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .produkter-grid,
    .produkt-grid {
        gap: 8px;
    }

    .produkt-card img,
    .produkt-billede {
        height: 120px;
    }

    .produkt-card-info {
        padding: 8px;
    }

    .produkt-card h4 {
        font-size: 0.8rem;
    }

    .butik-kort img,
    .butik-kort .butik-logo img {
        height: 130px;
    }

    .breadcrumb {
        font-size: 0.75rem;
    }

    .page-header h1 {
        font-size: 1.4rem;
    }

    /* Padding-reduktion på små telefoner */
    .card-body,
    .section-body {
        padding: 1rem;
    }

    .main-content {
        padding: 1rem 0.75rem;
    }

    /* Stats-grid: 2 kolonner selv på telefon */
    .stats-grid {
        gap: 0.5rem;
    }

    .stats-grid .stat-card {
        padding: 0.75rem;
    }

    /* Header-knapper: kompakt */
    .header-actions > a,
    .header-actions > button,
    .top-header .header-right > a,
    .top-header .header-right > button {
        font-size: 0.8rem;
        padding: 0.5rem 0.5rem;
    }

    /* Admin-header kompakt */
    .admin-header h1 {
        font-size: 1.3rem;
    }

    .stat-kort {
        padding: 0.75rem;
    }

    .stat-værdi {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }
}
/* PWA standalone (UX task 06): dæmp rubber-band/pull-to-refresh i installeret
   app — browser-fanen beholder normal opførsel */
@media (display-mode: standalone) {
    html, body {
        overscroll-behavior-y: contain;
    }
}
