/*
 * Komponentbibliotek - designelementerne fra BigSolverWEB som håndskrevet CSS:
 * Card, Button, Badge, ThemeIcon, Input, Alert, EmptyState, Skeleton, Modal,
 * ActionSheet og Toast. Layoutet omkring dem ligger i shell.css.
 */

/* ---------- Card ---------- */

.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--sp-md);
    min-width: 0;
}

.card--flat { box-shadow: none; border: 1px solid var(--border); }
.card--warm { background: var(--surface-warm); }

a.card, button.card { display: block; text-align: left; width: 100%; border: 0; cursor: pointer; }
a.card:hover, button.card:hover { text-decoration: none; box-shadow: var(--shadow-md); }

.card--interactive {
    cursor: pointer;
    transition: box-shadow 140ms ease, transform 140ms ease;
}
.card--interactive:hover { box-shadow: var(--shadow-md); }
.card--interactive:active { transform: scale(.995); }

/* ---------- Button ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--brand-6);
    color: #fff;
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn:hover:not(:disabled) { background: var(--brand-light); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn--default {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn--default:hover:not(:disabled) { background: var(--warm-0); }

.btn--light {
    background: var(--brand-0);
    color: var(--brand-7);
}
.btn--light:hover:not(:disabled) { background: var(--brand-1); }

.btn--subtle { background: transparent; color: var(--brand-7); }
.btn--subtle:hover:not(:disabled) { background: var(--brand-0); }

.btn--danger { background: var(--red); }
.btn--danger:hover:not(:disabled) { background: var(--red-7); }

.btn--danger-light { background: var(--red-0); color: var(--red-7); }
.btn--danger-light:hover:not(:disabled) { background: #fbd5d5; }

.btn--sm { height: 34px; padding: 0 14px; font-size: var(--fs-sm); }
.btn--lg { height: 44px; padding: 0 22px; font-size: var(--fs-md); }
.btn--full { width: 100%; }

/* Indlaesningstilstand: teksten bliver staaende, ikonet snurrer. */
.btn[data-loading="true"] { pointer-events: none; opacity: .7; }

.spinner {
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Badge ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    background: var(--brand-0);
    color: var(--brand-7);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: .2px;
    white-space: nowrap;
}

.badge--brand { background: var(--brand-6); color: #fff; }
.badge--amber { background: var(--amber-0); color: var(--amber-7); }
.badge--red { background: var(--red-0); color: var(--red-7); }
.badge--green { background: var(--green-0); color: var(--green-7); }
.badge--neutral { background: var(--warm-2); color: var(--warm-8); }
.badge--outline { background: transparent; border: 1px solid var(--border); color: var(--brand-7); }

/* ---------- ThemeIcon ---------- */

.theme-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    background: var(--brand-0);
    color: var(--brand-6);
    flex-shrink: 0;
}
.theme-icon--lg { width: 42px; height: 42px; }
.theme-icon--xl { width: 72px; height: 72px; border-radius: 50%; }
.theme-icon--amber { background: var(--amber-0); color: var(--amber-7); }
.theme-icon--red { background: var(--red-0); color: var(--red-7); }
.theme-icon--green { background: var(--green-0); color: var(--green-7); }

/* ---------- Input ---------- */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.field__label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-sm);
    font-weight: 600;
}

.field__hint { font-size: var(--fs-xs); color: var(--text-dimmed); }
.field__error { font-size: var(--fs-xs); color: var(--red-7); }

.input {
    height: 46px;
    width: 100%;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    font-size: var(--fs-md); /* 16px holder iOS fra at zoome ved fokus */
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input::placeholder { color: var(--warm-6); }
.input:focus {
    outline: none;
    border-color: var(--brand-5);
    box-shadow: 0 0 0 3px rgba(78, 120, 244, .18);
}
.input[aria-invalid="true"] { border-color: var(--red); }
.input:disabled { background: var(--warm-1); color: var(--text-dimmed); cursor: not-allowed; }

/* Telefonfelt: landekode + nummer side om side. */
.input-group { display: flex; gap: 8px; }
.input-group .input--prefix { width: 88px; flex: 0 0 auto; }

/* Store cifre til pinkoden. */
.input--code {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 6px;
    text-align: center;
}

/* ---------- Alert ---------- */

.alert {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--brand-0);
    color: var(--brand-8);
    font-size: var(--fs-sm);
}
.alert--red { background: var(--red-0); color: var(--red-7); }
.alert--amber { background: var(--amber-0); color: var(--amber-7); }
.alert--green { background: var(--green-0); color: var(--green-7); }
.alert__icon { flex-shrink: 0; margin-top: 1px; }

