/* Custom Beige Theme */
:root {
    /* Primary accent colors */
    --tp-primary: #8B7355;
    --tp-primary-hover: #6B5744;
    --tp-primary-light: rgba(139, 115, 85, 0.15);
    
    /* Background colors */
    --tp-background: #1C1814;
    --tp-card-background: #2A2420;
    
    /* Text colors */
    --tp-text: #E8E0D5;
    --tp-text-muted: #A89888;
    --tp-heading: #D4C4B0;
    
    /* Border colors */
    --tp-border: #3D3530;
    --tp-border-hover: #5D4D40;
    
    /* Status colors */
    --tp-success: #7D9B76;
    --tp-danger: #B87070;
    
    /* Shadows */
    --shadow-color: rgba(0, 0, 0, 0.3);
    
    /* Text-fit font size bounds (in rem) */
    --text-fit-min: 0.6;
    --text-fit-max: 2;
}

/* Override PicoCSS colors */
html[data-theme="dark"] {
    /* Map our custom variables to PicoCSS variables */
    --primary: var(--tp-primary);
    --primary-hover: var(--tp-primary-hover);
    --primary-focus: var(--tp-primary-light);
    --primary-light: var(--tp-primary-light);
    
    --background-color: var(--tp-background);
    --card-background-color: var(--tp-card-background);
    --card-sectionning-background-color: var(--tp-card-background);
    
    --color: var(--tp-text);
    --text-color: var(--tp-text);
    --muted-color: var(--tp-text-muted);
    --text-muted: var(--tp-text-muted);
    --heading-color: var(--tp-heading);
    --h1-color: var(--tp-heading);
    --h2-color: var(--tp-heading);
    --h3-color: var(--tp-heading);
    --h4-color: var(--tp-heading);
    --h5-color: var(--tp-heading);
    --h6-color: var(--tp-heading);
    
    --form-element-background-color: var(--tp-card-background);
    --form-element-border-color: var(--tp-border);
    --form-element-focus-color: var(--tp-primary);
    
    --switch-color: var(--tp-text);
    --switch-checked-background-color: var(--tp-primary);
    
    /* Secondary button colors */
    --secondary: var(--tp-text-muted);
    --secondary-hover: var(--tp-heading);
    --secondary-focus: var(--tp-primary-light);
    --secondary-inverse: var(--tp-background);
    
    /* Table colors */
    --table-border-color: var(--tp-border);
    
    /* Dropdown/select colors */
    --dropdown-background-color: var(--tp-card-background);
    --dropdown-border-color: var(--tp-border);
    --dropdown-hover-background-color: var(--tp-primary-light);
    
    /* Border colors - custom variable used throughout */
    --border-color: var(--tp-border);
    --border-hover: var(--tp-border-hover);
    --muted-border-color: var(--tp-border);
    
    /* Status colors */
    --success-color: var(--tp-success);
    --danger-color: var(--tp-danger);
    
    /* Modal overlay */
    --modal-overlay-background-color: rgba(0, 0, 0, 0.7);
}

/* Secondary button styling */
button.secondary,
[type="button"].secondary,
[type="submit"].secondary,
a.secondary[role="button"] {
    background-color: var(--border-color);
    border-color: var(--border-color);
    color: var(--text-color);
}

button.secondary:hover,
[type="button"].secondary:hover,
[type="submit"].secondary:hover,
a.secondary[role="button"]:hover {
    background-color: var(--tp-border-hover);
    border-color: var(--tp-border-hover);
    color: var(--tp-text);
}

/* Table styling overrides */
table {
    border-collapse: collapse;
    background-color: var(--card-background-color);
}

table th,
table td {
    border-bottom: 1px solid var(--border-color);
    background-color: var(--card-background-color);
}

table thead th {
    background-color: var(--card-background-color);
    border-bottom: 2px solid var(--border-color);
}

/* File input styling */
input[type="file"] {
    background-color: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
}

