/* ─── Design tokens (CSS custom properties) ────────────────────────────────── */
:root {
    /* Backgrounds / surfaces - Light mode with high contrast, based on #d3ba93 */
    --color-bg-base:             #ffffff;  /* page root background - pure white   */
    --color-surface-1:           #f8f4f0;  /* form inputs, cancel buttons          */
    --color-surface-2:           #f0e8dd;  /* secondary panels                     */
    --color-surface-hover:       #d8c9b8;  /* hover for surface-2 items            */
    --color-surface-1-hover:     #eee2d5;  /* hover for surface-1 items            */
    --color-surface-table-even:  #f5eadc;  /* alternating table row background     */
    --color-surface-3:           #e8dfd4;  /* deep panel background                */
    --color-surface-deep:        #e0d6c9;  /* slide-in picker panel background     */
    --color-surface-input:       #faf5ee;  /* compact inline inputs (qty, etc.)    */
    --color-surface-4:           #b8986f;  /* table headers                        */

    /* Navigation - Dark theme for strong contrast with content */
    --color-nav-bg:              #2c241c;  /* Dark menu background                 */
    --color-nav-bg-2:            #362d23;  /* Dark menu background                 */
    --color-nav-text:            #ffffff;  /* Light text on dark nav               */
    --color-nav-text-muted:      #b8986f;  /* Muted text on dark nav               */
    --color-nav-hover:           #5a4a3b;  /* Hover background for nav items        */

    /* Text - Maximum contrast for readability */
    --color-text:                #000000;  /* primary text - pure black             */
    --color-text-muted:          #444444;  /* secondary labels - much darker        */
    --color-text-muted-2:        #666666;  /* tertiary labels (recipe meta)        */
    --color-text-muted-3:        #888888;  /* icon buttons, collapse arrows          */
    --color-text-faint:          #aaaaaa;  /* empty-state messages                 */
    --color-text-faint-white:    rgba(26, 26, 26, 0.9);   /* auth brand subtitle   */
    --color-text-ghost-white:    rgba(26, 26, 26, 0.60);  /* list action links     */

    /* Accent — primary action buttons and links - BRAND COLOR */
    --color-accent:              #d3ba93;  /* Main brand color                     */
    --color-accent-hover:        #c1a885;  /* Slightly darker for hover            */
    --color-text-on-accent:      #1a1a1a;  /* Dark text on accent                  */
    --color-text-on-accent-2:    #fafafa;  /* White text on accent                 */

    /* Primary — tags, focus rings, active markers */
    --color-primary:             #b8986f;  /* Darker than brand for contrast       */
    --color-primary-light:       #d3ba93;  /* BRAND COLOR for highlighted tags     */
    --color-primary-shadow:      rgba(184, 152, 111, 0.30);
    --color-primary-bg:          rgba(184, 152, 111, 0.15);
    --color-primary-selected:    #1c1610;  /* Very dark for selected state */
    
    /* Tag highlighting - high contrast with brand color text */
    --color-tag-highlight-bg:     #1c1610;  /* Dark background for highlighted tags */
    --color-tag-highlight-text:  #d3ba93;  /* BRAND COLOR text on dark */

    /* Danger — destructive actions - Strong red */
    --color-danger-bg:           #c93737;
    --color-danger-bg-hover:     #e03f3f;
    --color-danger-text:         #ffffff;

    /* Validate / confirm - Vibrant green */
    --color-validate:            #4a9d4a;
    --color-validate-hover:      #3a8d3a;
    --color-validate-text:       #ffffff;

    /* Form chrome - Errors in red */
    --color-required:            #ff4444;  /* required-field asterisk              */
    --color-error-bg:            rgba(255, 68, 68, 0.10);
    --color-error-border:        rgba(255, 68, 68, 0.35);
    --color-error-shadow:        rgba(255, 68, 68, 0.15);
    --color-info-bg:             rgba(74, 157, 74, 0.10);
    --color-info-border:         rgba(74, 157, 74, 0.20);

    /* Shadows & overlays - Subtle for light mode */
    --color-shadow-heavy:        rgba(0, 0, 0, 0.15);
    --color-shadow-medium:       rgba(0, 0, 0, 0.10);
    --color-shadow-subtle:       rgba(0, 0, 0, 0.05);
    --color-backdrop:            rgba(0, 0, 0, 0.30);
}

