/* Base Styles & Variables */
:root {
    /* Common Colors */
    --primary-color: #007AFF;
    --secondary-color: #5856D6;
    --success-color: #34C759;
    --warning-color: #FF9500;
    --danger-color: #FF3B30;
    
    /* Common Properties */
    --radius: 20px;
    --radius-small: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme (Default) */
:root,
html.theme-dark {
    --background: #000000;
    --surface: rgba(255, 255, 255, 0.1);
    --glass: rgba(255, 255, 255, 0.08);
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --glass-strong: rgba(255, 255, 255, 0.12);
    --section-bg: rgba(255, 255, 255, 0.05);
}

/* Light Theme */
html.theme-light {
    --background: #F2F2F7;
    --surface: rgba(255, 255, 255, 0.3);
    --glass: rgba(255, 255, 255, 0.4);
    --text-primary: #000000;
    --text-secondary: rgba(0, 0, 0, 0.6);
    --border: rgba(255, 255, 255, 0.4);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --glass-strong: rgba(255, 255, 255, 0.3);
    --section-bg: rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    transition: var(--transition);
}

/* Dark Theme Background Gradients */
html.theme-dark body,
body {
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(120, 70, 255, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(70, 150, 255, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(255, 70, 120, 0.2) 0%, transparent 50%);
}

/* Light Theme Background Gradients */
html.theme-light body {
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(120, 70, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(70, 150, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(255, 70, 120, 0.08) 0%, transparent 50%);
}

/* Glassmorphism Effect */
.glass {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem;
    border-radius: 0 0 var(--radius) var(--radius);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Language Selector */
.language-selector-container {
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    z-index: 10;
}

.language-selector {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    min-width: 140px;
}

.language-selector:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-color);
}

.language-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.language-selector option {
    background: var(--background);
    color: var(--text-primary);
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.nav-tab {
    flex: 1;
    max-width: 150px;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.nav-tab:hover {
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Main Content */
.app-main {
    flex: 1;
    padding: 1rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Pages */
.page {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scan Page */
.scan-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.input-section {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: var(--radius);
}

.barcode-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.barcode-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.08);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-small);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

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

.btn-primary:hover {
    background: #0051D5;
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    width: 100%;
}

/* Camera Section */
.camera-section {
    text-align: center;
}

.camera-preview {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 1rem;
}

.camera-preview video {
    width: 100%;
    height: auto;
    border-radius: var(--radius);
}

.scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.scan-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 250px;
    height: 250px;
    border: 3px solid var(--primary-color);
    border-radius: var(--radius);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Product Preview */
.product-preview {
    margin-top: 1rem;
}

.product-card {
    padding: 1.5rem;
    border-radius: var(--radius);
    position: relative;
}

.modal-header-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 1001;
}

.close-btn, .edit-toggle-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-btn {
    color: #ff4444;
}

.edit-toggle-btn {
    color: var(--text-primary);
}

.edit-toggle-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.close-btn:hover {
    background: rgba(255, 68, 68, 0.2);
}

.edit-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Unified Edit Mode CSS */
/* Hide all edit buttons by default */
.edit-btn, .edit-field-btn, .edit-icon-btn {
    display: none;
}

/* Exception: Keep the main toggle button visible */
.modal-header-controls .edit-toggle-btn {
    display: inline-flex;
}

/* Show all edit buttons in edit mode - unified rule */
.modal.edit-mode .edit-btn,
.modal.edit-mode .edit-field-btn,
.modal.edit-mode .edit-icon-btn {
    display: inline-flex;
}

/* Hide specific edit buttons in nutrition and comments sections in normal mode */
.modal:not(.edit-mode) #edit-nutrition-btn,
.modal:not(.edit-mode) #edit-comments-btn {
    display: none;
}

/* Field input styles */
.field-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    padding: 0.5rem;
    color: var(--text-primary);
    font-size: inherit;
    width: 100%;
    margin-top: 0.25rem;
}

.field-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.15);
}