input[type="file"]::file-selector-button {
    background-color: var(--border-color);
    border: none;
    color: var(--text-color);
    padding: 0.5rem 1rem;
    margin-right: 1rem;
    border-radius: 4px;
    cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
    background-color: var(--border-hover);
}

/* Checkbox styling */
input[type="checkbox"] {
    background-color: var(--card-background-color);
    border-color: var(--border-color);
}

input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* Switch/toggle styling - ensure handle is visible */
input[type="checkbox"][role="switch"] {
    background-color: var(--border-color);
}

input[type="checkbox"][role="switch"]:checked {
    background-color: var(--primary);
}

input[type="checkbox"][role="switch"]::before {
    background-color: var(--tp-text) !important;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Hide scrollbar (Firefox) */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 0;
    height: 0;
}

body {
    background-color: var(--background-color);
    --block-spacing-vertical: 1rem;
    --block-spacing-horizontal: 1rem;
    font-size: 15px;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

/* Tobacco Tab - fills viewport, no body scroll */
.tobacco-tab {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 70px - 2rem); /* Viewport minus nav height minus main padding */
    height: calc(100dvh - 70px - 2rem); /* Dynamic viewport height for mobile */
    overflow: hidden;
}

/* When tobacco tab is active, prevent body scroll */
body:has(.tobacco-tab) {
    overflow: hidden !important;
}

/* Tobacco grid view needs to scroll within the tab */
.tobacco-tab > .grid.product-grid {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    scrollbar-width: none;
    grid-auto-rows: min-content;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1rem;
}

.tobacco-tab > .grid.product-grid::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* Ensure product cards in tobacco grid maintain proper sizing */
.tobacco-tab .product-card {
    height: auto;
    align-self: start;
}

.tobacco-tab .product-card .card-image {
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
}

h1, h2, h3, h4 {
    line-height: 1.2;
}

article {
    background-color: var(--tp-card-background) !important;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s;
    padding: 0; /* Reset padding for image */
    overflow: hidden; /* For image corners */
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-width: 400px;
    margin: 0 auto;
    --block-spacing-vertical: 1rem;
    --block-spacing-horizontal: 1rem;
}

article > header {
    padding: var(--block-spacing-vertical) var(--block-spacing-horizontal);
    margin: 0;
    background-color: var(--tp-card-background);
    border-bottom: 1px solid var(--border-color);
}

article > footer, article > p {
    padding: var(--block-spacing-vertical) var(--block-spacing-horizontal);
    margin: 0;
}

article.unavailable {
    opacity: 0.6;
    border-color: var(--border-color);
}

.mix-header {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    text-align: center;
}

.mix-header h3 {
    margin: 0;
    margin-bottom: 0.5rem;
    font-size: 1.4rem;
    line-height: 1.3;
    font-weight: 600;
    width: 100%;
    text-align: center;
}

.badge {
    font-size: 0.6rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.available {
    background-color: var(--success-color);
    color: #000;
}

.badge.unavailable {
    background-color: var(--danger-color);
    color: #fff;
}

.headings {
    margin-bottom: 2rem;
    text-align: center;
}

.mix-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 400px)) !important;
    gap: 2rem !important;
    justify-content: center;
}

.mix-image-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    overflow: hidden;
    background: linear-gradient(135deg, var(--card-background-color) 0%, var(--background-color) 100%);
    position: relative;
    margin: 0;
}

.mix-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Admin Layout --- */

.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
aside {
    width: 250px;
    background-color: var(--card-background-color);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    position: fixed;
    height: 100vh;
    z-index: 100;
    left: 0;
    top: 0;
    transform: translateX(-100%); /* Hidden by default on all screens */
}

aside.open {
    transform: translateX(0);
}

aside nav ul {
    flex-direction: column;
}

aside nav ul li {
    padding: 0.5rem 0;
}

aside nav ul li a {
    display: block;
    padding: 0.5rem;
    border-radius: 4px;
    color: var(--color);
    text-decoration: none;
}

aside nav ul li a.active {
    background-color: var(--primary);
    color: white;
}

