/* ─────────────────────────────────────────────────────────────
 *  style.css  —  Cookbook main stylesheet
 *  Design: warm food palette, Playfair Display + Inter
 * ───────────────────────────────────────────────────────────── */

/* ── Fonts ────────────────────────────────────────────────────── */
@font-face {
    font-family: 'Playfair Display';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/playfair-display/playfair-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Playfair Display';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/playfair-display/playfair-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Playfair Display';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/playfair-display/playfair-700.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/inter/inter-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/inter/inter-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/inter/inter-600.woff2') format('woff2');
}

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
    /* Palette */
    --bg:           #FBF7F0;      /* warm cream */
    --surface:      #FFFFFF;
    --surface-alt:  #F4EFE8;
    --sidebar-bg:   #1C1C1E;
    --sidebar-text: #E8E3DB;
    --sidebar-muted:#8A887F;
    --primary:      #B5451B;      /* paprika / brick-red */
    --primary-hover:#9A3815;
    --primary-light:#F9E8E2;
    --accent:       #D4A853;      /* warm gold */
    --accent-hover: #BC9240;
    --danger:       #C44536;
    --danger-hover: #A83428;
    --text:         #1C1C1E;
    --text-muted:   #6B7280;
    --border:       #E5DDD3;
    --border-focus: #B5451B;
    --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
    --shadow-md:    0 4px 12px rgba(0,0,0,.10);
    --shadow-lg:    0 12px 32px rgba(0,0,0,.14);
    --radius:       10px;
    --radius-sm:    6px;
    --radius-lg:    16px;

    /* Layout */
    --sidebar-w:    260px;
    --topbar-h:     60px;
    --transition:   .2s ease;
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    height: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4 {
    font-family: 'Playfair Display', Georgia, serif;
    line-height: 1.2;
}

img { max-width: 100%; display: block; }

button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ── Utilities ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ────────────────────────────────────────────────────────────────
 *  LOGIN PAGE
 * ────────────────────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    isolation: isolate;
    /* hero image */
    background: url('../images/welcome.jpg') center center / cover no-repeat fixed;
}

/* dark scrim over the photo */
.login-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(
        160deg,
        rgba(28, 20, 12, .65) 0%,
        rgba(28, 20, 12, .50) 100%
    );
}

.login-card {
    position: relative;
    /* frosted-glass panel */
    background: rgba(255, 255, 255, .13);
    backdrop-filter: blur(22px) saturate(1.6);
    -webkit-backdrop-filter: blur(22px) saturate(1.6);
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 20px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, .40),
        0 2px 8px  rgba(0, 0, 0, .25),
        inset 0 1px 0 rgba(255, 255, 255, .35);
    padding: 52px 44px;
    width: 100%;
    max-width: 440px;
    color: #fff;
    /* subtle entrance animation */
    animation: loginCardIn .45s cubic-bezier(.22, 1, .36, 1) both;
}

@keyframes loginCardIn {
    from { opacity: 0; transform: translateY(24px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo h1 {
    font-size: 2.2rem;
    color: #fff;
    text-shadow: 0 2px 12px rgba(0,0,0,.45);
    letter-spacing: .01em;
}

.login-logo p {
    color: rgba(255, 255, 255, .72);
    font-size: .9rem;
    margin-top: 6px;
    letter-spacing: .03em;
}

/* Override label / input / btn colours inside the glass card */
.login-card .form-group label {
    color: rgba(255, 255, 255, .80);
}

.login-card .form-control {
    background: rgba(255, 255, 255, .15);
    border-color: rgba(255, 255, 255, .30);
    color: #fff;
    caret-color: #fff;
}
.login-card .form-control::placeholder { color: rgba(255, 255, 255, .45); }
.login-card .form-control:focus {
    background: rgba(255, 255, 255, .22);
    border-color: rgba(255, 255, 255, .70);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .18);
    outline: none;
}

.login-card .form-check {
    color: rgba(255, 255, 255, .75);
    font-size: .875rem;
}

.login-card .btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 18px rgba(181, 69, 27, .55);
    transition: background var(--transition), box-shadow var(--transition), transform .1s;
}
.login-card .btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 22px rgba(181, 69, 27, .65);
    transform: translateY(-1px);
}
.login-card .btn-primary:active { transform: translateY(0); }

