/* --- ADMIN THEME: THE PAPER MENU (Final Version) --- */
/* Imports: Abril Fatface (Headers), Lato (Body), Great Vibes (Cursive), Montserrat (Titles) */
@import url('https://fonts.googleapis.com/css2?family=Abril+Fatface&family=Great+Vibes&family=Lato:ital,wght@0,400;0,700;1,400&family=Montserrat:wght@900&display=swap');

:root {
    /* --- PALETTE --- */
    --bg-paper: #fdfbf7;     /* Warm White Paper */
    --text-ink: #1a1a1a;     /* Deep Black Ink */
    --accent: #d4af37;       /* Gold (for highlights) */
    --border-ink: #000000;   /* Solid Black Borders */
    --soft-bg: #f4f1ea;      /* Beige accent from "Softs" box */
    
    /* --- TYPOGRAPHY --- */
    --font-header: 'Abril Fatface', serif; /* The "Beer/Gin" font */
    --font-title: 'Montserrat', sans-serif; /* The "DRINK MENU" font */
    --font-body: 'Lato', sans-serif;        /* The item text */
    --font-cursive: 'Great Vibes', cursive; /* The "Cocktails" font */
}

/* --- GLOBAL RESET --- */
body {
    background-color: var(--bg-paper);
    color: var(--text-ink);
    font-family: var(--font-body);
    margin: 0;
    padding: 40px 20px;
    min-height: 100vh;
    /* Subtle paper texture */
    background-image: linear-gradient(#f4f1ea 1px, transparent 1px), linear-gradient(90deg, #f4f1ea 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center center;
}

.container { max-width: 1200px; margin: 0 auto; }

/* --- HEADER --- */
header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 60px;
    border-bottom: 3px double var(--text-ink); /* Double line like the "Softs" box */
    padding-bottom: 20px;
    background: var(--bg-paper);
}

h1 {
    color: var(--text-ink);
    font-family: var(--font-title);
    font-size: 2.5rem;
    text-transform: uppercase;
    letter-spacing: -1px;
    margin: 0;
    font-weight: 900;
    display: flex; align-items: center; gap: 20px;
}

h1 a {
    text-decoration: none; color: var(--text-ink);
    font-size: 0.5em; vertical-align: middle; 
    font-family: var(--font-body); font-weight: normal;
}
h1 a:hover { color: var(--accent); }

/* --- BUTTONS (Ink Stamp Style) --- */
.btn, #view-toggle-btn {
    padding: 10px 20px; 
    border-radius: 0; 
    border: 2px solid var(--text-ink);
    cursor: pointer;
    font-family: var(--font-title); 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 1px;
    font-size: 0.8rem; 
    transition: all 0.2s;
    background: transparent; 
    color: var(--text-ink);
    text-decoration: none;
    display: inline-block;
}

/* Primary (Gold/Black Hover) */
.btn-primary, #view-toggle-btn:hover {
    background: var(--text-ink); 
    color: #fff;
    border-color: var(--text-ink);
}
.btn-primary:hover {
    background: var(--accent); 
    border-color: var(--accent); 
    color: #fff;
}

/* The View Toggle Specifics */
#view-toggle-btn {
    font-size: 0.7rem;
    padding: 8px 16px;
    vertical-align: middle;
    margin-left: 20px;
}

/* Danger (Red) */
.btn-danger {
    border-color: #d33; color: #d33;
}
.btn-danger:hover {
    background: #d33; color: #fff;
}

/* Outline (Subtle) */
.btn-outline {
    background: transparent; border: 1px dashed var(--text-ink); color: #666;
}
.btn-outline:hover {
    border-style: solid; color: var(--text-ink);
}

/* --- GRID LAYOUT (Default Card View) --- */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
}

/* --- CARDS (Styled like Menu Entries) --- */
.card {
    background: var(--bg-paper);
    border: 1px solid var(--text-ink);
    border-radius: 2px;
    overflow: hidden;
    display: flex; flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.1); /* Paper shadow effect */
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 6px 6px 0px rgba(0,0,0,0.15);
    border-color: var(--accent);
}

/* Image looks like a vintage photo */
.card-img {
    width: 100%; height: 200px; object-fit: cover;
    border-bottom: 1px solid var(--text-ink);
    filter: sepia(0.3) contrast(1.1);
    cursor: pointer;
}

.card-body {
    padding: 20px; flex-grow: 1; display: flex; flex-direction: column;
}

/* Header: Name.......Price */
.card-header {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 8px;
    border-bottom: 1px dotted #ccc; 
    padding-bottom: 5px;
}

.card-title {
    margin: 0;
    color: var(--text-ink);
    font-family: var(--font-header); 
    font-size: 1.5rem;
    letter-spacing: 0.5px;
}

.card-price {
    color: var(--text-ink);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1.2rem;
}