/* Main Content */
main {
    flex: 1;
    padding: 1rem;
    width: 100%; /* Full width always */
    margin-left: 0;
}

/* Prevent scroll anchoring jumps near dynamic featured content */
.featured-section {
    overflow-anchor: none;
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.top-bar h3 {
    margin-bottom: 0;
}

.hamburger {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 1rem;
    margin-bottom: 0; /* Fix alignment */
    color: var(--color);
    width: auto;
    display: block; /* Always visible */
    line-height: 1;
}

/* Utilities */
.stock-toggle {
    cursor: pointer;
}

.delete-btn {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    margin-bottom: 0;
    width: auto;
    display: inline-block;
}

/* Overlay */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

.overlay.open {
    display: block;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
    overflow: hidden;
}

.modal-overlay.open {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin: 0;
    animation: modal-in 0.2s ease-out;
    padding: 0; /* Ensure reset */
    background-color: var(--tp-card-background) !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.modal-content::-webkit-scrollbar {
    display: none;
}

.modal-content header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 2rem;
    margin-bottom: 0;
    background-color: var(--tp-card-background);
}

.modal-title-block {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.modal-content header h3 {
    margin-bottom: 0;
    text-align: left;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
    align-self: flex-end;
    --text-fit-min: 0.9;
    --text-fit-max: 1.8;
}

.modal-content form {
    padding: var(--block-spacing-vertical) var(--block-spacing-horizontal);
    margin-bottom: 0;
    background-color: var(--card-background-color);
}

.modal-content form input,
.modal-content form textarea,
.modal-content form select {
    background-color: var(--background-color);
    border-color: var(--border-color);
}

.modal-content footer {
    background-color: var(--card-background-color);
}

.modal-content footer button {
    margin-bottom: 0;
}

.modal-content .close {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--color);
    font-size: 1.5rem;
    line-height: 1;
    width: auto;
    cursor: pointer;
    align-self: center;
}

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

/* Admin Mix Table */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background-color: var(--card-background-color);
}

.table-scroll table {
    min-width: 760px;
    background-color: var(--card-background-color);
    border-collapse: collapse;
}

.table-scroll table th,
.table-scroll table td {
    background-color: var(--card-background-color);
    border-bottom: 1px solid var(--border-color);
}

.table-scroll table thead th {
    background-color: var(--card-background-color);
    border-bottom: 2px solid var(--border-color);
}

.mix-table {
    table-layout: fixed;
    width: 100%;
    background-color: var(--card-background-color);
}