/* Used on: All pages (global reset)
   Affects: global
*/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Used on: All pages (overall page layout)
   Affects: global
*/
body {
    display: flex;
    height: 100vh;
    background-color: var(--color-bg-base);
    color: var(--color-text);
}

/* Used on: Form groups within forms
   Affects: global
*/
.form-group { margin-bottom: 14px; display:flex; flex-direction:column; }
.form-group label { margin-bottom:6px; color:var(--color-text); font-size:0.95rem; font-weight: 600; }
.form-group label span[aria-hidden="true"] { color:var(--color-required); margin-left:2px; }
/* input and select share identical chrome */
.form-group input, .form-group select { padding:10px 12px; border-radius:6px; border:none; background:var(--color-surface-1); color:var(--color-text); }
.cancel-link { padding: 8px 12px; background-color: var(--color-surface-1); border-radius:6px; color:var(--color-text); text-decoration:none; font-size:0.9rem; }
.cancel-link:hover { text-decoration:none; background: var(--color-surface-1-hover); }
.action-link { padding: 8px 12px; background: var(--color-accent); border-radius:6px; color: var(--color-text-on-accent); text-decoration:none; font-size:0.9rem; }
.action-link:hover { text-decoration:none; background: var(--color-accent-hover); }
.submit-btn { padding: 10px 16px; background: var(--color-accent); color: var(--color-text-on-accent); border-radius: 6px; border: none; cursor: pointer; }
.submit-btn:hover { background: var(--color-accent-hover); }
.delete-btn { background: var(--color-danger-bg); color: var(--color-danger-text); }
.delete-btn:hover { background: var(--color-danger-bg-hover); }
.validate-btn { background: var(--color-validate); color: var(--color-validate-text); }
.validate-btn:hover { background: var(--color-validate-hover); }
.form-result {
    display: none;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 0.95rem;
}
.form-result.visible { display: block; }
/* Inline message variant — always hidden; shown only at desktop breakpoint */
.inline-msg { display: none !important; }
.form-result.error {
    background-color: var(--color-error-bg);
    color: var(--color-danger-bg);
    border: 1px solid var(--color-error-border);
}
.form-result.info {
    background-color: var(--color-info-bg);
    color: var(--color-validate);
    border: 1px solid var(--color-info-border);
    
}
.input-invalid {
    box-shadow: 0 0 0 3px var(--color-error-shadow);
    border-radius: 6px;
}
/* Used in: Action buttons area
   Affects: global
*/
.actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.actions a {
    text-decoration: none;
}

/* Used on: Authentication/login layout
   Affects: login.html
*/
.auth-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}
.auth-left {
    flex: 1;
    background-color: var(--color-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}
.auth-left .brand {
    color: var(--color-text);
    text-align: center;
    font-size: 28px;
    font-weight: 700;
}
.auth-left .brand small {
    display: block;
    color: var(--color-text-faint-white);
    margin-top: 6px;
    font-weight: 400;
}
.auth-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background-color: var(--color-surface-2);
    padding: 28px;
    border-radius: 8px;
    box-shadow: 0 8px 20px var(--color-shadow-heavy);
}
.auth-card h1 {
    margin-bottom: 18px;
    color: var(--color-text);
    font-size: 1.6em;
}
.auth-actions { display:flex; justify-content:space-between; align-items:center; margin-top:12px; }
.auth-actions .forgot { color:var(--color-text); text-decoration:none; font-size:0.9rem; }
.auth-actions .forgot:hover { text-decoration:underline; }
/* .auth-actions uses the global .submit-btn class — no separate color override needed */
.logo {
    width: 300px;
}