.login-card .btn-secondary {
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .38);
    color: #fff;
    transition: background var(--transition), border-color var(--transition);
}
.login-card .btn-secondary:hover {
    background: rgba(255, 255, 255, .24);
    border-color: rgba(255, 255, 255, .60);
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0;
    color: rgba(255, 255, 255, .50);
    font-size: .8rem;
}
.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, .25);
}

.login-error {
    background: rgba(196, 69, 54, .28);
    border: 1px solid rgba(196, 69, 54, .60);
    color: #ffd0cc;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: .875rem;
    margin-bottom: 16px;
    display: none;
}

/* ────────────────────────────────────────────────────────────────
 *  FORM CONTROLS (shared)
 * ────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(181,69,27,.12);
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
    color: var(--text-muted);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .9rem;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); color: #fff; box-shadow: var(--shadow-sm); }

.btn-secondary {
    background: var(--surface-alt);
    color: var(--text);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--border); color: var(--text); }

.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-accent:hover { background: var(--accent-hover); color: #fff; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-xs { padding: 4px 8px; font-size: .75rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ────────────────────────────────────────────────────────────────
 *  APP LAYOUT  (index.php SPA)
 * ────────────────────────────────────────────────────────────── */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width var(--transition);
    position: relative;
    z-index: 200;
}

.sidebar-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.sidebar-logo {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
}

.sidebar-new-btn {
    flex-shrink: 0;
    font-size: .78rem;
    padding: 5px 12px;
}

.sidebar-header h1 {
    font-size: 1.25rem;
    color: var(--accent);
    letter-spacing: .01em;
}

.sidebar-header p {
    font-size: .75rem;
    color: var(--sidebar-muted);
    margin-top: 2px;
}

.sidebar-search {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}

.sidebar-search input {
    width: 100%;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 20px;
    padding: 7px 14px 7px 36px;
    color: var(--sidebar-text);
    font-size: .875rem;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%238A887F' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.242 1.656a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    transition: background-color var(--transition);
}

.sidebar-search input::placeholder { color: var(--sidebar-muted); }
.sidebar-search input:focus { background-color: rgba(255,255,255,.14); border-color: rgba(255,255,255,.25); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

/* Category items (generated by app.js) */
.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 20px;
    cursor: pointer;
    border-left: 3px solid transparent;
    color: var(--sidebar-text);
    font-size: .85rem;
    list-style: none;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    user-select: none;
}

.category-item:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}

.category-item.active {
    background: rgba(181,69,27,.18);
    border-left-color: var(--primary);
    color: #fff;
}

.cat-name { flex: 1; }

.cat-count {
    margin-left: auto;
    font-size: .75rem;
    background: rgba(255,255,255,.12);
    color: var(--sidebar-muted);
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 22px;
    text-align: center;
}

.cat-count:empty { display: none; }

/* User pill (sidebar footer) */
.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.user-email {
    font-size: .78rem;
    color: var(--sidebar-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.logout-btn {
    color: var(--sidebar-muted);
    font-size: 1rem;
    padding: 4px;
    text-decoration: none;
}
.logout-btn:hover { color: #fff; }

.sidebar-admin-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.06);
    color: var(--sidebar-text);
    font-size: .85rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}
.sidebar-admin-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-admin-item .admin-icon { font-size: 1rem; }

.sidebar-section-label {
    padding: 12px 20px 4px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--sidebar-muted);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    cursor: pointer;
    border-left: 3px solid transparent;
    color: var(--sidebar-text);
    font-size: .9rem;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    user-select: none;
}

.sidebar-item:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}

.sidebar-item.active {
    background: rgba(181,69,27,.18);
    border-left-color: var(--primary);
    color: #fff;
}