.mix-table th,
.mix-table td {
    vertical-align: middle;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.mix-table .col-image { width: 110px; }
.mix-table .col-name { width: 16%; }
.mix-table .col-description { width: 24%; }
.mix-table .col-ingredients { width: 30%; }
.mix-table .col-featured { width: 10%; }
.mix-table .col-actions { width: 12%; }

.admin-mix-thumb {
    width: 80px;
    height: 80px;
    min-width: 80px;
    min-height: 80px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.admin-ingredient-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0;
    color: var(--text-muted);
}

.admin-ingredient-line {
    display: block;
    font-size: 0.85rem;
    line-height: 1.4;
}

.mix-description-clamp {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    max-height: 2.6em; /* ~2 lines */
}

/* --- Refactored Styles --- */

/* Index Page */
.mix-content {
    padding: var(--block-spacing-vertical) var(--block-spacing-horizontal);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.mix-description {
    margin-bottom: 1rem;
    color: var(--text-muted);
    text-align: center;
}

.mix-footer {
    margin-top: auto;
    padding: 0;
}

.ingredients-box {
    display: block;
    padding: 0.75rem;
    background-color: var(--primary-light);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.ingredients-title {
    color: var(--primary);
}

.ingredient-item {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.ingredients-section li {
    font-size: 0.95rem;
    line-height: 1.3;
    white-space: nowrap;
}
.ingredients-section {
    margin-bottom: 0;
}
.ingredients-section ul {
    display: inline-block;
    white-space: nowrap;
}

/* Admin Page */
.login-container {
    padding-top: 10vh;
}

.error-text {
    color: red;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
    padding: 0.25rem 0;
    gap: 0.5rem;
}

.section-header h3 {
    margin: 0;
    line-height: 1.2;
}

.table-filter {
    margin: 0 0 1rem 0;
}

.table-filter input {
    width: 100%;
    margin-bottom: 0;
}

.generate-ai-toggle {
    margin-bottom: 1rem;
}

.btn-auto {
    width: auto;
}

.selected-ingredients-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.selected-ingredient-item {
    display: flex;
    align-items: center;
    background-color: var(--primary-light);
    padding: 0.5rem;
    border-radius: 6px;
    gap: 10px;
}

.ingredient-name {
    flex-grow: 1;
}

.ingredient-proportion {
    width: 80px;
}

input.proportion-input {
    margin-bottom: 0;
    padding: 0.25rem;
    height: auto;
}

.remove-ingredient-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
    border-radius: 50%;
    line-height: 1;
}

.search-container {
    position: relative;
}

.ingredient-search-input {
    margin-bottom: 0;
    background: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    height: auto;
    box-shadow: none;
    color: var(--color);
    -webkit-appearance: none;
    appearance: none;
}

.ingredient-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.ingredient-search-input::placeholder {
    color: var(--muted-color);
}

.dropdown-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 6px var(--shadow-color);
}

.dropdown-item {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.dropdown-item:hover,
.dropdown-item.active {
    background: var(--primary);
    color: #fff;
}

.tag-input {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-background-color);
}

.tag-input input {
    border: none;
    background: transparent;
    padding: 0.25rem 0;
    margin-bottom: 0;
    box-shadow: none;
    min-width: 140px;
}

.tag-chip {
    background: var(--tp-border);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.25rem 0.55rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
}

.tag-remove {
    background: none;
    border: none;
    color: inherit;
    padding: 0;
    margin: 0;
    line-height: 1;
    cursor: pointer;
}

.no-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-background-color);
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    z-index: 10;
}

.th-image {
    width: 100px;
}

/* Admin Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
    align-items: center;
}

.icon-btn {
    padding: 0.4rem;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    margin-bottom: 0;
}

.edit-btn {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* --- New Menu Styles --- */

/* Navigation */
.top-nav {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 100;
    background-color: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
}

.app-logo {
    font-size: 1.3rem;
    font-weight: 700;
}