/* Section styles */
[data-section] {
    background: var(--section-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Nutrition and Comments row layout */
.nutrition-comments-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.nutrition-comments-row .product-nutrition,
.nutrition-comments-row .product-comments {
    margin-bottom: 0;
}

.modal:not(.edit-mode) .location-select {
    pointer-events: none;
    opacity: 0.7;
}

.modal.edit-mode .location-select {
    pointer-events: auto;
    opacity: 1;
}

/* Header styles for product fields to match nutrition and comments */
.product-name-header,
.product-brand-header,
.product-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.product-name-header h2,
.product-brand-header p,
.product-category-header {
    margin: 0;
    flex: 1;
}

.product-image {
    width: 100%;
    max-width: 200px;
    height: 200px;
    object-fit: contain;
    border-radius: var(--radius-small);
    margin: 0 auto 1rem;
    display: block;
    background: rgba(255, 255, 255, 0.05);
}

.product-info {
    text-align: center;
    margin-bottom: 1.5rem;
}

.product-name {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.product-brand {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.product-quantity {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.product-categories {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 0.5rem; /* Reduced from 1rem */
    min-height: 0; /* Collapse when empty */
}

/* Hide categories container when empty */
.product-categories:empty {
    display: none;
}

.category-tag {
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Quantity Control */
.add-to-inventory {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.qty-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.qty-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.qty-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.qty-input {
    width: 80px;
    padding: 0.5rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text-primary);
    font-size: 1.1rem;
}

/* Inventory Page */
.inventory-container {
    max-width: 800px;
    margin: 0 auto;
}

.filters {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

#add-manual-product-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text-primary);
}

.filter-select {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text-primary);
    min-width: 150px;
}

.inventory-list {
    display: grid;
    gap: 1rem;
}

.inventory-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
}

.inventory-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.item-image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: var(--radius-small);
    background: rgba(255, 255, 255, 0.05);
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

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

.item-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.item-qty {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
}

/* Summary Page */
.summary-container {
    max-width: 800px;
    margin: 0 auto;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.summary-content {
    display: grid;
    gap: 1rem;
}

.summary-group {
    padding: 1rem;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.group-title {
    font-size: 1.1rem;
    font-weight: 500;
}

.group-count {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-icon {
    opacity: 0.3;
    margin-bottom: 1rem;
}











.product-quantity {
    border: 1px solid teal !important; /* Quantity element */
}

/* Header Controls */
.header-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-left: auto;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-small);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.icon-btn svg {
    width: 24px;
    height: 24px;
}

/* Settings Modal */
.settings-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.settings-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.settings-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.localisation-section {
    padding: 1rem;
}

.locations-list {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.location-item {
    background: var(--glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-small);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.location-info {
    flex: 1;
}

.location-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.location-sections {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

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

/* Location Selection */
.location-selection {
    margin: 0.5rem 0;
    padding: 1rem;
    background: var(--glass);
    border-radius: var(--radius-small);
    border: 1px solid var(--border-color);
}

.location-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.location-dropdowns {
    display: flex;
    gap: 0.75rem;
}

.location-select {
    width: auto;
    min-width: fit-content;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-small);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.location-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.location-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Full Image Modal */
.full-image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.full-image-modal.active {
    display: flex;
}

.full-image-modal img {
    max-width: 80%;
    max-height: 90%;
    object-fit: contain;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease-out;
    min-width: 250px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Location Confirmation Modal */
.location-confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
}

.confirmation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
}

.confirmation-content {
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: confirmationSlide 0.3s ease-out;
}

.confirmation-content h3 {
    margin: 0 0 1rem 0;
    color: var(--success-color);
    font-size: 1.5rem;
}

.confirmation-content p {
    margin: 0 0 2rem 0;
    color: var(--text-color);
}

.confirmation-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.confirmation-actions .btn {
    flex: 1;
    max-width: 150px;
}

@keyframes confirmationSlide {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 3px solid var(--success-color);
}

.toast.error {
    border-left: 3px solid var(--danger-color);
}

.toast.warning {
    border-left: 3px solid var(--warning-color);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

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

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease-out;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    max-width: 900px;
    max-height: 85vh;
    width: 95%;
    margin: 1rem;
    padding: 2rem;
    border-radius: var(--radius);
    overflow-y: auto;
    z-index: 1001;
}

/* Product details modal specific styling */
#product-details-modal .modal-content {
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    max-height: 80vh;
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    flex: 1;
    overflow: hidden;
}

.product-overview,
.product-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.product-details {
    overflow-y: auto;
}

/* Image edit overlay */
.product-image-container {
    position: relative;
}

.image-edit-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    opacity: 0;
    transition: var(--transition);
}

.product-image-container:hover .image-edit-overlay {
    opacity: 1;
}

.btn-small {
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
}

/* Edit mode toggle */
.edit-mode-toggle {
    text-align: center;
}

/* Manual product entry */
.editable-field {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    width: 100%;
    margin-bottom: 0.5rem;
}

.editable-field:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}

.editable-field::placeholder {
    color: var(--text-secondary);
}

.upload-photo-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    width: 100%;
    justify-content: center;
}

.barcode-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-small);
    border: 1px solid var(--border);
}

.field-label {
    display: block;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* Personal comments section */
.personal-comments-section {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    padding: 1.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Comments header with edit button */
.comments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.comments-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.edit-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.edit-icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: scale(1.1);
}

.nutrition-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.nutrition-header h3 {
    margin: 0;
}

.comments-display {
    margin-bottom: 1rem;
}

.comments-content {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-small);
    padding: 1rem;
    white-space: pre-wrap;
    line-height: 1.5;
    min-height: 2rem;
}

.comments-edit textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    padding: 0.8rem;
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}

.comments-edit textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.comments-edit textarea::placeholder {
    color: var(--text-secondary);
}

.edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

/* Camera capture styling */
#camera-capture {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: var(--radius-small);
}