.sidebar-item .item-count {
    margin-left: auto;
    font-size: .75rem;
    background: rgba(255,255,255,.12);
    color: var(--sidebar-muted);
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 16px 16px;
    border-top: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info .name { font-size: .875rem; font-weight: 500; color: var(--sidebar-text); }
.sidebar-user-info .email { font-size: .75rem; color: var(--sidebar-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-footer-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-footer-links a {
    font-size: .8rem;
    color: var(--sidebar-muted);
    padding: 4px 0;
    transition: color var(--transition);
}
.sidebar-footer-links a:hover { color: var(--sidebar-text); }

/* ── Main content ─────────────────────────────────────────────── */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

#topbar,
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    flex-shrink: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

#topbar .breadcrumb,
.topbar .breadcrumb {
    flex: 1;
    font-size: .875rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

#topbar .breadcrumb span,
.topbar .breadcrumb span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .breadcrumb .bc-item { color: var(--text); font-weight: 500; }
#topbar .breadcrumb .sep,
.topbar .breadcrumb .sep,
.topbar .breadcrumb .bc-sep { color: var(--border); flex-shrink: 0; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

[hidden] { display: none !important; }

#topbar .hamburger,
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

#content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 28px;
    min-height: 0;
}

#content::-webkit-scrollbar { width: 6px; }
#content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Loading overlay ──────────────────────────────────────────── */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(251,247,240,.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}
#loading-overlay:not(.hidden) { display: flex; }

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ────────────────────────────────────────────────────────────────
 *  RECIPE GRID
 * ────────────────────────────────────────────────────────────── */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.recipe-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}

.recipe-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.recipe-card-img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--surface-alt);
}

.recipe-card-no-img {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, var(--surface-alt) 0%, var(--border) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 2.5rem;
}

.recipe-card-body {
    padding: 14px 16px;
}

.recipe-card-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recipe-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-category {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-servings {
    background: var(--surface-alt);
    color: var(--text-muted);
}

.badge-time {
    background: #EEF4FF;
    color: #3B5FC0;
}

.empty-state {
    text-align: center;
    padding: 64px 32px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h2 { font-size: 1.25rem; margin-bottom: 8px; color: var(--text); }

/* ────────────────────────────────────────────────────────────────
 *  RECIPE DETAIL PANEL
 * ────────────────────────────────────────────────────────────── */
.recipe-detail { max-width: 840px; }

.recipe-detail-header {
    margin-bottom: 28px;
}

.recipe-detail-header h1 {
    font-size: 2rem;
    margin-bottom: 12px;
}

.recipe-meta-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

/* Photo carousel */
.photo-carousel {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface-alt);
    margin-bottom: 24px;
    aspect-ratio: 16 / 9;
}

.photo-carousel img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,.45);
    color: #fff;
    border: none;
    cursor: pointer;
    padding: 10px 14px;
    font-size: 1.1rem;
    border-radius: 4px;
    transition: background var(--transition);
}
.photo-carousel-nav:hover { background: rgba(0,0,0,.65); }
.photo-carousel-nav.prev { left: 10px; }
.photo-carousel-nav.next { right: 10px; }

.photo-thumbs {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.photo-thumb {
    width: 64px;
    height: 44px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    opacity: .6;
    border: 2px solid transparent;
    transition: opacity var(--transition), border-color var(--transition);
    flex-shrink: 0;
}

.photo-thumb.active { opacity: 1; border-color: var(--primary); }

/* Scaling bar */
.scaling-bar {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.scaling-bar label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.scaling-bar input[type=number] {
    width: 80px;
    padding: 6px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    text-align: center;
}

.scaling-bar input[type=number]:focus {
    border-color: var(--border-focus);
    outline: none;
}

.scaling-bar .sep { color: var(--border); }

/* Action bar */
.action-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

/* Steps */
.steps-list { display: flex; flex-direction: column; gap: 16px; }

.step-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.step-header {
    padding: 14px 20px;
    background: var(--surface-alt);
    border-bottom: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.step-number {
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-title-text {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 600;
    font-size: 1rem;
}

.step-toggle { margin-left: auto; color: var(--text-muted); font-size: .85rem; }

.step-body {
    padding: 20px;
}

/* Ingredients table */
.ingredients-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: .9rem;
}

.ingredients-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    border-bottom: 1.5px solid var(--border);
}

.ingredients-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--surface-alt);
    vertical-align: top;
}

.ingredients-table tr:hover td { background: var(--bg); }
.ingredients-table td.qty-cell { width: 80px; font-weight: 600; text-align: right; color: var(--primary); }
.ingredients-table td.measure-cell { width: 90px; color: var(--text-muted); }

/* Instructions (Quill read-only) */
.step-instructions { line-height: 1.7; }
.step-instructions p { margin-bottom: .75em; }
.step-instructions ul, .step-instructions ol { padding-left: 1.5em; margin-bottom: .75em; }

/* Links section */
.links-section { margin-top: 28px; }
.links-section h2 { font-size: 1.1rem; margin-bottom: 12px; }

