/* ============================================================
   Madplanner – iOS-inspireret design
   ============================================================ */

:root {
    --accent:     #FF6B35;
    --accent-lt:  #FFF0EA;
    --bg:         #F2F2F7;
    --card-bg:    #FFFFFF;
    --text:       #1C1C1E;
    --text-sub:   #8E8E93;
    --border:     #E5E5EA;
    --nav-height: 83px;
    --top-height: 56px;
    --radius:     16px;
    --radius-sm:  10px;
    --shadow:     0 2px 12px rgba(0,0,0,.08);
    --font:       -apple-system, "SF Pro Display", system-ui, sans-serif;
    --green:      #34C759;
    --red:        #FF3B30;
    --blue:       #007AFF;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ── App-container ── */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ── Top bar ── */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--top-height);
    background: rgba(242,242,247,.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 12px;
}

.top-bar-simple { justify-content: center; }

.page-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.week-label {
    text-align: center;
    line-height: 1.2;
}
.week-num   { display: block; font-size: 15px; font-weight: 600; }
.week-dates { display: block; font-size: 12px; color: var(--text-sub); }

.icon-btn {
    width: 36px; height: 36px;
    border: none; background: none;
    font-size: 22px; font-weight: 300;
    color: var(--accent);
    cursor: pointer; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.icon-btn:active { background: var(--accent-lt); }

/* ── User bar ── */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}
.user-name   { font-size: 14px; font-weight: 500; }
.logout-link { font-size: 13px; color: var(--accent); text-decoration: none; }

/* ── Main content ── */
.main-content {
    flex: 1;
    padding: 16px 16px calc(var(--nav-height) + 16px);
    overflow-y: auto;
}

/* ── Bottom nav ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    height: var(--nav-height);
    background: rgba(255,255,255,.95);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding: 8px 0 20px;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-sub);
    flex: 1;
    transition: color .15s;
}
.nav-item.active { color: var(--accent); }

.nav-icon  { font-size: 22px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 500; }

/* ── Day section ── */
.day-section {
    margin-bottom: 24px;
    animation: fadeIn .3s ease;
}
.day-section.today .day-name { color: var(--accent); }

.day-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
}
.day-name { font-size: 20px; font-weight: 700; }
.day-date  { font-size: 14px; color: var(--text-sub); }

/* ── Recipe cards ── */
.recipe-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recipe-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .15s, box-shadow .15s;
    border: 2px solid transparent;
}
.recipe-card.voted { border-color: var(--green); }
.recipe-card:active { transform: scale(.99); }

.card-image {
    width: 100%;
    height: 160px;
    background-size: cover;
    background-position: center;
    background-color: #F0E6DC;
}
.card-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: var(--accent-lt);
}

