body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
}
h1 {
    color: #fff;
    text-align: center;
    margin-bottom: 0;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

h1 .chef-logo {
    width: 50px;
    height: 50px;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.2));
}
.search-container {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}
.search-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.form-group {
    /* Grid for label (row 1) and input wrapper (row 2) */
    display: grid;
    grid-template-columns: 1fr; /* single column now; spinner is inside input */
    grid-template-rows: auto auto;   /* label | input */
    gap: 5px 10px;
    align-items: center;
}
label {
    font-weight: bold;
    color: #555;
}
input[type="text"] {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

/* Place the label on its own row */
.form-group label {
    grid-column: 1;
    grid-row: 1;
}

/* Place the input wrapper on row 2 */
.form-group .input-with-spinner {
    grid-column: 1;
    grid-row: 2;
}

/* Input-with-spinner layout */
.input-with-spinner {
    position: relative;
}

.input-with-spinner input[type="text"] {
    width: 100%;
    box-sizing: border-box;
}
button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}
button:hover {
    background-color: #2980b9;
}
.categories-section {
    background-color: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

.categories-section.hidden {
    display: none;
}

.categories-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.clear-categories-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.clear-categories-btn:hover {
    background-color: #c0392b;
}

.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.categories-header h3 {
    margin-top: 0;
    margin-bottom: 0;
    color: #2c3e50;
    font-size: 1.1rem;
    font-weight: 600;
    position: relative;
}

.product-list {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.product-item {
    border-bottom: 1px solid #eee;
    padding: 10px 0;
}
.product-item:last-child {
    border-bottom: none;
}
.product-header {
    display: flex;
    align-items: center;
    margin-bottom: 3px;
}
.product-name {
    font-weight: bold;
    margin-right: 8px;
    margin-left: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.product-price-code {
    margin-left: auto;
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
}
.product-price {
    font-weight: bold;
    color: #e74c3c;
}
.product-code {
    color: #777;
}
.shop-link-icon {
    font-size: 14px;
    color: #3498db;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}
.shop-link-icon:hover {
    opacity: 1;
}
.product-link {
    text-decoration: none;
    color: inherit;
}
.product-link:hover {
    color: #3498db;
}
.shop-info-icon {
    color: #3498db;
    margin-left: 8px;
    font-size: 0.9em;
}
.product-attributes {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 5px;
    margin-top: 3px;
}

.category-tag {
    display: inline-block;
    padding: 3px 6px;
    margin: 2px;
    border-radius: 12px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-weight: 500;
}

/* =============================
   Cart amount + unit controls
   - narrower amount box
   - select styled like input
   - same height for both
   ============================= */
/* Place amount+unit and the Add/Remove button on one line in product list */
.cart-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap; /* keep on one row as requested */
}

.qty-unit,
.edit-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.amount-input,
.unit-select {
    padding: 6px 10px;          /* consistent inner spacing */
    border: 1px solid #d0d7de;  /* subtle neutral border */
    border-radius: 6px;         /* match inputs */
    background-color: #fff;
    font-size: 14px;
    line-height: 1;             /* keep control compact */
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}

/* Make amount visibly narrower */
.amount-input {
    width: 72px;
}

/* Make native select visually match text input */
.unit-select {
    width: 4rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%23666' d='M5.25 7.5l4.75 5 4.75-5H5.25z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px 14px;
    padding-right: 32px; /* room for arrow */
}

.amount-input:focus,
.unit-select:focus {
    outline: none;
    border-color: #6aa5d8;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

/* Disabled/unavailable product look keeps controls aligned */
.product-item.unavailable .amount-input,
.product-item.unavailable .unit-select {
    opacity: 0.7;
}

/* Frequency-based color coding */
.category-frequency-very-high {
    background-color: #ff4d4f;
    color: white;
}

.category-frequency-high {
    background-color: #ffaa00;
    color: white;
}

.category-frequency-medium {
    background-color: #13c2c2;
    color: white;
}

.category-frequency-low {
    background-color: #52c41a;
    color: white;
}

.category-frequency-very-low {
    background-color: #8c8c8c;
    color: white;
}

/* Hover effects */
.category-tag:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 3px 5px rgba(0,0,0,0.15);
}

.category-tag:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Selected category styling */
.category-tag.selected-category {
    border: 2px solid #2c3e50;
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.5);
    position: relative;
}

.category-tag.selected-category:after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -2px;
    background: #2c3e50;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
}

/* Styling for categories with zero products after filtering */
.category-tag.zero-products {
    opacity: 0.6;
    text-decoration: line-through;
    background-color: #e0e0e0 !important;
    color: #666 !important;
}

.product-details {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 6px;
}
.price-detail {
    display: inline-flex;
    align-items: center;
}
.price-label {
    font-size: 13px;
    color: #777;
    margin-right: 4px;
}
.price-value {
    font-weight: bold;
    color: #e74c3c;
}
.price-value a {
    color: #3498db;
    text-decoration: none;
}
.price-value a:hover {
    text-decoration: underline;
}
.source-tag {
    display: inline-block;
    background-color: #f39c12;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    margin-right: 8px;
}
.source-tag.source-metro {
    background-color: #ff9900;
}
.source-tag.source-bidfood {
    background-color: #003399;
}
.source-tag.source-lunys {
    background-color: #13c000;
}
.no-results {
    text-align: center;
    padding: 20px;
    color: #777;
}
.product-item.unavailable {
    opacity: 0.7;
    background-color: #f8f8f8;
}
.unavailable-label {
    display: inline-block;
    margin-left: 10px;
    background-color: #e74c3c;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: normal;
}
.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}
.htmx-request .htmx-indicator {
    opacity: 1;
    display: inline-block !important;
}
.htmx-request.htmx-indicator {
    opacity: 1;
    display: inline-block !important;
}

