:root {
    --bg-color: #050505;
    --card-bg: #111;
    --text-main: #e0e0e0;
    --text-dim: #888;
    --accent: #ff4400; /* Spicy Orange */
}

/* RESET */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Space Grotesk', sans-serif;
    min-height: 100vh;
    padding-bottom: 5rem;
}

/* NAV */
.nav-back {
    position: fixed; top: 20px; left: 20px; z-index: 100;
    text-decoration: none; font-family: 'Space Mono', monospace;
    color: var(--text-dim); font-size: 0.8rem;
    transition: color 0.3s;
}
.nav-back:hover { color: var(--accent); }

/* HEADER LAYOUT */
.log-header {
    /* Remove padding-left/right from here, the wrapper handles it */
    padding: 6rem 0 3rem 0; 
    text-align: center;
    border-bottom: 1px solid #222;
    margin-bottom: 3rem;
    position: relative; /* Context for absolute positioning if needed */
}

/* This wrapper mimics .grid-container dimensions exactly */
.header-layout {
    width: 90%;
    max-width: 1400px;
    margin: 0 auto;
    position: relative; /* Allows button to position relative to THIS width */
    display: flex;
    justify-content: center; /* Centers the text */
    align-items: center;
}

.header-titles {
    /* Keeps title centered */
    text-align: center;
}

.log-header h1 {
    font-family: 'Space Mono', monospace;
    font-size: 2rem; letter-spacing: -1px;
    color: var(--accent); margin-bottom: 0.5rem;
}

.log-header p {
    color: var(--text-dim); font-size: 0.9rem;
}

/* THE ADMIN BUTTON POSITIONING */
.admin-header-btn {
    position: absolute;
    left: 0; /* Snaps to the left edge of the 1400px/90% container */
    top: 50%;
    transform: translateY(-50%); /* Vertically centered relative to title */
    opacity: 0.3;
    font-size: 0.7rem;
    transition: opacity 0.3s;
}

.admin-header-btn:hover {
    opacity: 1;
}

/* On Mobile, the button might overlap the text if we aren't careful */
@media (max-width: 768px) {
    .header-layout {
        flex-direction: column;
        gap: 20px;
    }
    .admin-header-btn {
        position: static; /* Stack normally on mobile */
        transform: none;
    }
}

/* THE GRID SYSTEM */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    width: 90%;
    max-width: 1400px;
    margin: 0 auto;
}

/* THE CARD */
.card {
    background: var(--card-bg);
    border: 1px solid #222;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
}

/* MEDIA AREA */
.card-media {
    width: 100%;
    aspect-ratio: 16 / 9;
    position: relative;
    background: #000;
    border-bottom: 1px solid #222;
}

.card-media img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
}

/* MISSING IMAGE PLACEHOLDER */
.missing-img {
    width: 100%; height: 100%;
    background-color: #1a1a1a;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex; align-items: center; justify-content: center;
}

.missing-img::after {
    content: attr(data-text);
    font-family: 'Space Mono', monospace; font-size: 0.8rem;
    color: #444; border: 1px solid #444;
    padding: 5px 10px; letter-spacing: 2px;
}

/* --- HEAT TAGS & SCORES --- */
/* The text label (e.g. MEDIUM) */
.heat-tag {
    position: absolute;
    top: 10px; right: 10px;
    background: #000; color: #fff;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem; padding: 4px 8px;
    border: 1px solid #333; z-index: 5;
}

