@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap');

* {
    box-sizing: border-box;
}

/* ── THEME VARIABLES ── */
:root {
    --accent:       #16a085;
    --accent-dark:  #138d75;

    --bg-body:      #f0f0f0;
    --bg-main:      #ffffff;
    --bg-card:      #f5f5f5;
    --bg-item:      #ffffff;
    --bg-item-hover:#e0f7fa;

    --text-primary: #212121;
    --text-secondary:#757575;
    --text-heading: #2c3e50;

    --border:       #e0e0e0;
    --shadow:       rgba(0,0,0,0.1);
    --shadow-hover: rgba(0,0,0,0.15);

    --grid-color:   rgba(114,114,114,0.15);

    --modal-bg:     rgba(0,0,0,0.45);
    --modal-card:   #ffffff;
    --modal-text:   #444;
}

[data-theme="dark"] {
    --bg-body:      #191a1a;
    --bg-main:      #1a1b1b;
    --bg-card:      #232525;
    --bg-item:      #2a2c2c;
    --bg-item-hover:#1a3a35;

    --text-primary: #e8e8e8;
    --text-secondary:#909090;
    --text-heading: #c8d6d4;

    --border:       #333636;
    --shadow:       rgba(0,0,0,0.4);
    --shadow-hover: rgba(0,0,0,0.55);

    --grid-color:   rgba(255,255,255,0.04);

    --modal-bg:     rgba(0,0,0,0.65);
    --modal-card:   #1e2020;
    --modal-text:   #b0b8b8;
}

/* ── BASE ── */
body {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 2em 0;
    width: 100%;
    min-height: 100vh;
    max-width: 100vw;
    font-family: 'Inter', sans-serif;
    font-size: 24px;
    color: var(--text-primary);
    background-color: var(--bg-body);
    background-image:
        linear-gradient(0deg, transparent 24%, var(--grid-color) 25%, var(--grid-color) 26%, transparent 27%, transparent 74%, var(--grid-color) 75%, var(--grid-color) 76%, transparent 77%, transparent),
        linear-gradient(90deg, transparent 24%, var(--grid-color) 25%, var(--grid-color) 26%, transparent 27%, transparent 74%, var(--grid-color) 75%, var(--grid-color) 76%, transparent 77%, transparent);
    background-size: 55px 55px;
}

h1, h2, h3, h4, h5, button {
    font-family: "Lora", serif;
}

/* ── LAYOUT ── */
main {
    width: 100%;
    max-width: 42em;
    padding: 1.25em 1.75em;
    background-color: var(--bg-main);
    border-radius: 0.75em;
}

.header {
    display: flex;
    justify-content: center;
    margin-bottom: 0.2em;
}

h1 {
    margin: 0 0 0.6em 0;
    text-align: center;
    font-size: 1.8rem;
    color: var(--text-primary);
}



/* ── TOGGLE ── */
.dark-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    margin-bottom: 0.8em;
}

.dark-toggle span {
    font-size: 0.7em;
}

.toggle-switch {
    position: relative;
    width: 2.4em;
    height: 1.3em;
    cursor: pointer;
    display: inline-block;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 999px;
    transition: background 0.3s;
}

.toggle-switch input:checked + .toggle-track {
    background: var(--accent);
}

.toggle-thumb {
    position: absolute;
    top: 0.17em;
    left: 0.17em;
    width: 0.95em;
    height: 0.95em;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    pointer-events: none;
}

.toggle-switch input:checked ~ .toggle-thumb {
    transform: translateX(1.1em);
}

/* ── MEALS ── */
button {
    background-color: transparent;
    padding: 0;
    border: 0;
    font-weight: 550;
    cursor: pointer;
}

.dinner-list {
    display: flex;
    flex-direction: column;
}

.item-header {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.8em;
}

.week-group {
    background-color: var(--bg-card);
    border-radius: 0.75em;
    padding: 1em 1.25em;
    margin-bottom: 1em;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s;
}

.week-group:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.week-group h3 {
    font-size: 1.2em;
    margin-bottom: 0.6em;
    color: var(--text-heading);
}

.item {
    background: var(--bg-item);
    margin: 0.3em 0;
    padding: 0.6em;
    border-radius: 0.5em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.item:hover {
    background: var(--bg-item-hover);
}

.item.selected {
    background: var(--accent);
    color: white;
}

.item.selected .day-label {
    color: rgba(255,255,255,0.75);
}

.day-label {
    font-weight: 600;
    font-size: 0.8em;
    color: var(--text-secondary);
    min-width: 2.5em;
}

.name {
    font-weight: 600;
    font-size: 1em;
    color: var(--text-primary);
    flex: 1;
    text-align: right;
}

.item.selected .name {
    color: white;
}

.name:empty::before {
    content: '-';
    color: var(--text-secondary);
    font-style: italic;
}

/* ── MODAL ── */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--modal-bg);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-backdrop.visible {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--modal-card);
    border-radius: 1em;
    padding: 1.5em 2em;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    max-width: 28em;
    width: 90%;
    animation: modal-in 0.2s ease;
    border: 1px solid var(--border);
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h3 {
    margin: 0 0 0.4em 0;
    color: var(--accent);
    font-size: 1.3em;
}

.modal p {
    margin: 0 0 1.2em 0;
    font-size: 0.9em;
    color: var(--modal-text);
    line-height: 1.5;
}

.modal button {
    display: block;
    width: 100%;
    padding: 0.5em 1em;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 0.5em;
    font-size: 0.9em;
    cursor: pointer;
    transition: background 0.2s;
}

.modal button:hover {
    background-color: var(--accent-dark);
}

/* ── VERSION ── */
#version {
    position: fixed;
    top: 10px;
    right: 10px;
    background: var(--bg-card);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    z-index: 999;
}

/* ── MOBILE ── */
@media only screen and (max-width: 550px) {
    body {
        font-size: 14px;
        align-items: flex-start;
    }

    main {
        border-radius: 0;
        min-height: 100vh;
    }
}

/* ── SCROLL TO TOP ── */
#scroll-top {
    position: fixed;
    bottom: 1.5em;
    right: 1.5em;
    width: 2.2em;
    height: 2.2em;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 1.1em;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s, background 0.2s;
    z-index: 998;
    display: flex;
    align-items: center;
    justify-content: center;
}

#scroll-top.visible {
    opacity: 1;
    pointer-events: all;
}

#scroll-top:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
}