/* ============================================================
   FAMILIEMADPLAN – STYLE.CSS
   Komplet stylesheet – dashboard, indkøbsliste, drag & drop
   ============================================================ */

/* ---------- CSS VARIABLER ---------- */
:root {
    --primary-color: #6d4aff;
    --primary-dark: #5535cc;
    --primary-light: #a78bfa;
    --bg-body: #f4f4f8;
    --bg-white: #ffffff;
    --bg-light: #f0ecfb;
    --text-primary: #2d2a3e;
    --text-secondary: #6b6879;
    --border-color: #e2e0ea;
    --success-color: #16a34a;
    --success-bg: #e8f7ee;
    --error-color: #dc2626;
    --error-bg: #fdeaea;
    --info-color: #2563eb;
    --info-bg: #e8f0fd;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(45, 42, 62, 0.08);
    --shadow-md: 0 4px 12px rgba(45, 42, 62, 0.12);
    --transition-fast: 0.15s ease;
}

/* ---------- RESET & BASIS ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.muted {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

img {
    max-width: 100%;
}

/* ---------- HEADER / NAVIGATION ---------- */
.site-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.nav-brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.nav-links a {
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.nav-links a:hover {
    background: var(--bg-light);
    color: var(--primary-color);
    text-decoration: none;
}

.nav-links a.active {
    background: var(--primary-color);
    color: #fff;
}

/* ---------- MAIN CONTAINER ---------- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem;
}

main {
    flex: 1;
}

.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---------- DASHBOARD HEADER ---------- */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.dashboard-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
}

.dashboard-header p {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ---------- CARDS ---------- */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
    filter: brightness(1.05);
    box-shadow: var(--shadow-sm);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--primary-color);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: #e4dcfc;
}

.btn-danger {
    background: var(--error-bg);
    color: var(--error-color);
    border-color: #f5c6c6;
}

.btn-danger:hover {
    background: #fbd8d8;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
}

/* ---------- FORMS ---------- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.92rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-white);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(109, 74, 255, 0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---------- ALERTS ---------- */
.alert {
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-color);
    border-color: #bce5c9;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-color);
    border-color: #f5c6c6;
}

.alert-info {
    background: var(--info-bg);
    color: var(--info-color);
    border-color: #bcd3f5;
}

/* ---------- TABLES ---------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tr:hover td {
    background: var(--bg-body);
}

/* ---------- AUTH (LOGIN) ---------- */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.auth-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1.75rem;
}

.totp-input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.5em;
    font-family: monospace;
}

/* ---------- OPSKRIFTER ---------- */
.recipe-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.recipe-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.recipe-card h3 {
    font-size: 1.05rem;
    margin: 0;
}

.recipe-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.tag {
    display: inline-block;
    background: var(--bg-light);
    color: var(--primary-color);
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ---------- MADPLAN ---------- */
.meal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.meal-day {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    min-height: 120px;
}

.meal-day h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
}

.week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

/* ============================================================
   INDKØBSLISTE
   ============================================================ */

/* ---------- LISTE ---------- */
.shopping-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.shopping-list.sortable-items {
    min-height: 2.5rem;
}

.shopping-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-white);
    transition: background var(--transition-fast), opacity var(--transition-fast);
}

.shopping-item:last-child {
    border-bottom: none;
}

.shopping-item.checked {
    opacity: 0.55;
}

.shopping-item.checked .shopping-name {
    text-decoration: line-through;
}

.shopping-info {
    flex: 1;
    min-width: 0;
}

.shopping-name {
    font-weight: 600;
}

.shopping-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
}

/* ---------- CHECKBOX ---------- */
.shopping-checkbox-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.shopping-checkbox {
    width: 1.35rem;
    height: 1.35rem;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.check-visual {
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary);
    user-select: none;
    -webkit-user-select: none;
}

.shopping-item.checked .check-visual {
    color: var(--primary-color);
}

/* ---------- DRAG & DROP ---------- */
.drag-handle {
    cursor: grab;
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 0 0.25rem;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    flex-shrink: 0;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.cat-drag-handle {
    font-size: 1.3rem;
    cursor: move;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    opacity: 0.7;
    flex-shrink: 0;
    touch-action: none;
}

.cat-drag-handle:hover {
    opacity: 1;
    color: var(--primary-color);
}

.sortable-ghost {
    opacity: 0.4;
    background: #f0e6ff !important;
    border-left: 4px solid var(--primary-color);
}

.sortable-chosen {
    box-shadow: var(--shadow-md);
}

/* ---------- KATEGORI-KORT ---------- */
.category-card {
    margin-bottom: 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-white);
    transition: border-color var(--transition-fast);
}