.top-nav ul li a {
    color: var(--muted-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.top-nav ul {
    gap: 0.5rem;
}

.top-nav ul li {
    padding: 0.5rem 0.5rem;
}

.top-nav ul li a.active {
    background-color: var(--primary);
    color: white;
}

/* Featured Section */
.featured-section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.35rem;
    margin-bottom: 1rem;
    padding-left: 0.5rem;
    border-left: 4px solid var(--primary);
}

.featured-card {
    display: flex;
    flex-direction: row;
    max-width: 100%;
    cursor: pointer;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.featured-image {
    flex: 1;
    max-width: 50%;
    min-height: 200px;
}

.featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: auto;
    will-change: transform; /* GPU acceleration hint */
    transform: translateZ(0); /* Force GPU layer */
    backface-visibility: hidden;
}

.featured-content {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.featured-content .mix-description {
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 3.2em; /* ~2 lines at default line-height */
    min-height: 3.2em;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.product-card {
    cursor: pointer;
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: none; /* Override existing article max-width */
    margin: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.product-card .card-image {
    aspect-ratio: 1;
    overflow: hidden;
}

.product-card .card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: auto;
    will-change: transform; /* GPU acceleration hint */
    transform: translateZ(0); /* Force GPU layer */
    backface-visibility: hidden;
}

.product-card footer {
    padding: 0.8rem 0.5rem;
    text-align: center;
    background: var(--card-background-color);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-height: 80px;
}

.product-card footer strong {
    display: block;
    font-size: 1.2rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    max-width: 100%;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    --text-fit-min: 0.65;
    --text-fit-max: 1.1;
}

.product-card footer small {
    color: var(--muted-color);
    margin-top: 0.2rem;
}

.card-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    width: 100%;
}

.card-chips {
    margin-top: auto;
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Keep mini card tags to a single line without affecting modals/featured */
.product-card .card-chips {
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
    justify-content: center;
}

.product-card .tag-chip {
    flex-shrink: 0; /* prevent chips from squeezing and partially clipping */
}

/* Tobacco List Table */
.tobacco-table-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: var(--card-background-color);
}

.tobacco-table-header {
    flex-shrink: 0;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
}

.tobacco-table-body-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.tobacco-table-body-wrapper::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.tobacco-table-body-wrapper .tobacco-table {
    border: none;
    border-radius: 0;
    margin-bottom: 0;
}

.tobacco-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    background: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.tobacco-table th,
.tobacco-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    height: 5rem;
}

.tobacco-table th {
    font-weight: 600;
    color: var(--text-muted);
    background: var(--card-background-color);
    text-align: left;
}

.tobacco-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.tobacco-table tbody tr:hover {
    background-color: var(--primary-light);
}

.tobacco-table tbody tr.unavailable {
    opacity: 0.65;
}

.tobacco-table .col-image { width: 5.5rem; }
.tobacco-table .col-name { width: 35%; }
.tobacco-table .col-tags { width: auto; }

.tobacco-table th.col-image { text-align: left; }
.tobacco-table td.col-image { text-align: center; }

.tobacco-thumb {
    width: 4rem;
    height: 4rem;
    border-radius: 8px;
    object-fit: cover;
    background: var(--background-color);
}

.table-name {
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-brand {
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-chip-row {
    justify-content: flex-start;
    gap: 0.4rem;
}

/* Align featured card tags to the left */
.featured-card .card-chips {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
}

.featured-card .tag-chip {
    flex-shrink: 0;
}

/* Filters */
.filters-container {
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: flex-start;
    width: 100%;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: nowrap;
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: var(--background-color);
    padding: 0.5rem 0;
    flex-shrink: 0;
}

.filter-dropdown {
    margin-bottom: 0;
    width: auto;
    max-width: 340px;
    display: inline-block;
    flex: 0 1 340px;
}

.view-toggle {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.view-toggle-btn {
    background: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    margin-bottom: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.view-toggle-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    color: var(--text-muted);
}

.view-toggle-btn.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.view-toggle-btn:not(.active):hover {
    border-color: var(--primary);
    color: var(--color);
}

/* High specificity to override PicoCSS defaults */
details[role="list"].filter-dropdown summary {
    margin-bottom: 0;
    border-radius: 10px;
    padding: 0.5rem 0.8rem;
    background-color: var(--card-background-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    list-style: none;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    outline: none;
    box-shadow: none;
    min-height: 42px;
}

details[role="list"].filter-dropdown summary::after {
    display: none; /* Hide Pico's chevron if present via pseudo-element */
}

details[role="list"].filter-dropdown summary::-webkit-details-marker {
    display: none;
}

details[role="list"].filter-dropdown summary:focus {
    box-shadow: none;
    outline: none;
    border-color: var(--primary);
}

details[role="list"].filter-dropdown[open] summary,
details[role="list"].filter-dropdown.has-selection summary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: none; /* Ensure no shadow on active state */
}

.filter-dropdown ul {
    min-width: 200px;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background-color: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow-color);
}

.filter-dropdown ul li {
    padding: 0.2rem 0.5rem;
}

.filter-dropdown ul li label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.filter-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.filter-clear-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: inherit;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    font-size: 1rem;
    line-height: 1;
}

.filter-dropdown[open] .filter-clear-btn,
.filter-dropdown.has-selection .filter-clear-btn {
    background: rgba(255, 255, 255, 0.18);
}

.filter-dropdown.has-selection summary {
    padding-right: 0.6rem;
}

/* Product Modal */
.product-modal {
    width: min(750px, 75vw);
    max-height: 95vh;
    max-height: 95dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

.modal-body {
    display: flex;
    flex-direction: column;
    background-color: var(--card-background-color);
}

.modal-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    overflow: hidden;
}

.modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: auto;
    content-visibility: auto;
    contain: layout paint size style;
}

.modal-details {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    height: 100%;
    flex: 1;
    background-color: var(--card-background-color);
}

.modal-details h4 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: var(--primary);
}