.camera-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

/* Nutrition Facts Styles */
.product-nutrition-section {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.product-nutrition-section h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nutrition-container {
    color: var(--text-secondary);
}

.loading-nutrition {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.nutrition-facts {
    display: grid;
    gap: 1rem;
}

.nutrition-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.nutrition-highlight {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    padding: 1rem;
    text-align: center;
}

.nutrition-highlight-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.nutrition-highlight-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.nutri-score {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-small);
    font-weight: bold;
    font-size: 1.1rem;
    color: white;
}

.nutri-score.grade-a { background: #038e3e; }
.nutri-score.grade-b { background: #85bb2f; }
.nutri-score.grade-c { background: #fec10a; color: #000; }
.nutri-score.grade-d { background: #ee7f00; }
.nutri-score.grade-e { background: #e63312; }

.nutrition-details {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    overflow: hidden;
}

.nutrition-table {
    width: 100%;
    border-collapse: collapse;
}

.nutrition-table th {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

.nutrition-table td {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nutrition-table tr:last-child td {
    border-bottom: none;
}

.nutrition-table .nutrient-name {
    font-weight: 500;
    color: var(--text-primary);
}

.nutrition-table .nutrient-value {
    text-align: right;
    font-family: 'Courier New', monospace;
}

.nutrition-table .nutrient-unit {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.no-nutrition-data {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.no-nutrition-data svg {
    opacity: 0.3;
    margin-bottom: 1rem;
}

/* Nutrition Editing Styles */
.nutrition-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    padding: 0.4rem 0.6rem;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    width: 80px;
    text-align: right;
    margin-right: 0.5rem;
}

.nutrition-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}

.nutrition-edit-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Inline Nutrition Editing Styles */
.nutrition-input-inline {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-small);
    padding: 0.3rem 0.5rem;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    width: 70px;
    text-align: right;
    margin-right: 0.5rem;
}

.nutrition-input-inline:focus {
    outline: none;
    border-color: var(--success-color);
    background: rgba(255, 255, 255, 0.15);
}

.inline-actions {
    display: inline-flex;
    gap: 0.3rem;
    margin-left: 0.5rem;
}

.save-inline-btn, .cancel-inline-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 0.2rem 0.4rem;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.save-inline-btn:hover {
    background: var(--success-color);
    color: white;
}

.cancel-inline-btn:hover {
    background: var(--danger-color);
    color: white;
}

.nutrient-value {
    cursor: pointer;
    transition: var(--transition);
}

.nutrient-value:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Simple Nutrition Edit Buttons */
.nutrition-edit-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.nutrition-edit-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    padding: 2px 5px;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

/* Editable Product Fields */
.editable-field {
    position: relative;
    display: inline-block;
    width: 100%;
    margin-bottom: 0.5rem;
}

.edit-field-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* Removed hover opacity rule - edit buttons now permanently visible in edit mode */

.edit-field-btn:hover {
    color: var(--primary-color);
}

.product-name-input, .product-brand-input, .product-category-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-small);
    padding: 0.5rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: inherit;
    width: calc(100% - 2rem);
    margin-right: 1rem;
}

.product-name-input {
    font-size: 1.5rem;
    font-weight: bold;
}

.product-brand-input, .product-category-input {
    font-size: 1rem;
}

.product-name-input:focus, .product-brand-input:focus, .product-category-input:focus {
    outline: none;
    border-color: var(--success-color);
    background: rgba(255, 255, 255, 0.15);
}

/* Category field inline layout */
.category-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}
.category-field .field-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}
.category-field .product-category {
    flex: 1;
    min-width: 0;
}
.category-field .product-category-input {
    flex: 1;
    width: auto;
    margin-right: 0;
}
.category-field .edit-field-btn {
    flex-shrink: 0;
}

/* Category dropdown selector */
.product-category-select {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text-primary);
    padding: 0.5rem;
    font-size: 1rem;
    flex: 1;
    width: auto;
    margin-right: 0;
}

.product-category-select:focus {
    outline: none;
    border-color: var(--success-color);
    background: rgba(255, 255, 255, 0.15);
}

.product-category-select option {
    background: var(--background);
    color: var(--text-primary);
}

/* Settings Page Styles */
.settings-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    gap: 1.5rem;
    display: flex;
    flex-direction: column;
}

.settings-section {
    padding: 1.5rem;
    border-radius: var(--radius);
}

.settings-header {
    margin-bottom: 1.5rem;
}

.settings-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* Add Category Form */
.add-category-form {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.category-input {
    flex: 1;
    min-width: 250px;
    padding: 0.75rem;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text-primary);
    font-size: 1rem;
}

.category-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}