/* Used in: app/templates/nav.html
   Affects: global except login page
*/
nav {
    width: 220px;
    background-color: var(--color-nav-bg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
nav a {
    color: var(--color-nav-text-muted);
    text-decoration: none;
    padding: 10px;
    border-radius: 5px;
    transition: background 0.2s, color 0.2s;
}
nav a:hover {
    background-color: var(--color-nav-hover);
    color: var(--color-nav-text);
}
nav a img {
    display: inline;
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 8px;
}
nav a span {
    display: inline;
}
/* Used in: nav.html
   Affects: global except login
*/
.login {
    margin-top: auto;
    padding: 10px;
    border-radius: 5px;
    background-color: var(--color-nav-bg);
    color: var(--color-nav-text);
    cursor: pointer;
    position: relative;
    border: 1px solid var(--color-primary-shadow);
}
.login img {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 5px;
}
.login:hover {
    background-color: var(--color-nav-hover);
}
.login span {
    display: block;
    font-size: 0.9em;
    color: var(--color-nav-text-muted);
}
.login-popup {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    background-color: var(--color-nav-bg-2);
    border-radius: 5px;
    padding: 10px;
    min-width: 150px;
    box-shadow: 0 4px 8px var(--color-shadow-heavy);
    z-index: 10;
}
.login-popup a {
    display: block;
    color: var(--color-nav-text);
    text-decoration: none;
    padding: 10px 5px;
    transition: color 0.2s, background-color 0.2s;
}
.login-popup a:hover {
    color: var(--color-nav-text);
    background-color: var(--color-nav-hover);
}
.login-popup .username {
    display: none;
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--color-nav-text);
}
.login-popup .role {
    display: none;
    margin-bottom: 5px;
    color: var(--color-nav-text-muted);
}

/* Used on: Page content containers in templates (main content area)
   Affects: global
*/
main {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}


/* Used on: Search and tag filter controls at top of list pages
   Affects: products.html, recipes.html, shopping_list_create.html, shopping_lists.html, suppliers.html
*/
.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.filters input,
.filters select {
    padding: 8px 10px;
    border-radius: 5px;
    border: none;
    background-color: var(--color-surface-1);
    color: var(--color-text);
}
.filters button {
    padding: 8px 10px;
    border-radius: 5px;
    border: none;
    background-color: var(--color-surface-2);
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.2s;
}
.filters button:hover {
    background-color: var(--color-surface-hover);
}
.filters button:focus {
    outline: 2px solid var(--color-primary);
}

/* Used on: List tables throughout the app
   Affects: products.html, suppliers.html, shopping_lists.html
*/
table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--color-surface-1);
    border-radius: 8px;
    overflow: hidden;
}
table thead {
    background-color: var(--color-surface-4);
    color: var(--color-text-on-accent-2);
}
table th, table td {
    padding: 12px 15px;
    text-align: left;
}
table tbody tr:nth-child(even) {
    background-color: var(--color-surface-table-even);
}
table tbody tr:hover {
    background-color: var(--color-surface-hover);
}

/* Used on: tag link lists and tags within entries
   Affects: products.html, recipes.html, shopping_list_create.html
*/
.tag {
    display: inline-block;
    background-color: var(--color-primary);
    color: var(--color-text-on-accent-2);
    padding: 2px 8px;
    margin-right: 5px;
    border-radius: 3px;
    font-size: 0.8em;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}
.tag.highlight {
    background-color: var(--color-tag-highlight-bg);
    color: var(--color-tag-highlight-text);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(211, 186, 147, 0.3);
}
.tag-link {
    text-decoration: none;
    margin-bottom: 5px;
}

/* Tag-list containers — margin replaces style="margin:…" inline attributes removed from HTML.
   The .form-tag-list variant is used inside form panels (tighter spacing). */
#tag-list, #picker-tag-list, #main-tag-list { margin: 12px 0 18px; }
#recipe-tag-list, .form-tag-list { margin: 8px 0 0; }

/* Used on: Created dynamically by JS autocomplete logic. Appended to the .filters element;
   not present in templates until JS runs.
   Note: left/top/width are set by JS at runtime (computed from input's DOM position)
         and cannot be expressed as static CSS.
   Affects: products.js, recipes.js, shopping_lists.js, suppliers.js
*/
.autocomplete-popup {
    position: absolute;
    background-color: var(--color-surface-1);
    color: var(--color-text);
    border: 1px solid var(--color-surface-hover);
    max-height: 150px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 4px var(--color-shadow-subtle);
}
.autocomplete-item {
    padding: 5px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-surface-hover);
}
.autocomplete-item:hover {
    background-color: var(--color-surface-hover);
}
.autocomplete-more {
    padding: 5px 10px;
    color: var(--color-text-muted);
    font-size: 0.9em;
    border-top: 1px solid var(--color-surface-hover);
}

