/* ---------------------------------------------------------
   Familiens system — mobile-first stylesheet
   --------------------------------------------------------- */

:root {
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-text: #1f2430;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-primary: #3B82F6;
    --color-primary-dark: #2563eb;
    --color-danger: #ef4444;
    --color-success: #16a34a;
    --color-warning: #f59e0b;
    --radius: 14px;
    --nav-height: 64px;
    --topbar-height: 56px;
    font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
p { margin: 0 0 .75em; }
a { color: var(--color-primary); text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    background: var(--color-primary);
    color: #fff;
}
.topbar-title { font-size: 1.1rem; font-weight: 600; }
.icon-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    padding: 6px;
    cursor: pointer;
}

/* ---------- Layout ---------- */
.page {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px calc(var(--nav-height) + 24px);
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: flex;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 6px;
    color: var(--color-muted);
    font-size: .7rem;
}
.bottom-nav a.active { color: var(--color-primary); font-weight: 600; }
.nav-icon { font-size: 1.3rem; line-height: 1; }

/* ---------- "Mere" bundmenu ---------- */
.more-sheet[hidden] { display: none; }
.more-sheet { position: fixed; inset: 0; z-index: 40; }
.more-sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.more-sheet-panel {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: var(--color-surface);
    border-radius: 16px 16px 0 0;
    padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.more-sheet-panel a {
    color: var(--color-text);
    padding: 14px 8px;
    border-bottom: 1px solid var(--color-border);
    font-size: 1rem;
}
.more-sheet-panel a:last-of-type { border-bottom: none; }

/* ---------- Cards ---------- */
.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.card h2 { font-size: 1.05rem; }
.muted { color: var(--color-muted); font-size: .9rem; }

/* ---------- Forms ---------- */
form label {
    display: block;
    margin: 12px 0 4px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--color-muted);
}
form input[type=text],
form input[type=password],
form input[type=email],
form input[type=number],
form input[type=date],
form input[type=datetime-local],
form select,
form textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    font-size: 1rem;
    background: #fff;
    color: var(--color-text);
}
form input[type=color] { width: 60px; height: 38px; border: 1px solid var(--color-border); border-radius: 8px; padding: 2px; }
form textarea { min-height: 80px; resize: vertical; }
.inline-form { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.inline-form input { flex: 1; padding: 8px; }

fieldset { border: 1px solid var(--color-border); border-radius: 10px; margin: 12px 0; padding: 8px 12px; }
fieldset legend { font-size: .85rem; font-weight: 600; color: var(--color-muted); padding: 0 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-weight: normal; }
.checkbox-row input { width: auto; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    border: none;
    border-radius: 10px;
    padding: 11px 18px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--color-border);
    color: var(--color-text);
    text-align: center;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:active { background: var(--color-primary-dark); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-muted { background: #eef0f3; color: var(--color-muted); }
.btn-block { display: block; width: 100%; margin-top: 16px; }
.btn-small { padding: 6px 10px; font-size: .8rem; }

/* ---------- Alerts / badges ---------- */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .9rem; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-off { background: #f1f1f3; color: var(--color-muted); }
.badge-high { background: #fee2e2; color: #991b1b; }
.badge-normal { background: #dbeafe; color: #1e40af; }
.badge-low { background: #f1f1f3; color: var(--color-muted); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }

/* ---------- Lists of items (events, tasks, birthdays, subscriptions) ---------- */
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}
.item-list li:last-child { border-bottom: none; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; }
.item-title.done { text-decoration: line-through; color: var(--color-muted); }
.item-meta { font-size: .8rem; color: var(--color-muted); margin-top: 2px; }
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.item-actions form { display: inline; }

/* ---------- Kalender: visningsvælger, uge- og månedsvisning ---------- */
.view-switcher {
    display: flex;
    background: var(--color-surface);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 16px;
    gap: 4px;
}
.view-switcher a {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    border-radius: 8px;
    color: var(--color-muted);
    font-size: .85rem;
    font-weight: 600;
}
.view-switcher a.active { background: var(--color-primary); color: #fff; }

.week-nav { display: flex; gap: 8px; margin-bottom: 16px; }
.week-nav a { flex: 1; text-align: center; }

.week-day-section h3.week-day-header { font-size: .95rem; margin-bottom: 8px; }
.week-day-section.today { border: 2px solid var(--color-primary); }
.week-day-section.today h3.week-day-header { color: var(--color-primary); }

.month-grid-card { padding: 8px; }
.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.month-grid-header {
    text-align: center;
    font-size: .7rem;
    font-weight: 600;
    color: var(--color-muted);
    padding: 4px 0;
}
.month-day {
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 3px;
    padding: 4px 2px;
    border-radius: 8px;
    color: var(--color-text);
    font-size: .8rem;
    min-height: 44px;
}
.month-day:active { background: var(--color-bg); }
.month-day.other-month { color: var(--color-border); }
.month-day.today { background: #dbeafe; font-weight: 700; }
.month-day.today .month-day-num { color: var(--color-primary); }
.month-day-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; max-width: 100%; }
.event-dot { display: inline-block; border-radius: 50%; background: var(--color-primary); }
.event-dot.imported { background: var(--color-warning); }
.month-day .event-dot { width: 5px; height: 5px; margin: 0; }
.month-day-more { font-size: .55rem; color: var(--color-muted); line-height: 1; }

/* ---------- Section header w/ add button ---------- */
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.fab-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
}

/* ---------- Auth page ---------- */
.auth-body {
    background: linear-gradient(160deg, var(--color-primary), #1e3a8a);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.auth-card {
    background: #fff;
    border-radius: 18px;
    padding: 28px 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.auth-card h1 { text-align: center; color: var(--color-primary); }
.auth-sub { text-align: center; color: var(--color-muted); margin-bottom: 20px; }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th, .data-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.data-table .actions { display: flex; flex-direction: column; gap: 4px; }
.data-table details summary { cursor: pointer; color: var(--color-primary); font-size: .8rem; }

/* ---------- Dashboard specific ---------- */
.stat-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 100px; background: var(--color-surface); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat-box .num { font-size: 1.6rem; font-weight: 700; color: var(--color-primary); }
.stat-box .label { font-size: .75rem; color: var(--color-muted); }

.empty-state { text-align: center; color: var(--color-muted); padding: 24px 8px; font-size: .9rem; }

/* ---------- Statistik (score/graf) ---------- */
.donut-wrap { display: flex; justify-content: center; margin-bottom: 12px; }
.donut-chart { width: 180px; height: 180px; }
.donut-total { font-size: 2rem; font-weight: 700; fill: var(--color-text); }
.donut-total-label { font-size: .7rem; fill: var(--color-muted); }
.score-list { list-style: none; margin: 0; padding: 0; }
.score-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--color-border); font-size: .9rem; }
.score-list li:last-child { border-bottom: none; }
.score-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.score-name { flex: 1; font-weight: 600; }
.score-count { color: var(--color-muted); font-size: .85rem; }
.week-chart { width: 100%; height: auto; }
.week-chart-label { font-size: 7px; fill: var(--color-muted); }

@media (min-width: 700px) {
    .page { padding-top: 24px; }
}