.category-input::placeholder {
    color: var(--text-secondary);
}

/* Categories List */
.categories-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    transition: var(--transition);
}

.category-item:hover {
    background: var(--glass-strong);
}

.category-name {
    flex: 1;
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.delete-category-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-category-btn:hover {
    background: rgba(255, 59, 48, 0.1);
    transform: scale(1.1);
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: 0.5rem;
}

.empty-state .text-muted {
    font-size: 0.9rem;
    opacity: 0.7;
}

@media (max-width: 768px) {
    .nutrition-overview {
        grid-template-columns: 1fr;
    }
    
    .nutrition-comments-row {
        grid-template-columns: 1fr;
    }
    
    .nutrition-table {
        font-size: 0.85rem;
    }
    
    .nutrition-table th,
    .nutrition-table td {
        padding: 0.5rem;
    }
}

.product-image-container {
    position: relative;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 1rem; /* Reduced bottom margin */
    aspect-ratio: 2 / 1;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
}

.product-image-large {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: var(--radius-small);
    box-shadow: var(--shadow);
}

.product-info-modal {
    text-align: center;
    margin-bottom: 2rem;
}

.product-info-modal .product-name {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.product-info-modal .product-brand {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.product-info-modal .product-quantity {
    color: var(--text-secondary);
    margin-bottom: 0.25rem; /* Reduced from 1rem */
}

/* Hide quantity when empty */
.product-quantity:empty {
    display: none;
}

.add-to-inventory-section {
    background: var(--glass);
    border-radius: var(--radius-small);
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.add-to-inventory-section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.scan-to-add p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-align: center;
}

.confirmation-barcode {
    background: var(--surface);
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-small);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.barcode-canvas {
    max-width: 100%;
    height: auto;
    margin-bottom: 0.5rem;
    background: white;
    border-radius: 4px;
}

.barcode-text-display {
    margin-top: 0.5rem;
}

.qty-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.qty-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.barcode-text {
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--primary-color);
    letter-spacing: 2px;
}

.scan-instruction {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Product Details Modal */
.product-details-header {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.product-basic-info {
    flex: 1;
    margin-bottom: 0; /* Remove default spacing */
}

/* Direct editable field spacing in modal */
.modal-left-column > .editable-field {
    margin-bottom: 0.5rem; /* Small gap between name and image */
}

.product-analytics-section,
.product-reviews-section {
    background: var(--glass);
    border-radius: var(--radius-small);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}
.product-history-section {
    background: var(--glass);
    border-radius: var(--radius-small);
    padding: 1.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0;
    border: 1px solid var(--border);
}

.product-analytics-section h3,
.product-reviews-section h3,
.product-history-section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.analytics-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.analytics-item:last-child {
    border-bottom: none;
}

.analytics-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.analytics-value {
    color: var(--text-primary);
    font-weight: 600;
}

.reviews-container {
    max-height: 300px;
    overflow-y: auto;
}

.review-item {
    background: var(--surface);
    border-radius: var(--radius-small);
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 3px solid var(--primary-color);
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.review-rating {
    color: var(--warning-color);
    font-size: 1.1rem;
}

.review-source {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.review-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

.loading-reviews {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.history-container {
    max-height: 120px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.history-item:last-child {
    border-bottom: none;
}

.history-date {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.history-quantity {
    color: var(--primary-color);
    font-weight: 600;
}

/* Mobile adjustments for modal */
@media (max-width: 768px) {
    .modal-content {
        max-width: 95%;
        margin: 0.5rem;
        padding: 1.5rem;
        max-height: 90vh;
    }
    
    .modal-body {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .product-overview,
    .product-details {
        gap: 1rem;
    }
    
    .image-edit-overlay {
        opacity: 1; /* Always visible on mobile */
    }
    
    .product-image-container {
        max-width: 250px;
    }
    
    .barcode-text {
        font-size: 1.2rem;
    }
    
    .product-details-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        border-radius: 0;
    }
    
    .nav-tabs {
        gap: 0.25rem;
    }
    
    .nav-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .summary-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Theme Toggle Styles */
.theme-toggle-container {
    position: absolute;
    top: 0.5rem;
    right: 160px; /* Position before language selector */
    z-index: 10;
}

.theme-toggle {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text-primary);
    padding: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.theme-toggle:hover {
    background: var(--glass-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.theme-toggle:active {
    transform: translateY(0);
}

.theme-icon {
    width: 20px;
    height: 20px;
    transition: var(--transition);
}

/* Default state - show sun icon (for dark theme) */
.sun-icon {
    display: block;
}

.moon-icon {
    display: none;
}

/* Light theme - show moon icon */
html.theme-light .sun-icon {
    display: none;
}

html.theme-light .moon-icon {
    display: block;
}

/* Theme-specific adjustments */
html.theme-light .glass {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Light theme modal adjustments */
html.theme-light .modal-content {
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.6);
    color: var(--text-primary);
}

html.theme-light .modal-overlay {
    background: rgba(0, 0, 0, 0.3);
}

/* Increase contrast for modal content blocks */
.modal .personal-comments-section,
.modal .product-nutrition-section,
.modal .location-selection,
.modal .product-analytics-section,
.modal .product-history-section {
    background: var(--glass-strong);
    border: 1px solid var(--border);
}

/* Light theme input and button adjustments */
html.theme-light .barcode-input,
html.theme-light .search-input,
html.theme-light .qty-input,
html.theme-light input,
html.theme-light textarea {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
}

html.theme-light .btn {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: var(--text-primary);
}

html.theme-light .btn:hover {
    background: rgba(255, 255, 255, 0.8);
}

/* Light theme cards and inventory items */
html.theme-light .inventory-item,
html.theme-light .summary-group {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

html.theme-light .app-title {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Responsive adjustments for theme toggle */
@media (max-width: 768px) {
    .theme-toggle-container {
        right: 120px; /* Adjust for smaller screens */
    }
    
    .theme-toggle {
        width: 36px;
        height: 36px;
        padding: 0.4rem;
    }
    
    .theme-icon {
        width: 18px;
        height: 18px;
    }
}