/* Used on: Updated by JS to show number of visible results
   Affects: products.html, shopping_list_create.html, shopping_lists.html, suppliers.html, recipes.html
*/
#results-counter, #main-results-counter {
    margin: 10px 0;
    color: var(--color-text-muted);
}

/* Used on: Grid of recipe preview cards 
   Affects: recipes.html and shopping_list_create.html
*/
.recipe-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 20px;
}
.recipe-card {
    position: relative;
    background-color: var(--color-surface-2);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 8px var(--color-shadow-heavy);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--color-surface-2);
}
.recipe-card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
}
.recipe-card-actions a img {
    width: 24px;
    height: 24px;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.recipe-card-actions a:hover img {
    opacity: 1;
}
.recipe-card:hover {
    transform: translateY(-5px);
    background-color: var(--color-surface-2);
}
.recipe-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.recipe-select { display: flex; align-items: center; gap: 8px; }
.recipe-selection-controls { display: none; align-items: center; gap: 8px; }
.recipe-selection-controls label { color: var(--color-text-muted); font-size: 0.95em; margin-right: 6px; }
.recipe-selection-controls .recipe-qty { width: 70px; padding: 6px 8px; border-radius: 6px; border: none; background:var(--color-surface-input); color:var(--color-text) }
.recipe-card.selected {
    border: 3px solid var(--color-accent);
    background-color: var(--color-surface-hover);
    box-shadow: 0 4px 12px var(--color-primary-shadow);
}
.recipe-name {
    font-size: 1.2em;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--color-text);
}
.recipe-description {
    color: var(--color-text-muted);
    margin-bottom: 10px;
}
.recipe-details {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}
.recipe-yield, .recipe-time, .recipe-date {
    font-size: 0.9em;
    color: var(--color-text-muted-2);
}
.recipe-tags {
    margin-top: 10px;
}

.recipe-ingredients {
    margin-top: 20px;
    color: var(--color-text-muted);
}
.recipe-ingredients-title {
    color: var(--color-text);
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}
.recipe-ingredients-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.recipe-ingredient-item {
    font-size: 0.95em;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}
.recipe-no-ingredients {
    font-size: 0.95em;
    color: var(--color-text-faint);
}

/* Used on: Panel layout for create page (independent from auth classes)
   Affects: shopping_list_create.html */
.panel-page { padding: 20px; }
.panel {
    background-color: var(--color-surface-3);
    padding: 28px;
    border-radius: 8px;
    box-shadow: 0 8px 20px var(--color-shadow-heavy);
    width: 100%;
    border: 1px solid var(--color-surface-2);
}
/* .panel .form-group and .panel .form-group label intentionally omitted:
   they are identical to the global .form-group rules and would be redundant. */
.panel .form-group input, .panel .form-group textarea { padding:10px 12px; border-radius:6px; border:none; background:var(--color-surface-1); color:var(--color-text); }
.panel table .form-group { margin-bottom: 0; }
/* Table inputs and all textareas get an explicit border for visual separation */
.panel table .form-group select { padding:10px 12px; border-radius:6px; border:none; background:var(--color-surface-1); color:var(--color-text); border: 1px solid var(--color-surface-hover); }
.panel table .form-group input, .panel .form-group textarea { padding:10px 12px; border-radius:6px; border:none; background:var(--color-surface-1); color:var(--color-text); border: 1px solid var(--color-surface-hover); }
.panel-actions { display:flex; justify-content:space-between; align-items:center; margin-top:12px; }

/* Used on: Layout of create form for shopping list creation
   Affects: shopping_list_create.html, shopping_list_update.html
*/
.shopping-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 20px;
}
.shopping-list-header h1 { margin: 0 0 10px 0; font-size: 1.5em; }
.shopping-list-form-top-actions { display: flex; justify-content: flex-end; gap: 10px; }
.shopping-list-two-col { display: flex; gap: 20px; margin-bottom: 12px; }
.shopping-list-two-col .col { flex: 1; min-width: 0; }
.shopping-list-two-col .form-group { margin-bottom: 10px; }
.field-label { margin-bottom: 6px; color: var(--color-text); font-size: 0.95rem; display: block; font-weight: 600; }
.field-value { padding: 10px 12px; border-radius: 6px; background: var(--color-surface-1); color: var(--color-text); border: 1px solid var(--color-surface-hover); min-height: 40px; }
.field-value--multiline { white-space: pre-wrap; min-height: 90px; }
.shopping-list-recipes-title {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--color-text);
}
.shopping-list-update {
    text-align: right;
}
.shopping-list-update a {
    margin-right: 20px;
    font-size: 1.5em;
    color: var(--color-text-ghost-white);
    text-decoration: none;
}

