* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --background: 0 0% 98%;
    --foreground: 0 0% 10%;
    --card: 0 0% 100%;
    --card-foreground: 0 0% 10%;
    --popover: 0 0% 100%;
    --popover-foreground: 0 0% 10%;
    --primary: 48 100% 50%;
    --primary-foreground: 0 0% 10%;
    --secondary: 0 0% 20%;
    --secondary-foreground: 48 100% 50%;
    --muted: 0 0% 96%;
    --muted-foreground: 0 0% 40%;
    --accent: 0 84% 55%;
    --accent-foreground: 0 0% 98%;
    --accent-red: 0 75% 50%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 0 0% 90%;
    --input: 0 0% 90%;
    --ring: 48 100% 50%;
    --success: 142 71% 45%;
    --info: 217 91% 60%;
    --danger: 0 84.2% 60.2%;
    --warning: 43 96% 56%;
    --sidebar-background: 0 0% 98%;
    --sidebar-foreground: 240 5.3% 26.1%;
    --sidebar-primary: 240 5.9% 10%;
    --sidebar-primary-foreground: 0 0% 98%;
    --sidebar-accent: 240 4.8% 95.9%;
    --sidebar-accent-foreground: 240 5.9% 10%;
    --sidebar-border: 220 13% 91%;
    --sidebar-ring: 217.2 91.2% 59.8%;
    --shadow: rgba(15, 23, 42, 0.08);
    --shadow-lg: rgba(15, 23, 42, 0.15);

    --surface: hsl(var(--card));
    --surface-alt: hsl(var(--popover));
    --surface-muted: hsl(var(--muted));
    --text-primary: hsl(var(--foreground));
    --text-secondary: hsl(var(--muted-foreground));
    --border-color: hsl(var(--border));
    --bg-primary: hsl(var(--background));
    --bg-secondary: hsl(var(--card));
    --primary-color: hsl(var(--primary));
    --primary-foreground-color: hsl(var(--primary-foreground));
    --secondary-color: hsl(var(--secondary));
    --accent-color: hsl(var(--accent));
    --accent-red-color: hsl(var(--accent-red));
    --destructive-color: hsl(var(--destructive));
    --destructive-foreground-color: hsl(var(--destructive-foreground));
    --ring-color: hsl(var(--ring));
    --success-color: hsl(var(--success));
    --info-color: hsl(var(--info));
    --warning-color: hsl(var(--warning));
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, hsl(var(--background)) 0%, hsl(0 0% 95%) 50%, hsl(var(--background)) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--surface);
    color: var(--text-primary);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.header-logo {
    height: 55px;
    width: auto;
    object-fit: contain;
}

.logo-section h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    white-space: nowrap;
}

.header-stats {
    display: none;
}

/* Main Layout */
.main-layout {
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.view-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    background: var(--surface);
    border-radius: 999px;
    padding: 0.35rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), inset 0 1px 2px rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(10px);
}

.toggle-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-size: 0.95rem;
}

.toggle-btn:hover:not(.active) {
    color: var(--text-primary);
    background: var(--surface-muted);
}

.toggle-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-red-color) 100%);
    color: var(--primary-foreground-color);
    box-shadow: 0 4px 12px hsl(var(--primary) / 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.toggle-btn .toggle-count {
    margin-left: 0.5rem;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--primary-foreground-color);
    color: var(--primary-color);
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.4rem;
    box-shadow: 0 2px 4px var(--shadow);
}

.toggle-btn.active .toggle-count {
    background: var(--primary-foreground-color);
    color: var(--primary-color);
}