/* ---------- EmptyState ---------- */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-xs);
    padding: var(--sp-xl) var(--sp-md);
    text-align: center;
}
.empty__title { font-size: var(--fs-lg); font-weight: var(--fw-heading); margin-top: var(--sp-xs); }
.empty__desc { font-size: var(--fs-sm); color: var(--text-dimmed); max-width: 420px; }

/* ---------- Skeleton ---------- */

.skeleton {
    background: var(--warm-2);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}
.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
    animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- Modal ---------- */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    background: rgba(1, 22, 137, .35);
    animation: fade 140ms ease;
}
@keyframes fade { from { opacity: 0; } }

.modal {
    margin: auto;
    width: min(420px, calc(100vw - 32px));
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-lg);
    animation: pop 160ms ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.modal__title { font-size: var(--fs-md); font-weight: var(--fw-heading); margin-bottom: var(--sp-xs); }

/* ---------- ActionSheet - bundpanel paa mobil, dialog paa desktop ---------- */

.sheet {
    margin-top: auto;
    width: 100%;
    padding: var(--sp-sm);
    padding-bottom: max(var(--sp-sm), env(safe-area-inset-bottom));
    animation: slide-up 200ms cubic-bezier(.22, 1, .36, 1);
}
@keyframes slide-up { from { transform: translateY(100%); } }

.sheet__group {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.sheet__group + .sheet__group { margin-top: var(--sp-xs); }

.sheet__title {
    padding: 13px 16px;
    font-size: var(--fs-sm);
    color: var(--text-dimmed);
    text-align: center;
    border-bottom: 1px solid var(--border-warm);
}

.sheet__option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 17px 16px;
    border: 0;
    border-top: 1px solid var(--border-warm);
    background: var(--surface);
    color: var(--brand-7);
    font-size: var(--fs-md);
    font-weight: 600;
    cursor: pointer;
}
.sheet__group > .sheet__option:first-child { border-top: 0; }
.sheet__option:hover:not(:disabled) { background: var(--brand-0); }
.sheet__option:disabled { color: var(--warm-6); cursor: not-allowed; }
.sheet__option--danger { color: var(--red); }
.sheet__option--danger:hover:not(:disabled) { background: var(--red-0); }
.sheet__option--cancel { color: var(--text); }

@media (min-width: 48em) {
    .sheet {
        margin: auto;
        width: min(400px, calc(100vw - 32px));
        animation: pop 160ms ease;
    }
}

/* ---------- Toast - modsvarer Mantine Notifications, top-right ---------- */

.toasts {
    position: fixed;
    top: calc(var(--header-h) + 12px);
    right: 16px;
    left: 16px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    gap: 10px;
    width: min(360px, 100%);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--brand-6);
    animation: toast-in 180ms ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } }

.toast--closing { opacity: 0; transform: translateX(12px); transition: opacity 180ms ease, transform 180ms ease; }

.toast--red { border-left-color: var(--red); }
.toast--green { border-left-color: var(--green); }
.toast--amber { border-left-color: var(--amber); }

.toast__title { font-size: var(--fs-sm); font-weight: 700; }
.toast__msg { font-size: var(--fs-md); color: var(--text-dimmed); }
.toast__icon { flex-shrink: 0; margin-top: 1px; color: var(--brand-6); }
.toast--red .toast__icon { color: var(--red); }
.toast--green .toast__icon { color: var(--green); }
.toast--amber .toast__icon { color: var(--amber); }