/* Used on: Checkout page checkbox column and unchecked-only filter label
   Affects: shopping_list_checkout.html
*/
.product-check { width: 36px; text-align: center; }
.product-check input[type="checkbox"] { cursor: pointer; width: 16px; height: 16px; }
.unchecked-filter-label { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--color-text); cursor: pointer; white-space: nowrap; font-weight: 600; }
.unchecked-filter-label input[type="checkbox"] { cursor: pointer; width: 16px; height: 16px; }

/* Used on: Per-item comment icon and inline panel on the checkout page
   Affects: shopping_list_checkout.html
*/
.product-comment { width: 40px; text-align: center; }
.comment-cell { position: relative; display: flex; align-items: center; justify-content: center; }
.comment-btn { background: none; border: none; cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; position: relative; }
.comment-btn img { width: 16px; height: 16px; display: block; opacity: 0.7; }
.comment-btn:hover img { opacity: 1; }
.comment-badge { position: absolute; top: 0; right: 0; font-size: 0.8rem; color: var(--color-text); font-weight: 700; line-height: 1; pointer-events: none; text-shadow: 0 0 3px rgba(0,0,0,0.8); }
.comment-panel { position: fixed; z-index: 1000; background: var(--color-surface-2); border: 1px solid var(--color-primary); border-radius: 6px; padding: 8px; min-width: 220px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.comment-textarea { background: var(--color-surface-input); color: var(--color-text); border: 1px solid var(--color-surface-hover); border-radius: 4px; padding: 6px 8px; font-size: 0.85rem; font-family: inherit; resize: vertical; width: 100%; box-sizing: border-box; }
.comment-textarea:focus { outline: 1px solid var(--color-primary); border-color: var(--color-primary); }
.comment-confirm-btn { align-self: flex-end; padding: 4px 14px; background: var(--color-accent); color: var(--color-text); border: none; border-radius: 4px; cursor: pointer; font-size: 0.85rem; font-family: inherit; font-weight: 600; }
.comment-confirm-btn:hover { background: var(--color-primary); color: var(--color-text); }
.comment-panel--readonly { min-width: 200px; max-width: 300px; }
.comment-text-readonly { background: var(--color-surface-input); color: var(--color-text); border: 1px solid var(--color-surface-hover); border-radius: 4px; padding: 6px 8px; font-size: 0.85rem; font-family: inherit; white-space: pre-wrap; word-wrap: break-word; width: 100%; box-sizing: border-box; }

/* Used on: Layout of update form for shopping list
   Affects: shopping_list_update.html
*/
.product-remove { width:48px; }
.product-remove .cancel-link { padding:6px 8px; font-weight:700; }
.product-remove .form-group { margin:0; }
.product-remove .item-remove-toggle { display:flex; align-items:center; justify-content:center; padding:6px 8px; }
.product-remove .item-remove-toggle img { width:18px; height:18px; display:block; }
.readonly-supplier { padding:10px 12px; border-radius:6px; background:var(--color-surface-input); color:var(--color-text); }
.row-disabled { opacity: 0.45; }
.row-disabled .product-name, .row-disabled .product-category, .row-disabled .product-quantity, .row-disabled .product-unit, .row-disabled .product-supplier, .row-disabled .product-tags { text-decoration: line-through; }
.product-name label { cursor: pointer; }
.sl-mobile-category { display: none; }
.item-pending-hide td:not(.product-comment) { opacity: 0.25; transition: opacity 0.7s ease; }
.item-pending-hide td.product-comment { opacity: 1; transition: none; }

/* Used on: Rows with unsaved local changes on the checkout page
   Affects: shopping_list_checkout.html
*/
table tbody tr.item-unsaved {
    border-left: 4px solid var(--color-accent);
    background-color: var(--color-primary-bg);
}

/* Used on: Archive form on the checkout page; hidden until all items are checked and saved
   Affects: shopping_list_checkout.html
*/
.archive-btn-form {
    display: none;
}

/* Hidden delete confirmation forms — replaces style="display:none;" inline attributes */
#product-delete-form,
#supplier-delete-form,
#recipe-delete-form {
    display: none;
}
/* Save-checkout form rendered inline — replaces style="display:inline;" inline attribute */
#save-checkout-form {
    display: inline;
}