.modal-details ul {
    margin-bottom: 0;
    padding-left: 1rem;
}

.tobacco-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.tobacco-details p {
    margin-bottom: 0;
}

.tobacco-details .chip-row {
    align-items: center;
    justify-content: flex-start;
    min-height: 32px;
}

.description {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 0;
}

@media (min-width: 768px) {
    .modal-body {
        flex-direction: row;
        align-items: stretch;
    }
    .modal-image {
        width: 42%;
        max-width: 320px;
        height: auto;
    }
    .modal-details {
        width: 58%;
        height: auto;
    }
}

/* --- Featured Animation & Sizing --- */

.featured-section {
    margin-bottom: 2rem;
    max-width: 440px; /* Slightly narrower card */
    margin-left: 0;
    margin-right: 0;
}

.featured-card {
    --featured-img-size: clamp(162px, 31.5vw, 216px);
    height: var(--featured-img-size);
    overflow: hidden;
    align-items: stretch;
}

.featured-image {
    flex: 0 0 var(--featured-img-size);
    width: var(--featured-img-size);
    height: 100%;
    aspect-ratio: 1 / 1;
    min-height: 0;
    display: flex;
}

.featured-content {
    padding: 1rem;
    justify-content: center;
    align-items: flex-start;
    min-height: 0;
    min-width: 0;
    gap: 0.5rem;
}

.featured-content h3 {
    font-size: 1.1rem;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    max-width: 100%;
    --text-fit-min: 0.7;
    --text-fit-max: 1.3;
}

.featured-desc {
    font-size: 0.85rem;
    margin-bottom: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    color: var(--text-muted);
    text-overflow: ellipsis;
    max-height: 2.6em;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Fade Transition */
.fade-enter-active,
.fade-leave-active {
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-enter-from {
    opacity: 0;
    transform: translateX(20px);
}

.fade-leave-to {
    opacity: 0;
    transform: translateX(-20px);
}

/* Reduce form input spacing */
form input,
form select,
form textarea,
form label {
    margin-bottom: 0.3rem;
}

/* Tag input chips */
.tag-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
    gap: 0.35rem;
    min-height: 44px;
    padding: 0.4rem 0.5rem;
    background: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: text;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.tag-input:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.tag-input input {
    flex: 1;
    min-width: 140px;
    border: none;
    background: transparent;
    box-shadow: none;
    margin-bottom: 0;
    padding: 0.35rem 0;
    height: auto;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    background: var(--primary-light);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.9rem;
}

.tag-chip-unavailable {
    background: rgba(184, 112, 112, 0.18);
    border-color: var(--danger-color);
    color: #ffd6d6;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
    margin-bottom: 0.3rem;
    justify-content: flex-start;
}

.chip-sm {
    padding: 0.22rem 0.50rem;
    font-size: 0.9rem;
}

/* Modal-specific tag tweaks */
.modal-details .chip-row {
    justify-content: flex-start;
}

.modal-details .tag-chip,
.modal-details .chip-sm {
    padding: 0.35rem 0.8rem;
    font-size: 1rem;
}

.tag-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 0.9rem;
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 auto;
    border-radius: 50%;
}

.tag-suggestions {
    position: absolute;
    background: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 16px var(--shadow-color);
    z-index: 20;
    overflow: hidden;
    margin: 0; /* override Pico */
    display: inline-block;
    width: max-content;
    min-width: 0;
    max-width: 320px;
    white-space: nowrap;
}

.tag-suggestion-item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 0.6rem 0.75rem;
    color: var(--text-color);
    cursor: pointer;
    margin: 0; /* override Pico */
}