.card-body {
    padding: 14px 16px 16px;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.cat-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    letter-spacing: .3px;
}
.cat-1, .cat-saved { background: #E8F5E9; color: #2E7D32; }
.cat-2             { background: #E3F2FD; color: #1565C0; }
.cat-3             { background: #FFF3E0; color: #E65100; }
.cat-search        { background: #EDE7F6; color: #4527A0; }

.cook-time  { font-size: 12px; color: var(--text-sub); margin-left: auto; }

.card-title { font-size: 17px; font-weight: 600; margin-bottom: 4px; line-height: 1.25; }
.card-desc  { font-size: 14px; color: var(--text-sub); line-height: 1.4; margin-bottom: 12px; }

.card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* ── Vote button ── */
.vote-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all .15s;
    font-family: var(--font);
}
.vote-btn.voted {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}
.vote-btn:active { transform: scale(.95); }
.vote-count { font-weight: 700; }

/* ── Star rating ── */
.star-rating { display: flex; gap: 4px; }
.star {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #C7C7CC;
    transition: color .1s;
    padding: 0;
    font-family: var(--font);
}
.star.active, .star:hover { color: #FF9500; }

.rating-display { font-size: 14px; color: #FF9500; font-weight: 500; }
.rating-val     { color: var(--text-sub); margin-left: 4px; font-size: 13px; }

/* ── "Se opskrift" button ── */
.recipe-details-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: var(--accent-lt);
    color: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: var(--font);
    transition: background .15s;
}
.recipe-details-btn:active { background: #FFDDD0; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: var(--font);
    transition: opacity .15s, transform .1s;
    text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-outline  { background: #fff; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-danger   { background: #FFE5E3; color: var(--red); border: none; }
.btn-full     { width: 100%; }
.btn-lg       { padding: 14px 28px; font-size: 17px; }
.btn-sm       { padding: 7px 14px; font-size: 13px; }

/* ── Generate bar ── */
.generate-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* ── Empty states ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.empty-state p  { color: var(--text-sub); margin-bottom: 24px; font-size: 15px; }

.empty-state-small { text-align: center; padding: 32px 0; color: var(--text-sub); }

/* ── Modal (opskrift) ── */
.modal { position: fixed; inset: 0; z-index: 200; }
.modal.hidden { display: none; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.4);
}
.modal-sheet {
    position: absolute;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 12px 20px 40px;
    animation: slideUp .3s ease;
}
.modal-handle {
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
}
.modal-close {
    position: absolute;
    top: 14px; right: 16px;
    background: var(--bg);
    border: none;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-sub);
    display: flex; align-items: center; justify-content: center;
}

.modal-image {
    width: calc(100% + 40px);
    margin: 0 -20px 20px;
    height: 200px;
    background-size: cover;
    background-position: center;
    background-color: var(--accent-lt);
}

.modal-title  { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.modal-meta   { font-size: 14px; color: var(--text-sub); margin-bottom: 20px; }

.modal-section       { margin-bottom: 20px; }
.modal-section-title { font-size: 13px; font-weight: 700; text-transform: uppercase;
                       letter-spacing: .5px; color: var(--text-sub); margin-bottom: 10px; }

.ingredient-list, .instructions-list {
    list-style: none;
}

.ingredient-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ingredient-list li::before { content: '•'; color: var(--accent); font-size: 18px; }

.instructions-list li {
    padding: 10px 0 10px 36px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    line-height: 1.5;
    position: relative;
}
.step-num {
    position: absolute;
    left: 0;
    top: 10px;
    width: 24px; height: 24px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* ── Loading overlay ── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}
.loading-overlay.hidden { display: none; }

.loading-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px 40px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    max-width: 280px;
}
.loading-box p     { font-size: 16px; font-weight: 600; margin-top: 16px; }
.loading-sub       { font-size: 13px; color: var(--text-sub); margin-top: 6px !important; font-weight: 400 !important; }

.spinner {
    width: 44px; height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

/* ── Login ── */
.login-body { background: var(--bg); display: flex; align-items: center; min-height: 100dvh; }

.login-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

.login-logo { text-align: center; margin-bottom: 32px; }
.logo-icon   { font-size: 56px; display: block; margin-bottom: 8px; }
.login-title { font-size: 28px; font-weight: 700; }
.login-subtitle { font-size: 16px; color: var(--text-sub); margin-top: 4px; }

.tab-bar-login {
    display: flex;
    background: var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 24px;
    gap: 3px;
}
.tab-btn {
    flex: 1;
    padding: 9px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font);
    color: var(--text-sub);
    transition: all .2s;
}
.tab-btn.active { background: var(--card-bg); color: var(--text); box-shadow: var(--shadow); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }

/* ── Form groups ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-sub); }
.form-group input {
    padding: 13px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: var(--font);
    background: var(--card-bg);
    outline: none;
    transition: border-color .15s;
}
.form-group input:focus { border-color: var(--accent); }

/* ── Alerts ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error   { background: #FFE5E3; color: var(--red); }
.alert-success { background: #E8F5E9; color: #2E7D32; }

/* ── Settings ── */
.settings-form { display: flex; flex-direction: column; gap: 0; }
.settings-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 18px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.section-desc  { font-size: 13px; color: var(--text-sub); margin-bottom: 14px; }

.cuisine-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.cuisine-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}
.cuisine-option input { display: none; }
.cuisine-option.selected { border-color: var(--accent); background: var(--accent-lt); color: var(--accent); }

.checkbox-grid { display: flex; flex-direction: column; gap: 2px; }
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.checkbox-option:last-child { border-bottom: none; }
.checkbox-option input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.checkbox-label { font-size: 15px; }

.textarea-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    resize: vertical;
    outline: none;
    transition: border-color .15s;
}
.textarea-input:focus { border-color: var(--accent); }

.settings-footer { padding: 8px 0 0; }
.settings-note { text-align: center; font-size: 13px; color: var(--text-sub); margin-top: 10px; }

/* ── Search ── */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: var(--card-bg);
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    outline: none;
}
.search-input:focus { border-color: var(--accent); }

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    padding: 1px 8px;
    font-size: 13px;
    font-weight: 700;
    margin-left: 8px;
}