/* Used on: Collapsible metadata panel (project, production, dates) on the shopping list update page
   Affects: shopping_list_update.html, shopping_list_checkout.html
*/
.metadata-panel {
    margin: 0;
}
/* Visual styles provided by .sl-section-title; kept for JS targeting */
.metadata-panel-toggle {
    font-size: inherit;
    font-family: inherit;
}
.metadata-panel-arrow {
    display: inline-block;
    font-size: 0.75rem;
    transition: transform 0.2s ease;
    color: var(--color-text-muted-3);
    flex-shrink: 0;
}
.metadata-panel-arrow.open {
    transform: rotate(180deg);
}
.metadata-panel-body {
    padding: 10px 0 20px 12px;
}

/* Used on: Section subtitles on shopping list pages
   Affects: shopping_list_create.html, shopping_list_update.html, shopping_list_checkout.html
*/
.sl-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text);
    padding: 6px 0 6px 12px;
    border-left: 4px solid var(--color-accent);
    border-top: none;
    border-right: none;
    border-bottom: none;
    margin: 0 0 14px;
    background: none;
    text-align: left;
    user-select: none;
}
button.sl-section-title {
    width: 100%;
    cursor: pointer;
}
button.sl-section-title:hover {
    color: var(--color-primary);
}
.recipe-list-top-actions .sl-section-title,
.product-list-top-actions .sl-section-title {
    margin: 0;
}
.metadata-panel + .sl-section-title {
    margin-top: 20px;
}

/* Used on: Header row wrapping the 'Liste des produits' title and 'Add products' button
   Affects: shopping_list_update.html
*/
.shopping-list-products-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0 12px;
}

/* Used on: Row above the filter area containing the "Ajouter des produits" button
   Affects: shopping_list_update.html
*/
.product-list-top-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
/* .product-list-top-actions .section-title removed: templates use .sl-section-title, not .section-title */

/* #add-products-btn uses the global .submit-btn class — no separate color override needed */

/* Used on: Secondary (cancel-style) button elements
   Affects: shopping_list_update.html (picker panel cancel button)
*/
.secondary-btn {
    padding: 8px 12px;
    background-color: var(--color-surface-1);
    border-radius: 6px;
    border: none;
    color: var(--color-text);
    font-size: 0.9rem;
    cursor: pointer;
}
.secondary-btn:hover {
    background: var(--color-surface-1-hover);
}

/* Used on: Slide-in product picker overlay panel on the shopping list update page
   Affects: shopping_list_update.html
*/
#picker-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--color-backdrop);
    z-index: 400;
}
#picker-backdrop.active {
    display: block;
}
#product-picker-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 80%;
    max-width: 100vw;
    background-color: var(--color-surface-deep);
    border-left: 1px solid var(--color-surface-2);
    padding: 24px 20px 20px;
    overflow-y: auto;
    z-index: 500;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}
#product-picker-panel.open {
    transform: translateX(0);
}
.picker-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-surface-2);
}
.picker-panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
}
.picker-close-btn {
    background: none;
    border: none;
    color: var(--color-text-muted-3);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}
.picker-close-btn:hover {
    background: var(--color-surface-1);
    color: var(--color-text);
}
.picker-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}
/* .picker-actions .submit-btn and hover intentionally omitted — identical to global .submit-btn rules */
#picker-results-counter {
    margin: 10px 0;
    color: var(--color-text-muted);
}

/* Used on: Header row wrapping the recipe list title and 'Add recipes' button
   Affects: shopping_list_create.html
*/
.recipe-list-top-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

/* #add-recipes-btn uses the global .submit-btn class — no separate color override needed */

