/* === CSS-variabler (lys tema) === */
:root {
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-text-muted: #6c757d;
    --color-primary: #4a90d9;
    --color-primary-hover: #357abd;
    --color-success: #4caf50;
    --color-success-hover: #43a047;
    --color-danger: #e74c3c;
    --color-border: #dee2e6;
    --color-done-bg: #f0fdf4;
    --color-done-text: #a0aec0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* === Reset === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

/* === Container — mobil-først === */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 1rem;
    text-align: center;
}

/* === Skjema (legg til vare) === */
form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

input[type="text"] {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s;
    background: var(--color-surface);
    color: var(--color-text);
}

input[type="text"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

input[type="text"]::placeholder {
    color: var(--color-text-muted);
}

button[type="submit"] {
    padding: 0.75rem 1.25rem;
    font-size: 1.25rem;
    font-weight: 600;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

button[type="submit"]:hover {
    background: var(--color-primary-hover);
}

button[type="submit"]:active {
    transform: scale(0.97);
}

/* === Liste === */
ul {
    list-style: none;
    padding: 0;
}

li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow);
    transition: background 0.2s, opacity 0.2s;
}

li:hover {
    background: #f8faff;
}

li span {
    flex: 1;
    font-size: 1rem;
}

/* Ferdige varer */
li.done {
    background: var(--color-done-bg);
    border-color: #c6f6d5;
}

li.done span {
    text-decoration: line-through;
    color: var(--color-done-text);
}

/* Toggle-knapper (OK / Angre) */
li button {
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    min-width: 48px;
    min-height: 44px;
    white-space: nowrap;
}

li:not(.done) button {
    background: var(--color-success);
    color: #fff;
}

li:not(.done) button:hover {
    background: var(--color-success-hover);
}

li.done button {
    background: var(--color-primary);
    color: #fff;
}

li.done button:hover {
    background: var(--color-primary-hover);
}

li button:active {
    transform: scale(0.95);
}

/* === Tom liste-melding === */
.empty-message {
    text-align: center;
    color: var(--color-text-muted);
    margin: 2rem 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* === htmx swap- animasjon (fade-in) === */
.htmx-swapping li {
    opacity: 0;
    transition: opacity 0.2s ease-out;
}

.htmx-added li {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === htmx-indikator (spinner) === */
.htmx-indicator {
    display: none;
    text-align: center;
    padding: 0.5rem;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

.spinner-icon {
    display: inline-block;
    width: 1.2rem;
    height: 1.2rem;
    border: 2px solid #e2e8f0;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === 404-side === */
body:has(h1:first-child) a {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 600;
    transition: background 0.2s;
}

body:has(h1:first-child) a:hover {
    background: var(--color-primary-hover);
}

/* === Responsiv: Desktop === */
@media (min-width: 640px) {
    .container {
        padding: 2rem 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    li {
        padding: 1rem 1.25rem;
    }

    li button {
        min-width: 60px;
    }

    button[type="submit"] {
        font-size: 1.5rem;
    }
}