/* The numeric score circle (e.g. 4.5) */
.score-circle {
    position: absolute;
    top: 42px; right: 10px; /* Sits right below the tag */
    width: 35px; height: 35px;
    border-radius: 50%;
    background: #000;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Space Mono', monospace;
    font-weight: bold; font-size: 0.8rem;
    border: 1px solid #333; z-index: 5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

/* Levels apply to both tags and circles */
.level-1 { border-color: #00ffc3; color: #00ffc3; }
.level-2 { border-color: #ffff00; color: #ffff00; }
.level-3 { border-color: #ffaa00; color: #ffaa00; }
.level-4 { border-color: #ff4400; color: #ff4400; }
.level-5 { border-color: #ff0055; color: #ff0055; text-shadow: 0 0 5px #ff0055; }

/* CARD ACTIONS */
.card-actions {
    position: absolute; bottom: 10px; right: 10px;
    display: flex; gap: 5px; z-index: 10;
    display: none; /* HIDDEN FOR VISITORS */
}

.action-btn {
    background: rgba(0,0,0,0.7); color: #fff;
    border: 1px solid #444;
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem; padding: 4px 8px;
    cursor: pointer; backdrop-filter: blur(2px);
    transition: all 0.2s; text-transform: uppercase;
}
.btn-edit:hover { background: #fff; color: #000; border-color: #fff; }
.btn-delete { border-color: #552222; color: #ff8888; }
.btn-delete:hover { background: #ff0055; color: #fff; border-color: #ff0055; }

/* CONTENT AREA (Restructured Layout) */
.card-content {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex; flex-direction: column;
}

/* Row 1: Category */
.card-content .cat-wrapper { margin-bottom: 0.5rem; }

/* Row 2: Name */
.card-content h2 {
    font-size: 1.3rem; margin-bottom: 0.2rem;
    color: #fff; line-height: 1.2;
}

/* Row 3: Brand + Divider */
.card-content .meta {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem; color: var(--accent);
    margin-bottom: 1rem; padding-bottom: 1rem;
    text-transform: uppercase; letter-spacing: 1px;
    border-bottom: 1px dashed #333; /* The dotted line */
}

/* Row 4: Ingredients & Body */
.card-content p {
    font-size: 0.9rem; color: #aaa; line-height: 1.5;
}

.ing-label {
    color: #fff; font-weight: bold; margin-right: 5px;
}

/* --- FLOATING ACTION BUTTON --- */
.fab {
    position: fixed; bottom: 30px; right: 30px;
    width: 60px; height: 60px;
    border-radius: 50%; border: none;
    background: var(--accent); color: #fff;
    font-size: 2rem; cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 68, 0, 0.4);
    z-index: 500; transition: transform 0.2s;
    display: none; /* HIDDEN FOR VISITORS */
}
.fab:hover { transform: scale(1.1); }

/* --- MODAL --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-window {
    background: #111; border: 1px solid #333;
    width: 90%; max-width: 600px;
    max-height: 90vh; overflow-y: auto;
    padding: 2rem; border-radius: 8px;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
}

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 2rem; border-bottom: 1px solid #333; padding-bottom: 1rem;
}
.modal-header h2 { font-family: 'Space Mono', monospace; font-size: 1.2rem; color: #fff; }
#close-modal-btn { background: none; border: none; color: #888; font-size: 2rem; cursor: pointer; }
#close-modal-btn:hover { color: #fff; }

/* --- FORM --- */
.form-group { margin-bottom: 1.5rem; }
.form-row { display: flex; gap: 20px; }
.half { flex: 1; }

label {
    display: block; font-family: 'Space Mono', monospace;
    font-size: 0.7rem; color: #888; margin-bottom: 5px;
}
.sub-label { margin-top: 10px; }

input[type="text"], select, input[type="file"] {
    width: 100%; padding: 12px;
    background: #050505; border: 1px solid #333;
    color: #fff; font-family: 'Space Grotesk', sans-serif;
    border-radius: 4px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.text-btn {
    background: none; border: none; 
    color: var(--accent); font-family: 'Space Mono', monospace; 
    font-size: 0.7rem; cursor: pointer;
}
.text-btn:hover { text-decoration: underline; color: #fff; }

/* --- TAGS SYSTEM --- */
.tag-library {
    transition: max-height 0.4s ease, opacity 0.4s ease;
    overflow: hidden; margin-top: 10px;
    display: flex; flex-wrap: wrap; gap: 8px;
}
.tag-library.collapsed { max-height: 0; opacity: 0; pointer-events: none; }
.tag-library.expanded { max-height: 300px; opacity: 1; pointer-events: all; }

.tags-container { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; min-height: 30px;}

/* TAG STYLES */
/* 1. Base Style */
.tag-pill {
    background: linear-gradient(135deg, #e0f2fe, #bfdbfe); color: #1e3a8a; 
    font-size: 0.75rem; padding: 4px 10px; border-radius: 20px;
    cursor: pointer; opacity: 0.9; transition: all 0.2s;
    border: 1px solid transparent; text-shadow: none;
}
.tag-pill:hover { opacity: 1; transform: scale(1.05); }
.tag-pill.selected { border-color: #fff; opacity: 1; box-shadow: 0 0 10px rgba(255,255,255,0.2); }

/* 2. Specific Gradients */
.t-smoky { background: linear-gradient(135deg, #4b5563, #111827); color: #f9fafb; }
.t-tropical { background: linear-gradient(135deg, #f97316, #facc15); color: #111827; }
.t-fruity { background: linear-gradient(135deg, #f97373, #fb7185); color: #111827; }
.t-citrus { background: linear-gradient(135deg, #facc15, #fbbf24); color: #111827; }
.t-sweet { background: linear-gradient(135deg, #f9a8d4, #fb923c); color: #111827; }
.t-vinegar { background: linear-gradient(135deg, #a5b4fc, #6366f1); color: #f9fafb; }
.t-garlic { background: linear-gradient(135deg, #ede9fe, #fbbf24); color: #1f2937; }
.t-fermented { background: linear-gradient(135deg, #22c55e, #16a34a); color: #f9fafb; }
.t-umami { background: linear-gradient(135deg, #0f172a, #4b5563); color: #f9fafb; }
.t-herbal { background: linear-gradient(135deg, #4ade80, #22c55e); color: #022c22; }
.t-chipotle { background: linear-gradient(135deg, #b91c1c, #7f1d1d); color: #fef2f2; }
.t-superhot { background: linear-gradient(135deg, #ef4444, #b91c1c); color: #fef2f2; }
.t-reaper { background: linear-gradient(135deg, #000000, #7f1d1d); color: #ffffff; border: 1px solid #ff0000; }
.t-mild { background: linear-gradient(135deg, #e5e7eb, #9ca3af); color: #111827; } 
.t-earthy { background: linear-gradient(135deg, #854d0e, #431407); color: #fefce8; }
.t-habanero { background: linear-gradient(135deg, #fb923c, #c2410c); color: #fff7ed; }
.t-oil { background: linear-gradient(135deg, #fde047, #ca8a04); color: #422006; }
.t-extract { background: linear-gradient(135deg, #000000, #450a0a); color: #ff0000; border: 1px solid #7f1d1d; }
.t-dry { background: linear-gradient(135deg, #d6d3d1, #78716c); color: #292524; }
.t-chunky { background: linear-gradient(135deg, #404040, #262626); color: #d4d4d4; border: 1px dashed #737373; }
.t-smooth { background: linear-gradient(135deg, #525252, #404040); color: #e5e5e5; border: 1px solid #737373; }
.t-thin { background: linear-gradient(135deg, #262626, #171717); color: #a3a3a3; }
.t-thick { background: linear-gradient(135deg, #525252, #262626); color: #d4d4d4; }

/* Custom Tag Input */
.custom-tag-input { display: flex; gap: 10px; margin-bottom: 10px; }
.custom-tag-input input[type="text"] { flex-grow: 1; width: auto; }

#add-custom-tag-btn {
    background: #333; color: #fff; 
    border: 1px solid #444; padding: 0 20px; 
    cursor: pointer; font-family: 'Space Mono', monospace;
    transition: all 0.2s; flex-shrink: 0;
}
#add-custom-tag-btn:hover {
    background: var(--accent); border-color: var(--accent); color: #000;
}

/* --- RULER SLIDER --- */
.ruler-wrapper {
    position: relative; width: 100%; height: 50px; margin-top: 10px;
}
.ruler-bg {
    position: absolute; top: 15px; left: 0; width: 100%; height: 20px;
    pointer-events: none;
    background-image: 
        repeating-linear-gradient(90deg, #555 0 1px, transparent 1px 10%), 
        repeating-linear-gradient(90deg, #333 0 1px, transparent 1px 2%); 
    background-size: 100% 100%; border-bottom: 2px solid #555;
}

/* 1. Global Reset (Clean slate for all sliders) */
input[type=range] {
    -webkit-appearance: none; appearance: none;
    background: transparent; outline: none;
    padding: 0; border: none;
    width: 100%;
    cursor: pointer;
}

/* 2. RULER SPECIFIC (The Heat Slider) */
/* Needs absolute positioning to sit on top of the tick marks */
.ruler-wrapper input[type=range] {
    position: absolute; top: 0; left: 0; z-index: 2;
    height: 50px;
}

/* Ruler Thumbs (Orange Rectangle - Pushed down to sit on line) */
.ruler-wrapper input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 30px;
    background: var(--accent);
    border: 2px solid #fff; border-radius: 2px;
    box-shadow: 0 0 10px var(--accent);
    transform: translateY(18px); 
}
.ruler-wrapper input[type=range]::-moz-range-thumb {
    width: 20px; height: 30px;
    background: var(--accent);
    border: 2px solid #fff; border-radius: 2px;
    transform: translateY(18px);
}

/* 3. STAR SPECIFIC (The Quality Slider) */
/* Needs relative positioning to sit inside the flex box */
#star-slider {
    position: relative; 
    height: 30px;
    flex-grow: 1;
}

/* Star Thumbs (Gold Circle - Centered) */
#star-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px;
    background: #ffd700;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 10px #ffd700;
    margin-top: 0; /* No offset needed */
}
#star-slider::-moz-range-thumb {
    width: 20px; height: 20px;
    background: #ffd700;
    border-radius: 50%;
    border: 2px solid #fff;
}
.ruler-labels {
    display: flex; justify-content: space-between;
    font-family: 'Space Mono', monospace; font-size: 0.6rem; color: #666; margin-top: 5px;
}

/* --- TEXTAREA --- */
textarea {
    width: 100%; padding: 12px;
    background: #050505; border: 1px solid #333;
    color: #fff; font-family: 'Space Mono', monospace;
    font-size: 0.8rem; border-radius: 4px;
    resize: vertical; line-height: 1.4;
}
textarea:focus { outline: none; border-color: var(--accent); }

/* --- SUBMIT BUTTON --- */
.submit-btn {
    width: 100%; padding: 15px;
    background: var(--accent); color: #fff;
    border: none; font-family: 'Space Mono', monospace;
    font-size: 1rem; cursor: pointer; margin-top: 1rem;
    transition: background 0.3s;
}
.submit-btn:hover { background: #ff6633; }

/* --- CATEGORY BADGE --- */
.category-badge {
    display: inline-block;
    font-size: 0.6rem; 
    font-family: 'Space Mono', monospace;
    padding: 2px 6px; border-radius: 4px;
    vertical-align: middle;
}
.cat-sauce { background: #331100; color: #ffaa80; border: 1px solid #ffaa80; }
.cat-dish { background: #001133; color: #80aaff; border: 1px solid #80aaff; }
.cat-recipe { background: #113311; color: #80ff80; border: 1px solid #80ff80; }

/* Mobile Tweaks */
@media (max-width: 768px) {
    .grid-container { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
    .modal-window { padding: 1rem; width: 95%; }
}

/* --- STAR RATING SYSTEM --- */
.star-rating-wrapper {
    display: inline-flex;
    align-items: center;
    font-family: 'Space Mono', monospace;
    margin-bottom: 1rem; /* Spacing before ingredients */
    padding-bottom: 1rem;
    border-bottom: 1px dashed #333; /* Move the divider here */
    width: 100%;
}

.stars-outer {
    position: relative;
    display: inline-block;
    font-size: 1.2rem;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #333, #444); /* Grey/Empty color */
    -webkit-background-clip: text;
    color: rgba(0,0,0,0.2); /* Make text transparent to show background */
}

/* The Unicode Star Character */
.stars-outer::before {
    content: '★★★★★';
}

.stars-inner {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
    width: 0%; /* JavaScript will set this */
    
    /* Gold Gradient for filled stars */
    background: linear-gradient(180deg, #ffd700, #ffaa00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stars-inner::before {
    content: '★★★★★';
}

.star-score-text {
    margin-left: 10px;
    color: #ffd700;
    font-size: 0.9rem;
    font-weight: bold;
}

/* Update existing .meta to remove its border since stars have it now */
.card-content .meta {
    border-bottom: none; 
    margin-bottom: 0.2rem; 
    padding-bottom: 0;
}

/* --- MODAL STAR INPUT --- */
.star-input-group {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #0a0a0a;
    padding: 10px;
    border: 1px solid #333;
    border-radius: 4px;
}

/* Reuse the ruler-style slider but smaller */
#star-slider {
    flex-grow: 1;
    height: 30px;
    margin-top: 0;
}
/* Make the star slider handle Gold */
#star-slider::-webkit-slider-thumb { background: #ffd700; box-shadow: 0 0 10px #ffd700; }
#star-slider::-moz-range-thumb { background: #ffd700; }

/* --- SHOW TOOLS IF LOGGED IN --- */
/* Javascript will add class 'is-admin' to the body if password is correct */

body.is-admin .fab {
    display: block;
}

body.is-admin .card-actions {
    display: flex;
}