.category-card:hover {
    border-color: var(--primary-light);
}

.category-header {
    background: var(--bg-light);
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.category-title {
    flex: 1;
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    min-width: 80px;
}

.category-count {
    background: var(--primary-color);
    color: #fff;
    padding: 0.2rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.empty-category .category-count {
    background: transparent;
    color: var(--text-secondary);
    font-weight: 400;
}

.empty-category .category-header {
    opacity: 0.6;
}

/* ---------- KATEGORI-DROPDOWN (simpel, mobil-venlig) ---------- */
.category-select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-family: inherit;
    background: var(--bg-white);
    color: var(--text-secondary);
    cursor: pointer;
    max-width: 130px;
    flex-shrink: 0;
    line-height: 1.4;
    touch-action: manipulation;
}

.category-select:hover {
    border-color: var(--primary-light);
}

.category-select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -1px;
    border-color: var(--primary-color);
}

/* ---------- STATUS-BADGES (generelt) ---------- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-color);
}

.badge-muted {
    background: var(--bg-body);
    color: var(--text-secondary);
}

/* ---------- UTILITY ---------- */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }

.divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

/* ---------- FOOTER ---------- */
.site-footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    padding: 1.25rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 2rem;
}

/* ---------- RESPONSIVT ---------- */
@media (max-width: 768px) {
    body { font-size: 15px; }

    .dashboard-header h1 { font-size: 1.35rem; }

    .container { padding: 1rem 0.85rem; }

    .auth-card { padding: 1.75rem; }

    /* Indkøbsliste på mobil: dropdown lidt bredere og nem at ramme */
    .shopping-item {
        padding: 0.65rem 0.6rem;
        gap: 0.45rem;
    }

    .category-select {
        max-width: 105px;
        min-height: 44px;   /* Apple touch-anbefaling */
        font-size: 0.85rem;
    }

    .drag-handle,
    .shopping-checkbox-btn {
        min-height: 44px;
        min-width: 44px;
        align-items: center;
        justify-content: center;
    }

    /* Basisvarer-knapper skal være store nok til tommelfinger */
    .btn-sm {
        min-height: 40px;
        padding: 0.5rem 0.9rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .nav-container {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-links {
        justify-content: center;
    }

    .category-header {
        padding: 0.65rem 0.85rem;
    }
}

/* ---------- PRINT (indkøbslisten i supermarkedet) ---------- */
@media print {
    .site-header,
    .site-footer,
    .no-print,
    .drag-handle,
    .cat-drag-handle,
    .category-select,
    .btn {
        display: none !important;
    }

    body {
        background: #fff;
        font-size: 13pt;
    }

    .category-card {
        border: 1px solid #999;
        break-inside: avoid;
        margin-bottom: 0.8rem;
    }

    .shopping-item.checked {
        display: none;   /* skjul varer i kurven på udskrift */
    }

    .container {
        max-width: 100%;
        padding: 0;
    }
}

/* ---------- FIREFOX-SPECIFIKKE JUSTERINGER ---------- */
@-moz-document url-prefix() {
    /* Firefox håndterer native selects lidt anderledes */
    .category-select {
        font-family: inherit;
        padding-left: 0.4rem;
    }

    .sortable-ghost {
        background: #f0e6ff !important;
    }
}

/* Mobile toast notification */
.mobile-toast {
  pointer-events: none;
  animation: fadeInOut 1.5s ease forwards;
}

@keyframes fadeInOut {
  0%   { opacity: 0; transform: translate(-50%, -60%); }
  20%  { opacity: 1; transform: translate(-50%, -50%); }
  80%  { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -60%); }
}

/* Knap interaktion på mobil */
.btn[data-pantry-id] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 44px;
  min-width: 44px;
}

/* Forhindr Firefox i at tolke håndtag som draggable tekst/links */
.drag-handle,
.cat-drag-handle {
    -moz-user-select: none;
    -webkit-user-drag: none;
    draggable: false;   /* ignoreres af FF men skader ikke */
}

/* Undgå at browsere laver native drag af emoji-indholdet */
[draggable="true"] {
    -moz-user-select: none;
}