.link-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.link-tile {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: .875rem;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.link-tile:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); color: var(--primary); }

/* ────────────────────────────────────────────────────────────────
 *  EDITOR PANEL (slide-in)
 * ────────────────────────────────────────────────────────────── */
#editor-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: min(860px, 100%);
    height: 100vh;
    background: var(--surface);
    box-shadow: -8px 0 32px rgba(0,0,0,.15);
    z-index: 500;
    display: flex;
    flex-direction: column;
    transition: right .3s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}

#editor-panel.visible { right: 0; }

#editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 499;
    backdrop-filter: blur(2px);
}

.editor-topbar,
.ep-header {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    flex-shrink: 0;
}

.editor-topbar h2, .ep-header h2 { flex: 1; font-size: 1.1rem; }

.editor-body,
.ep-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.editor-body::-webkit-scrollbar, .ep-body::-webkit-scrollbar { width: 6px; }
.editor-body::-webkit-scrollbar-thumb, .ep-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.editor-footer,
.ep-footer {
    padding: 16px 20px;
    border-top: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    background: var(--surface);
}

.editor-footer .spacer { flex: 1; }

.ep-footer-right { margin-left: auto; display: flex; gap: 10px; }

.ep-delete-btn { margin-right: auto; }

/* ── Editor meta fields — compact 2-col grid ── */
.ep-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    margin-bottom: 8px;
}
.ep-meta-grid .ep-field-full { grid-column: 1 / -1; }
.ep-meta-grid label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 3px;
}
.ep-meta-grid .form-control { padding: 7px 10px; font-size: .875rem; }
.ep-meta-grid .input-group { display: flex; gap: 6px; }
.ep-meta-grid .input-group .form-control { flex: 1; min-width: 0; }

.ep-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0 10px;
}

.ep-section-header h3 { font-size: 1rem; }

/* Step card in editor */
.editor-step {
    background: var(--surface-alt);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: visible;
}

.editor-step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1.5px solid var(--border);
    background: var(--bg);
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 0 4px;
    user-select: none;
}
.drag-handle:active { cursor: grabbing; }

.editor-step-body { padding: 16px; }

/* Ingredient table in editor */
.ing-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.ing-table th {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    text-align: left;
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
}
.ing-table td { padding: 4px 6px; }
.ing-table td input { width: 100%; padding: 6px 8px; border: 1.5px solid var(--border); border-radius: 4px; background: var(--surface); }
.ing-table td input:focus { border-color: var(--border-focus); outline: none; }
.ing-table .col-qty { width: 80px; }
.ing-table .col-measure { width: 110px; }
.ing-table .col-desc { }
.ing-table .col-del { width: 32px; text-align: center; }
.ing-row-del { color: var(--danger); padding: 4px; }
.ing-row-del:hover { opacity: .7; }

/* Quill editor in steps */
.editor-step .ql-container { font-size: 14px; min-height: 120px; }
.editor-step .ql-toolbar { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.editor-step .ql-container { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

/* Image gallery in editor */
.img-gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.img-thumb-item {
    position: relative;
    width: 100px;
    flex-shrink: 0;
}

.img-thumb-item img {
    width: 100px;
    height: 68px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
}

.img-thumb-item.primary-img img { border-color: var(--accent); }

.img-primary-star {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--accent);
    color: #fff;
    font-size: .65rem;
    border-radius: 3px;
    padding: 1px 5px;
}

.img-del-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,.6);
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    cursor: pointer;
    line-height: 1;
}
.img-del-btn:hover { background: var(--danger); }

.img-caption { width: 100%; font-size: .7rem; padding: 2px 4px; border: 1px solid var(--border); border-radius: 3px; margin-top: 4px; }

/* Links editor */
.links-editor { display: flex; flex-direction: column; gap: 8px; }
.link-row { display: flex; gap: 8px; align-items: center; }
.link-row input { flex: 1; padding: 7px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; background: var(--surface); }
.link-row input:focus { border-color: var(--border-focus); outline: none; }
.link-row .link-del { color: var(--danger); flex-shrink: 0; }

/* ────────────────────────────────────────────────────────────────
 *  MODALS (share, confirm, admin overlays)
 * ────────────────────────────────────────────────────────────── */
.modal-overlay,
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(2px);
}

.modal-overlay { display: none; }
.modal-backdrop.hidden { display: none !important; }