/* ── History ── */
.history-intro { font-size: 14px; color: var(--text-sub); margin-bottom: 12px; }
.history-list  { display: flex; flex-direction: column; gap: 10px; }

.history-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    transition: transform .15s;
}
.history-card:active { transform: scale(.99); }

.history-week    { font-size: 16px; font-weight: 600; padding-right: 24px; }
.history-top-meal { font-size: 13px; color: var(--text-sub); }
.history-arrow   { position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
                   color: var(--text-sub); font-size: 20px; }

.badge-current {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: middle;
}

/* ── Grocery ── */
.grocery-body      { background: var(--bg); }
.grocery-container { max-width: 600px; margin: 0 auto; padding: 20px 16px 40px; }

.grocery-header { text-align: center; margin-bottom: 28px; }
.grocery-header h1 { font-size: 26px; font-weight: 700; }
.grocery-week      { font-size: 14px; color: var(--text-sub); margin-top: 4px; }

.grocery-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.grocery-section h2 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }

.meal-list { list-style: none; }
.meal-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.meal-list li::before { content: '🍽️'; font-size: 16px; }
.meal-list li:last-child { border-bottom: none; }

.ingredient-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: opacity .2s;
    -webkit-tap-highlight-color: transparent;
}
.ingredient-item:last-child { border-bottom: none; }
.ingredient-item.checked { opacity: .45; text-decoration: line-through; }

.check-box        { font-size: 18px; flex-shrink: 0; color: var(--accent); }
.ingredient-text  { font-size: 15px; flex: 1; }
.ingredient-meal  { font-size: 12px; color: var(--text-sub); flex-shrink: 0; }

.grocery-footer { text-align: center; margin-top: 20px; }
.grocery-tip    { font-size: 13px; color: var(--text-sub); margin-bottom: 12px; }
.grocery-empty  { text-align: center; color: var(--text-sub); padding: 40px 0; }

/* ── No meals for day ── */
.no-meals-day { color: var(--text-sub); font-size: 14px; padding: 12px 0; }

/* ── Animations ── */
@keyframes slideUp {
    from { transform: translateX(-50%) translateY(100%); }
    to   { transform: translateX(-50%) translateY(0); }
}

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

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

/* ── Responsivt ── */

/* Tablet (600–1023px): 2 kort side om side */
@media (min-width: 600px) {
    .app-container { max-width: 800px; }
    .recipe-cards  { flex-direction: row; flex-wrap: wrap; }
    .recipe-card   { flex: 1 1 calc(50% - 8px); min-width: 220px; }
}

/* Desktop (900px+): 3 kort pr. dag, bredere layout */
@media (min-width: 900px) {
    .app-container { max-width: 1140px; }
    .main-content  { padding: 28px 32px calc(var(--nav-height) + 16px); }

    .recipe-cards              { display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 16px; }
    .recipe-card               { min-width: 0; }

    .day-name      { font-size: 22px; }
    .generate-bar  { gap: 14px; }
    .user-bar      { padding: 10px 32px; }
    .top-bar       { padding: 0 24px; }
}

/* Lille skærm (iPhone SE m.fl.) */
@media (max-width: 380px) {
    .cuisine-grid { grid-template-columns: repeat(2, 1fr); }
    .card-image   { height: 130px; }
}