.tag-suggestion-item:hover,
.tag-suggestion-item.active {
    background: var(--primary-light);
}

.tag-remove:hover {
    color: #fff;
}

/* Admin Image Upload Preview */
.image-upload-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.image-upload-container.bulk {
    gap: 0.5rem;
}

.image-preview-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 1rem;
}

.image-preview-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
}

.bulk .image-preview-thumb {
    width: 50px;
    height: 50px;
}

.remove-image-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    padding: 0;
    width: 16px;
    height: 16px;
    font-size: 10px;
    line-height: 1;
    border-radius: 50%;
    background: red;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bulk-file-input {
    width: 180px;
}

/* Admin Layout Helpers */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-header .btn-auto {
    margin-top: 0.2rem;
    margin-bottom: 0.2rem;
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
    line-height: 1.1;
}

.modal-content.bulk-modal {
    max-width: 800px;
}

/* Settings Page Styles */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.settings-card {
    max-width: none;
    margin: 0;
}

.settings-card header {
    border-bottom: 1px solid var(--border-color);
}

.settings-card header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--heading-color);
}

/* Lounge Name Form */
.lounge-name-form {
    padding: 1rem;
}

.lounge-name-form .input-group {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.lounge-name-form .input-group input[type="text"] {
    flex: 1;
    margin: 0;
}

.lounge-name-form .input-group button {
    flex-shrink: 0;
}

.lounge-name-form .help-text {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.color-settings-form {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.color-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.color-input-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-input-wrapper input[type="color"] {
    width: 48px;
    height: 48px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
    flex-shrink: 0;
}

.color-input-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 4px;
}

.color-input-wrapper input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.color-text-input {
    flex: 1;
    font-family: monospace;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
}

/* Categories Page Styles */
.add-category-form {
    margin-bottom: 1.5rem;
}

.category-input-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.category-input-row input {
    flex: 1;
    max-width: 400px;
    margin-bottom: 0;
}

.category-input-row button {
    margin-bottom: 0;
    white-space: nowrap;
}

.categories-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.category-card {
    background: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: visible;
    transition: box-shadow 0.2s;
}

.category-card.dragging {
    opacity: 0.5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--tp-primary-light);
    border-bottom: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
}

.category-header .drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.2rem;
    user-select: none;
}

.category-header .drag-handle:active {
    cursor: grabbing;
}

.category-name {
    flex: 1;
    font-weight: 600;
    color: var(--heading-color);
    font-size: 1.1rem;
}

.category-name-input {
    flex: 1;
    margin: 0;
    margin-bottom: 0 !important;
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
}

.category-actions {
    display: flex;
    gap: 0.5rem;
}

.category-mixes {
    padding: 0.75rem;
    min-height: 60px;
    position: relative;
}

.category-mix-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    transition: background-color 0.2s;
}

.category-mix-item:hover {
    background: var(--tp-primary-light);
}

.category-mix-item.dragging {
    opacity: 0.5;
}

.category-mix-item .drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 0.9rem;
    user-select: none;
}

.category-mix-item .drag-handle:active {
    cursor: grabbing;
}

.category-mix-item .mix-name {
    flex: 1;
    color: var(--text-color);
}

.remove-mix-btn {
    background: none;
    border: none;
    color: var(--tp-danger);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
    margin: 0;
    margin-bottom: 0;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
    width: auto;
}

.remove-mix-btn:hover {
    opacity: 1;
}

.add-mix-to-category {
    margin-top: 0.5rem;
}

.add-mix-to-category .search-container {
    position: relative;
}

.add-mix-to-category input {
    margin-bottom: 0;
    font-size: 0.9rem;
}

.category-mix-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.category-mix-dropdown .dropdown-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.category-mix-dropdown .dropdown-item:hover,
.category-mix-dropdown .dropdown-item.highlighted {
    background: var(--tp-primary-light);
}

.empty-categories {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-categories p {
    margin: 0;
}

/* Category section on main menu */
.category-section {
    margin-bottom: 2rem;
}