.card-desc {
    color: #555;
    font-size: 0.95rem;
    font-style: italic;
    margin-bottom: 20px;
    flex-grow: 1;
    line-height: 1.5;
}

/* Category Badge */
.card-cat-display {
    display: inline-block;
    background: var(--soft-bg);
    border: 1px solid var(--text-ink);
    padding: 2px 8px;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 10px;
    border-radius: 4px;
}

.card-actions { display: flex; gap: 10px; margin-top: auto; }

/* --- INLINE EDITING --- */
[contenteditable="true"] {
    border-bottom: 2px solid var(--accent);
    background: rgba(212, 175, 55, 0.1);
    outline: none; cursor: text;
}

.inline-actions {
    display: none; gap: 10px; margin-top: 15px; padding-top: 10px;
    border-top: 1px solid #eee;
}
.inline-actions.active { display: flex; }

.editable-field { cursor: pointer; transition: color 0.2s; }
.editable-field:hover { color: var(--accent); }

/* --- PHANTOM CARD (Add New Item) --- */
.card.new-item-mode {
    border: 2px dashed var(--accent);
    background: #fff;
    order: -1; 
}

.upload-placeholder {
    width: 100%; height: 200px;
    background: #e0e0e0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-ink); font-weight: bold; text-transform: uppercase;
    cursor: pointer;
    border-bottom: 1px solid var(--text-ink);
    transition: background 0.2s;
}
.upload-placeholder:hover {
    background: #d4af37; color: #fff;
}

/* --- LIST MODE STYLES (Robust Grid Fix) --- */
.menu-grid.list-mode {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.menu-grid.list-mode .card {
    display: grid;
    /* Columns: Img | Name | Desc | Price | Cat | Actions */
    grid-template-columns: 50px 1.5fr 2.5fr 80px 120px 140px;
    align-items: center;
    gap: 15px;
    padding: 8px 15px;
    min-height: 50px;
    border-bottom: 1px solid #ddd;
    box-shadow: none; 
}

/* FLATTEN CONTAINERS:
   This makes children part of the main grid. 
   Note: We do NOT flatten .list-cat-wrapper anymore to keep it tidy.
*/
.menu-grid.list-mode .card-body,
.menu-grid.list-mode .card-header {
    display: contents;
}

/* CRITICAL FIX: Hide the hidden input so it doesn't take up a grid cell */
.menu-grid.list-mode input[type="hidden"] {
    display: none !important;
}

/* 1. IMAGE */
.menu-grid.list-mode .card-img {
    grid-column: 1;
    grid-row: 1; /* Force everything to Row 1 */
    display: block !important;
    width: 40px; height: 40px;
    object-fit: cover;
    border: 1px solid var(--text-ink);
    border-radius: 2px;
    margin: 0;
    cursor: pointer;
}

/* 2. NAME */
.menu-grid.list-mode .card-title {
    grid-column: 2;
    grid-row: 1;
    font-size: 1rem;
    margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 3. DESCRIPTION (Now forced to middle) */
.menu-grid.list-mode .card-desc {
    grid-column: 3;
    grid-row: 1;
    display: block !important;
    font-size: 0.85rem;
    color: #666;
    margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 4. PRICE */
.menu-grid.list-mode .card-price {
    grid-column: 4;
    grid-row: 1;
    text-align: right;
    font-weight: bold;
    font-size: 1rem;
    margin: 0;
}

/* 5. CATEGORY (Targeting the wrapper we added) */
.menu-grid.list-mode .list-cat-wrapper {
    grid-column: 5;
    grid-row: 1;
    margin: 0;
    text-align: center;
    width: 100%;
}
/* Ensure the elements inside the wrapper behave */
.menu-grid.list-mode .list-cat-wrapper select,
.menu-grid.list-mode .list-cat-wrapper span {
    width: 75% !important;
    margin: 0 !important;
}

/* 6. ACTIONS */
.menu-grid.list-mode .card-actions,
.menu-grid.list-mode .inline-actions {
    grid-column: 6;
    grid-row: 1;
    margin: 0;
    display: flex; 
    justify-content: flex-end;
    gap: 5px;
}

.menu-grid.list-mode .btn {
    padding: 5px 10px;
    font-size: 0.7rem;
}

/* HIDE UNUSED ELEMENTS */
.menu-grid.list-mode .upload-placeholder { display: none; }

/* --- FORMS & MODALS --- */
select {
    width: 100%; padding: 5px;
    background: #fff;
    border: 1px solid var(--text-ink);
    color: var(--text-ink);
    font-family: var(--font-body);
    font-size: 0.9rem;
    border-radius: 0;
}
select:focus { outline: none; border-color: var(--accent); }

/* Cropper Modal */
.modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    z-index: 999; align-items: center; justify-content: center;
}
.cropper-modal-box {
    background: #fff; padding: 20px; border: 2px solid var(--text-ink);
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}