/* Remove old input spinner styles; spinner now lives in #search-results-info */

/* Position relative for the form group to position the indicator */
/* No need for absolute positioning anymore; grid handles placement */

.search-results-info {
    background-color: white;
    border-radius: 8px;
    padding: 10px 20px;
    margin-top: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-size: 0.9rem;
    color: #555;
    display: none; /* hidden on initial load when empty */
    align-items: center;
    min-height: 32px; /* prevent layout shift while toggling spinner/text */
}

/* Show results info while searching (indicator state) */
.htmx-request.search-results-info {
    display: flex;
}

/* Keep it visible after a search once we have results/timing */
.search-results-info.has-results {
    display: flex;
}

.search-results-info p {
    margin: 0;
    display: flex;
    align-items: center;
}

.search-results-info p:before {
    content: '\f017'; /* Clock icon */
    font-family: 'Font Awesome 5 Free';
    margin-right: 8px;
    color: #3498db;
}

/* Spinner shown in results info while searching */
.search-results-spinner {
    display: none; /* hidden by default */
    color: #3498db;
    font-size: 16px;
}

/* When HTMX request is active on the indicator element, show spinner and hide text */
.htmx-request.search-results-info .search-results-spinner {
    display: inline-block;
}
.htmx-request.search-results-info p,
.htmx-request.search-results-info .results-text {
    display: none;
}

/* JSON tooltip styles */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.tooltip .tooltip-content {
    visibility: hidden;
    position: absolute;
    z-index: 1000;
    width: 500px;
    max-height: 400px;
    overflow: auto;
    background-color: #2c3e50;
    color: #ecf0f1;
    font-family: monospace;
    font-size: 12px;
    padding: 15px;
    border-radius: 6px;
    white-space: pre;
    box-shadow: 0 5px 10px rgba(0,0,0,0.2);
    left: 0;
    top: 100%;
    margin-top: 5px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -20px -20px 30px -20px;
    padding: 25px 40px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 50%, #8e2d23 100%);
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" opacity="0.1"><circle cx="10" cy="10" r="2" fill="white"/><circle cx="30" cy="20" r="1.5" fill="white"/><circle cx="50" cy="15" r="2.5" fill="white"/><circle cx="70" cy="25" r="1" fill="white"/><circle cx="90" cy="10" r="2" fill="white"/></svg>');
    background-size: 200px 100px;
    pointer-events: none;
}
#cart-icon .cart-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 23px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 10;
}
#cart-icon .cart-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}
#cart-icon .fa-shopping-cart { 
    color: #e74c3c; 
    font-size: 20px;
}
#cart-icon .cart-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #e74c3c;
    color: #fff;
    font-size: 12px;
    border-radius: 10px;
    padding: 2px 6px;
    min-width: 18px;
    text-align: center
}
.product-item { position: relative; }
.cart-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity .2s ease;
}
.product-item:hover .cart-actions { opacity: 1; }
.cart-btn {
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
}
.cart-btn.add .cart-btn.edit { background: #2ecc71; }
.cart-btn.add:hover .cart-btn.edit:hover { background: #27ae60; }
.cart-btn.remove { background: #e67e22; }
.cart-btn.remove:hover { background: #d35400; }