/* Used on: Main recipe list table columns on shopping_list_create.html */
.recipe-remove-col { width: 48px; }
.recipe-remove { width: 48px; }
.recipe-remove .recipe-remove-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
}
.recipe-remove .recipe-remove-link img { width: 18px; height: 18px; display: block; }

/* Used on: Slide-in recipe picker overlay panel on shopping_list_create.html
   Affects: shopping_list_create.html
*/
#recipe-picker-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 80%;
    max-width: 100vw;
    background-color: var(--color-surface-deep);
    border-left: 1px solid var(--color-surface-2);
    padding: 24px 20px 20px;
    overflow-y: auto;
    z-index: 500;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}
#recipe-picker-panel.open {
    transform: translateX(0);
}

/* Used on: Inline-edit user table on parameters.html
   Affects: parameters.html
*/
.param-col-username { width: 30%; }
.param-col-role     { width: 30%; }
.param-actions-col {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
    text-align: right;
}
.param-actions-col .param-edit-btn {
    color: var(--color-text-ghost-white);
    text-decoration: none;
    line-height: 0;
}
.param-actions-col .param-edit-btn img {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.param-actions-col .param-edit-btn:hover img { opacity: 1; }
.param-actions-col .param-edit-btn.param-locked { cursor: default; pointer-events: none; }
.param-actions-col .param-edit-btn.param-locked img { opacity: 0.2; transition: none; }
#add-user-link.param-locked { opacity: 0.35; pointer-events: none; cursor: default; }

/* Read/edit mode toggling — driven by .editing class added by parameters.js */
.param-edit-only { display: none; }
.param-row.editing .param-edit-only { display: inline-block; }
.param-row.editing .param-read-only { display: none; }

.param-col-username .param-edit-only,
.param-col-role .param-edit-only {
    width: 100%;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--color-surface-hover);
    background: var(--color-surface-1);
    color: var(--color-text);
}

.param-save-btn { padding: 8px 12px; font-size: 0.9rem; }

/* Inline new-user row (parameters.html) */
.param-new-input {
    width: 100%;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--color-surface-hover);
    background: var(--color-surface-1);
    color: var(--color-text);
    font-size: 0.9rem;
}
.param-add-user-wrapper {
    margin-top: 12px;
}

/* Mobile-only action row (shown below the data row when editing) */
.param-actions-row { display: none; }
.param-actions-cell {
    padding-bottom: 10px;
}
.param-actions-cell .label-mobile {
    display: none;
}

/* Dashboard styles */
.dashboard {
    margin: 20px 0;
}

.dashboard-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.tile {
    background-color: var(--color-surface-2);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 12px var(--color-shadow-medium);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--color-surface-1);
}

.tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--color-shadow-heavy);
}

.tile h3 {
    color: var(--color-text);
    font-size: 1.1rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.tile-value {
    font-size: 4rem;
    font-weight: bold;
    color: var(--color-text);
    text-align: center;
    margin: 10px 0;
}

.tile-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-align: center;
    margin-top: 5px;
}

.tile-content {
    color: var(--color-text);
}

.supplier-info {
    font-size: 1rem;
    margin: 8px 0;
    padding: 6px;
    background-color: var(--color-surface-1);
    border-radius: 4px;
    color: var(--color-text-muted);
}

.tile .supplier-name {
    color: var(--color-text);
}

.supplier-info:first-child {
    margin-top: 0;
}