.content-panels {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel {
    background: var(--surface);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    padding: 1.75rem;
    display: none;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.panel:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
}

.panel.active {
    display: block;
}

.panel-header {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.25rem;
}

.panel-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.products-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.toolbar-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-chip {
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-chip:hover {
    background: var(--accent-color);
    color: var(--accent-foreground);
    border-color: transparent;
}

.search-container {
    position: relative;
    margin-bottom: 1rem;
}

.search-container i {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.1rem;
    z-index: 1;
    transition: color 0.3s ease;
}

.search-container input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.search-container input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px hsl(var(--primary) / 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.search-container:has(input:focus) i {
    color: var(--primary-color);
}

.btn-clear-search {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--destructive-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-clear-search:hover {
    background: hsl(0 72% 45%);
    transform: translateY(-50%) scale(1.1);
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-chip {
    padding: 0.5rem 1rem;
    background: var(--surface-muted);
    border: 1.5px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.filter-chip:hover {
    background: var(--accent-color);
    color: var(--accent-foreground);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.filter-chip.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-red-color) 100%);
    color: var(--primary-foreground-color);
    border-color: transparent;
    box-shadow: 0 4px 12px hsl(var(--primary) / 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.products-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.products-container::-webkit-scrollbar {
    width: 8px;
}

.products-container::-webkit-scrollbar-track {
    background: var(--surface-muted);
}

.products-container::-webkit-scrollbar-thumb {
    background: hsl(var(--primary) / 0.35);
    border-radius: 4px;
}

.products-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Categoria */
.category {
    background: var(--surface);
    border-radius: 14px;
    border: 1.5px solid var(--border-color);
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.category:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
    border-color: hsl(var(--primary) / 0.3);
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    cursor: pointer;
    user-select: none;
    color: var(--text-primary);
}

.category-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.category-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.05rem;
}

.category-label {
    font-size: 1rem;
}

.category-chevron {
    transition: transform 0.3s ease;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.category.open .category-chevron {
    transform: rotate(180deg);
    color: var(--primary-color);
}

.products-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.6rem;
    padding: 0 1.1rem 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
}

.category.open .products-list {
    padding: 0.75rem 1.1rem 1.1rem;
    max-height: 1500px;
}

.product-btn {
    background: var(--surface);
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.92rem;
    font-weight: 500;
    text-align: left;
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.product-text {
    flex: 1;
}

.product-check {
    color: var(--success-color);
    font-size: 1rem;
    animation: checkAppear 0.3s ease;
}

@keyframes checkAppear {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.product-btn.selected {
    background: linear-gradient(135deg, hsl(var(--primary) / 0.15) 0%, hsl(var(--accent-red) / 0.1) 100%);
    border-color: var(--primary-color);
    border-width: 2px;
    box-shadow: 0 4px 8px hsl(var(--primary) / 0.2), inset 0 0 0 1px hsl(var(--primary) / 0.1);
}

.product-btn.selected .product-text {
    color: var(--text-primary);
    font-weight: 600;
}

.product-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.product-btn:hover::before {
    left: 100%;
}

.product-btn:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, hsl(var(--primary) / 0.9) 100%);
    color: var(--primary-foreground-color);
    border-color: transparent;
    transform: translateY(-3px);
    box-shadow: 0 8px 16px hsl(var(--primary) / 0.3), 0 4px 8px rgba(0, 0, 0, 0.1);
}

.product-btn.selected:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-red-color) 100%);
    color: var(--primary-foreground-color);
    border-color: transparent;
}

.product-btn.selected:hover .product-check {
    color: var(--primary-foreground-color);
}

/* Wrapper prodotto */
.product-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-note-container {
    margin-top: 0.25rem;
    animation: slideDown 0.3s ease;
}

.product-note-input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}

.product-note-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1);
    background: var(--surface-alt);
}

.product-note-input::placeholder {
    color: var(--text-secondary);
    font-style: italic;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.list-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
}

.list-header h2 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.list-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--surface-muted);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: var(--primary-foreground-color);
    border-color: transparent;
    transform: translateY(-2px);
}

.list-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.list-content::-webkit-scrollbar {
    width: 8px;
}

.list-content::-webkit-scrollbar-track {
    background: var(--surface-muted);
}