.modal-backdrop .modal,
.modal-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-box.modal-lg { max-width: 720px; }

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header h3 { flex: 1; font-size: 1.1rem; }
.modal-close, .modal-close-btn { color: var(--text-muted); font-size: 1.25rem; padding: 4px; }
.modal-close:hover, .modal-close-btn:hover { color: var(--text); }

.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

.share-link-row { display: flex; gap: 8px; }
.share-link-row input { flex: 1; }
.share-info { color: var(--text-muted); font-size: .875rem; margin-bottom: 12px; }

/* ────────────────────────────────────────────────────────────────
 *  ADMIN PAGE
 * ────────────────────────────────────────────────────────────── */
.admin-wrap { max-width: 900px; margin: 0 auto; }
.admin-wrap h1 { font-size: 1.75rem; margin-bottom: 8px; }
.admin-wrap .subtitle { color: var(--text-muted); margin-bottom: 28px; }

.tab-bar {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 28px;
    gap: 0;
}

.tab-btn {
    padding: 10px 20px;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color var(--transition), border-color var(--transition);
}

.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { color: var(--text); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    background: var(--bg);
}
.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--surface-alt);
    vertical-align: middle;
}
.data-table tr:hover td { background: var(--bg); }

.sortable-list { list-style: none; padding: 0; }
.sortable-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: .9rem;
}
.sortable-list li .drag-handle { color: var(--text-muted); cursor: grab; }
.sortable-list li .cat-name { flex: 1; }
.sortable-ghost { opacity: .4; background: var(--primary-light) !important; }

/* ────────────────────────────────────────────────────────────────
 *  IMPORT PAGE (inside admin)
 * ────────────────────────────────────────────────────────────── */
.import-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    margin-bottom: 16px;
}
.import-zone:hover, .import-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }
.import-zone .icon { font-size: 2.5rem; margin-bottom: 12px; }

.import-result {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    font-size: .875rem;
    margin-top: 12px;
    display: none;
}
.import-result.success { border-color: #86EFAC; background: #F0FDF4; }
.import-result.error { border-color: #FCA5A5; background: #FEF2F2; color: var(--danger); }

/* ────────────────────────────────────────────────────────────────
 *  SHARE / PUBLIC VIEW
 * ────────────────────────────────────────────────────────────── */
.public-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.public-header {
    padding: 20px 24px;
    background: var(--surface);
    border-bottom: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.public-header .app-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    color: var(--primary);
}

/* ────────────────────────────────────────────────────────────────
 *  TOAST NOTIFICATIONS
 * ────────────────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--text);
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    box-shadow: var(--shadow-md);
    animation: toastIn .25s ease;
    pointer-events: auto;
    max-width: 320px;
}

.toast.success { background: #15803D; }
.toast.error { background: var(--danger); }
.toast.warning { background: #B45309; }

@keyframes toastIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }

/* ────────────────────────────────────────────────────────────────
 *  RESPONSIVE
 * ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 300;
        transition: left .3s cubic-bezier(.4,0,.2,1);
    }
    #sidebar.open, #sidebar.sidebar-open { left: 0; }
    #sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 299; display: none; }
    #sidebar-overlay.visible { display: block; }

    #topbar .hamburger, .hamburger-btn { display: flex; }
    #main { width: 100%; }

    #content { padding: 16px; }

    .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

    .recipe-detail-header h1 { font-size: 1.5rem; }

    #editor-panel { width: 100%; }

    .ep-meta-grid { grid-template-columns: 1fr; }
    .ep-meta-grid .ep-field-full { grid-column: 1; }

    .form-row { grid-template-columns: 1fr; }

    .login-card { padding: 36px 24px; }

    .action-bar { gap: 8px; }
    .action-bar .btn { font-size: .8rem; padding: 7px 12px; }

    .scaling-bar { padding: 10px 14px; gap: 10px; }
}

@media (max-width: 480px) {
    .recipe-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* ── Print styles ─────────────────────────────────────────────── */
@media print {
    #sidebar, #topbar, .topbar, .action-bar, .scaling-bar, #editor-panel, #editor-overlay, #toast-container { display: none !important; }
    #main { overflow: visible; }
    #content { overflow: visible; padding: 0; }
    .recipe-detail { max-width: 100%; }
    .step-body { display: block !important; }
}