/* Responsive */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        font-size: 14px;
    }
    .filters {
        flex-direction: column;
        gap: 15px;
    }
    .filters button {
        order: -1;
    }
    .actions {
        flex-direction: column;
        gap: 15px;
    }
    nav {
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 10px;
        gap: 10px;
    }
    nav a {
        flex: 1;
        text-align: center;
        padding: 10px 5px;
    }
    nav a img {
        display: inline;
        margin: 0;
    }
    nav a span {
        display: none;
    }
    .login {
        margin-top: 0;
        flex: none;
        width: 40px;
        height: 40px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }
    .login b, .login span {
        display: none;
    }
    .login img {
        margin: 0;
    }
    .login-popup {
        bottom: auto;
        top: 100%;
        right: 0;
        left: auto;
        transform: none;
    }
    .login-popup .username {
        display: block;
        text-align: center;
    }
    .login-popup .role {
        display: block;
        text-align: center;
    }
    .logo {
        width: 250px;
    }
    .desktop-only {
        display: none;
    }
    .product-tags {
        display: none;
    }
    .recipe-cards {
        grid-template-columns: 1fr;
    }

    .auth-container { flex-direction: column; }
    .auth-left { display: flex; flex: none; height: 25vh; background-color: var(--color-surface-2); align-items: center; justify-content: center; padding: 24px; }
    .auth-left .brand { font-size: 22px; }
    .auth-right { padding: 12px 20px; width: 100%; height: calc(75vh); display: flex; align-items: flex-start; justify-content: center; }
    .auth-card { padding: 20px; margin-top: 30%; }

    /* .two-col removed: no template uses this class; all use .shopping-list-two-col */
    .form-top-actions { justify-content: center; gap: 8px; width: 100%; margin-top: 12px; margin-bottom: 20px; }
    .form-top-actions { flex-direction: row; }
    .form-top-actions .cancel-link, .form-top-actions .submit-btn, .action-link {
        display: block;
        flex: 1 1 0;
        min-width: 0;
        text-align: center;
    }
    .shopping-list-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .shopping-list-form-top-actions {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
    }
    .shopping-list-form-top-actions .inline-msg.visible {
        display: block !important;
        flex-basis: 100%;
        margin-bottom: 8px;
    }
    .shopping-list-form-top-actions .form-result.visible {
        flex-basis: 100%;
        margin-bottom: 8px;
    }
    .shopping-list-form-top-actions .cancel-link,
    .shopping-list-form-top-actions .submit-btn {
        flex: 1 1 0;
        min-width: 0;
        text-align: center;
    }
    .shopping-list-products-header {
        flex-direction: column;
        align-items: stretch;
    }
    .product-list-top-actions > *,
    .recipe-list-top-actions > * {
        flex: 1 1 50%;
        min-width: 0;
    }
    .picker-actions {
        width: 100%;
    }
    .picker-actions .submit-btn {
        flex: 1 1 0;
        min-width: 0;
        text-align: center;
    }
    #product-picker-panel {
        width: 100vw;
    }
    #recipe-picker-panel {
        width: 100vw;
    }
    .recipe-yield-col, .recipe-yield-cell,
    .recipe-date-col, .recipe-date-cell,
    .recipe-tags-col, .recipe-tags-cell { display: none; }
    #main-recipes-table .recipe-qty-cell input[type="number"] { width: 90px; }
    .sl-mobile-category { display: inline; }
    .product-quantity input[type="number"] { width: 90px; }
    .panel table th, .panel table td { padding: 12px 5px; }

    /* parameters: show action buttons on a new row when editing/adding a user */
    .param-row.editing + .param-actions-row,
    #user-create-row + .param-actions-row { display: table-row; }
    .param-row.editing .param-actions-col .param-edit-only { display: none; }
    #user-create-row .param-actions-col { display: none; }
    .param-actions-cell .submit-btn,
    .param-actions-cell .cancel-link {
        flex: 1 1 40%;
        min-width: 0;
        text-align: center;
    }
    
    .param-actions-cell .label-mobile {
        display: inline;
    }   
    .param-actions-cell .label-desktop {
        display: none;
    }

    .dashboard-tiles {
        grid-template-columns: 1fr;
    }
    
    .tile-value {
        font-size: 1.5rem;
    }
}

/* Desktop-only: increase tag filter input width without affecting mobile/tablet */
@media (min-width: 769px) {
    /* Grid layout: filters row and tag list below */
    .product-filter-area {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-areas:
            "filters"
            "tags";
    }
    .product-filter-area .filters {
        grid-area: filters;
        margin-bottom: 0;
    }
    .product-filter-area #tag-list {
        grid-area: tags;
    }
    /* Make the tag filter input wider and push action buttons to the right */
    .filters .tag-input {
        flex: 0 0 420px;
        max-width: 420px;
    }
    .filters .filters-action-link {
        margin-left: auto;
    }
    /* Inline message shown compactly next to action buttons */
    .inline-msg.visible {
        display: flex !important;
        align-items: center;
        margin: 0;
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    /* Group wrapping the inline message + Nouvelle liste link */
    .filters-right-group {
        margin-left: auto;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .filters-right-group .filters-action-link {
        margin-left: 0;
    }
}