.list-content::-webkit-scrollbar-thumb {
    background: hsl(var(--primary) / 0.35);
    border-radius: 4px;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state span {
    font-size: 0.9rem;
}

.shopping-category {
    margin-bottom: 1.5rem;
    background: var(--surface-muted);
    border-radius: 12px;
    padding: 1.25rem;
    border-left: 4px solid var(--primary-color);
}

.shopping-category h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.shopping-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.shopping-item {
    background: var(--surface);
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.shopping-item:hover {
    box-shadow: 0 6px 12px var(--shadow-lg);
    transform: translateY(-2px);
}


.item-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}


.note-input {
    flex: 2;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    background: var(--surface);
}

.note-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.25);
}

.btn-remove {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--destructive-color);
    color: var(--destructive-foreground-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-remove:hover {
    background: hsl(0 72% 45%);
    transform: scale(1.1) rotate(90deg);
}

.list-footer {
    padding: 1.5rem;
    border-top: 2px solid var(--border-color);
    background: transparent;
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-red-color) 100%);
    color: var(--primary-foreground-color);
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px hsl(var(--primary) / 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px var(--shadow-lg);
}

.btn-primary:disabled {
    background: var(--surface-muted);
    color: var(--text-secondary);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

/* Animazioni */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes pulseBadge {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.toggle-count.pulse {
    animation: pulseBadge 0.45s ease;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .app-header {
        padding: 1rem;
        border-bottom-width: 1px;
    }

    .header-content {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .logo-section {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .header-logo {
        height: 45px;
    }

    .logo-section h1 {
        font-size: 1.1rem;
        white-space: normal;
        line-height: 1.3;
    }

    .header-stats {
        width: 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .stat-item {
        flex: 1;
        padding: 0.4rem 0.75rem;
        font-size: 0.9rem;
    }

    .main-layout {
        padding: 0.75rem;
        gap: 1rem;
    }

    .view-toggle {
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .toggle-btn {
        flex: 1;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .panel {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .panel-header h2 {
        font-size: 1.35rem;
    }

    .search-container input {
        padding: 0.875rem 0.875rem 0.875rem 2.75rem;
        font-size: 0.95rem;
    }

    .search-container i {
        left: 1rem;
        font-size: 1rem;
    }

    .category-filters {
        gap: 0.4rem;
        margin-bottom: 0.75rem;
    }

    .filter-chip {
        padding: 0.35rem 0.7rem;
        font-size: 0.8rem;
    }

    .category-header {
        padding: 0.75rem 1rem;
    }

    .category-badge {
        width: 32px;
        height: 32px;
        font-size: 0.95rem;
    }

    .category-label {
        font-size: 0.9rem;
    }

    .products-list {
        grid-template-columns: 1fr;
        gap: 0.4rem;
        padding: 0.75rem;
    }

    .product-btn {
        padding: 0.65rem;
        font-size: 0.85rem;
    }

    .shopping-item {
        flex-wrap: wrap;
        padding: 0.875rem;
        gap: 0.75rem;
    }


    .item-name {
        font-size: 0.9rem;
        width: 100%;
        margin-bottom: 0.25rem;
    }

    .note-input {
        order: 3;
        width: 100%;
        padding: 0.5rem 0.65rem;
        font-size: 0.85rem;
    }

    .btn-remove {
        order: 4;
        width: 32px;
        height: 32px;
        margin-left: auto;
    }

    .list-header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .list-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

    .list-footer {
        padding: 1rem;
    }

    .btn-primary {
        padding: 0.875rem;
        font-size: 1rem;
    }

    .empty-state {
        padding: 3rem 1.5rem;
    }

    .empty-state i {
        font-size: 3rem;
    }

    .empty-state p {
        font-size: 1.1rem;
    }

    .shopping-category {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .shopping-category h3 {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 0.75rem;
    }

    .header-logo {
        height: 38px;
    }

    .logo-section h1 {
        font-size: 0.95rem;
    }

    .main-layout {
        padding: 0.5rem;
    }

    .panel {
        padding: 1rem;
    }

    .view-toggle {
        margin-bottom: 0.75rem;
    }

    .toggle-btn {
        padding: 0.65rem 0.75rem;
        font-size: 0.85rem;
    }
}
