/* Shopping Module - Bring-Style */

.shopping-module { display: flex; flex-direction: column; gap: var(--sp-4); }

/* ---- Listen-Kacheln ---- */
.shopping-list-header {
    display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-start;
}
.shopping-list-tiles {
    display: flex; flex-wrap: wrap; gap: var(--sp-3); flex: 1;
}
.list-tile {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2);
    background: var(--bg-card); border: 2px solid var(--border);
    border-radius: var(--radius-lg); cursor: pointer;
    transition: all var(--dur-fast); min-width: 100px;
    position: relative;
}
.list-tile:hover { border-color: var(--tile-color, var(--accent)); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.list-tile.active {
    border-color: var(--tile-color, var(--accent));
    background: color-mix(in srgb, var(--tile-color, var(--accent)) 8%, var(--bg-card));
}
.list-tile-icon {
    width: 32px; height: 32px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: white;
    flex-shrink: 0;
}
.list-tile-name {
    font-size: var(--text-sm); font-weight: 500;
    color: var(--text-primary); flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-tile .delete-list {
    display: flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 50%;
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 0;
    opacity: 0; transition: opacity var(--dur-fast);
    flex-shrink: 0;
}
.list-tile:hover .delete-list { opacity: 1; }
.list-tile .delete-list:hover { color: var(--red); background: rgba(239,68,68,0.1); }
.s-new-list-tile {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2);
    background: none; border: 2px dashed var(--border);
    border-radius: var(--radius-lg); cursor: pointer;
    color: var(--text-muted); font-size: var(--text-sm);
    font-family: var(--font-sans); transition: all var(--dur-fast);
}
.s-new-list-tile:hover { border-color: var(--accent); color: var(--accent); }
.s-no-lists { color: var(--text-muted); font-size: var(--text-sm); padding: var(--sp-2); }

/* ---- View Tabs ---- */
.shopping-view-tabs {
    display: flex; gap: 0; background: var(--bg-input);
    border-radius: var(--radius-md); padding: 3px; margin-bottom: var(--sp-4);
}
.view-tab {
    flex: 1; padding: var(--sp-2) var(--sp-4); font-size: var(--text-sm);
    font-weight: 500; color: var(--text-muted); background: none; border: none;
    border-radius: var(--radius-sm); cursor: pointer; transition: all var(--dur-fast);
    font-family: var(--font-sans); text-align: center;
}
.view-tab.active { background: var(--accent); color: white; }
.view-tab:hover:not(.active) { color: var(--text-secondary); }

/* ---- Quick-Add Bar ---- */
.quick-add-bar {
    display: flex; gap: var(--sp-2); align-items: center;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); margin-bottom: var(--sp-3);
}
.quick-add-bar .form-input {
    padding: var(--sp-2) var(--sp-3); background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    color: var(--text-primary); font-size: var(--text-sm);
    font-family: var(--font-sans); outline: none;
    transition: border-color var(--dur-fast);
}
.quick-add-bar .form-input:focus { border-color: var(--accent); }
.quick-add-bar .form-input:first-child { flex: 1; min-width: 0; }
.quick-add-bar .qty-input { width: 70px; text-align: center; }
.quick-add-bar .unit-select {
    width: 80px; padding: var(--sp-2) var(--sp-2);
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-md); color: var(--text-primary);
    font-size: var(--text-sm); font-family: var(--font-sans); outline: none;
    transition: border-color var(--dur-fast);
}
.quick-add-bar .unit-select:focus { border-color: var(--accent); }
.quick-add-bar .btn { padding: var(--sp-2) var(--sp-3); min-width: 36px; font-size: 1.1rem; }

/* ---- Listenansicht ---- */
.shopping-list-view { display: flex; flex-direction: column; gap: var(--sp-3); }

.list-category-group {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
}
.list-cat-header {
    padding: var(--sp-2) var(--sp-4); font-size: var(--text-xs); font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}
.shopping-item {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
    transition: background var(--dur-fast);
}
.shopping-item:last-child { border-bottom: none; }
.shopping-item:hover { background: rgba(128,128,128,0.04); }
.shopping-item.checked { opacity: 0.45; }
.shopping-item.checked .item-name { text-decoration: line-through; }
.item-check { display: flex; align-items: center; cursor: pointer; }
.item-check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.item-icon {
    width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.item-icon svg {
    width: 20px; height: 20px; stroke-width: 2;
}
.item-content { flex: 1; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; min-width: 0; }
.item-name { font-size: var(--text-base); color: var(--text-primary); }
.item-qty { font-size: var(--text-sm); color: var(--text-muted); font-family: var(--font-mono); }
.item-qty-edit {
    font-size: var(--text-sm); color: var(--accent); font-family: var(--font-mono);
    cursor: pointer; padding: 2px 6px; border-radius: var(--radius-sm);
    transition: all var(--dur-fast); border: 1px solid transparent;
    white-space: nowrap;
}
.item-qty-edit:hover {
    background: var(--accent-muted); border-color: var(--accent);
}
.qty-placeholder {
    color: var(--text-muted); font-family: var(--font-sans);
    font-size: var(--text-xs); font-style: italic;
}
.item-qty-edit:hover .qty-placeholder { color: var(--accent); }
.item-delete {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: var(--sp-1); font-size: 1rem; border-radius: var(--radius-sm);
    transition: all var(--dur-fast); line-height: 1;
}
.item-delete:hover { color: var(--red); }
.checked-section-header {
    padding: var(--sp-3) var(--sp-4); font-size: var(--text-xs); color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
}
.checked-section-header:hover { background: var(--bg-elevated); }
.checked-items-list { opacity: 0.5; }

/* ---- Mengen-Dialog (Overlay) ---- */
.qty-dialog-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: var(--sp-4);
}
.qty-dialog-overlay[hidden] { display: none; }
.qty-dialog {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-xl); padding: var(--sp-6);
    width: 100%; max-width: 340px;
    box-shadow: var(--shadow-xl);
    animation: qtyDialogIn 0.2s ease-out;
}
@keyframes qtyDialogIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.qty-dialog h4 {
    margin: 0 0 var(--sp-4) 0; font-size: var(--text-lg);
    font-weight: 600; color: var(--text-primary);
    text-align: center;
}
.qty-form {
    display: flex; gap: var(--sp-3); margin-bottom: var(--sp-4);
}
.qty-form .form-input,
.qty-form .form-select {
    flex: 1; padding: var(--sp-3) var(--sp-4);
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-md); color: var(--text-primary);
    font-size: var(--text-base); font-family: var(--font-sans);
    outline: none; transition: border-color var(--dur-fast);
}
.qty-form .form-input:focus,
.qty-form .form-select:focus { border-color: var(--accent); }
.qty-form .form-input { width: 90px; text-align: center; flex: 0 0 auto; }
.qty-form .form-select { flex: 1; }
.qty-actions {
    display: flex; gap: var(--sp-2);
}
.qty-actions .btn {
    flex: 1; padding: var(--sp-3); border: none; border-radius: var(--radius-md);
    font-size: var(--text-sm); font-weight: 600; cursor: pointer;
    font-family: var(--font-sans); transition: all var(--dur-fast);
    text-align: center;
}
.qty-actions .btn-primary {
    background: var(--accent); color: white;
}
.qty-actions .btn-primary:hover { background: var(--accent-hover); }
.qty-actions .btn-secondary {
    background: var(--bg-elevated); color: var(--text-primary);
    border: 1px solid var(--border);
}
.qty-actions .btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.qty-actions .btn-ghost {
    background: none; color: var(--text-muted);
}
.qty-actions .btn-ghost:hover { color: var(--text-primary); }

/* ---- Bring-Ansicht: Suche ---- */
.bring-search { position: relative; margin-bottom: var(--sp-4); }
.bring-search input {
    width: 100%; padding: var(--sp-3) var(--sp-4) var(--sp-3) 2.5rem;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); color: var(--text-primary);
    font-size: var(--text-base); font-family: var(--font-sans); outline: none;
    transition: border-color var(--dur-fast);
}
.bring-search input:focus { border-color: var(--accent); }
.bring-search svg {
    position: absolute; left: var(--sp-3); top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none;
}

/* ---- Kategorien & Chips ---- */
.bring-categories { display: flex; flex-direction: column; gap: var(--sp-6); }
.bring-cat-section { display: flex; flex-direction: column; gap: var(--sp-3); }
.bring-cat-title {
    font-size: var(--text-sm); font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; padding-bottom: var(--sp-2); border-bottom: 2px solid;
}
.bring-chips {
    display: grid; grid-template-columns: repeat(4,1fr); gap: var(--sp-3);
}
/* Bildkachel-Stil: Icon gross oben, Name unten */
.bring-chip {
    display: flex; flex-direction: column; align-items: center;
    padding: var(--sp-3) var(--sp-2) var(--sp-2);
    background: var(--bg-card); border: 2px solid var(--border);
    border-radius: var(--radius-lg); cursor: pointer;
    transition: all var(--dur-fast); font-family: var(--font-sans);
    font-size: 0.7rem; color: var(--text-primary); position: relative;
    overflow: hidden; user-select: none; gap: var(--sp-2);
    min-height: 80px; text-align: center;
}
.bring-chip:hover:not(.on-list) {
    border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md);
}
.bring-chip:active { transform: translateY(0); }
.bring-chip.on-list { border-color: #22c55e; background: rgba(34,197,94,0.08); cursor: default; }
.bring-chip-custom { border-style: dashed; }
.bring-chip-icon {
    width: 48px; height: 48px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.bring-chip-icon svg {
    width: 26px; height: 26px; flex-shrink: 0;
}
.bring-chip-name {
    font-size: 0.68rem; font-weight: 500; line-height: 1.25;
    word-break: break-word; hyphens: auto;
    overflow: hidden; display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.on-list-check {
    position: absolute; top: 4px; right: 4px; width: 18px; height: 18px;
    background: #22c55e; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.on-list-check svg { width: 10px; height: 10px; stroke: white; stroke-width: 3; fill: none; }
.chip-delete-custom {
    position: absolute; bottom: 2px; right: 3px; background: none; border: none;
    font-size: 0.7rem; color: var(--text-muted); cursor: pointer; padding: 1px 3px;
    line-height: 1; opacity: 0; transition: opacity var(--dur-fast);
}
.bring-chip:hover .chip-delete-custom { opacity: 1; }
.chip-delete-custom:hover { color: var(--red); }

/* ---- Eigener Artikel anlegen ---- */
.custom-article-section {
    margin-top: var(--sp-6); padding: var(--sp-5);
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.custom-article-header {
    display: flex; align-items: center; gap: var(--sp-2);
    font-size: var(--text-sm); font-weight: 700; color: var(--text-primary);
    margin-bottom: var(--sp-4);
}
.custom-article-form { display: flex; flex-direction: column; gap: var(--sp-3); }
.custom-article-form input[type="text"],
.custom-article-form select {
    padding: var(--sp-3) var(--sp-4); background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    color: var(--text-primary); font-size: var(--text-sm);
    font-family: var(--font-sans); outline: none; transition: border-color var(--dur-fast);
}
.custom-article-form input:focus,
.custom-article-form select:focus { border-color: var(--accent); }
.custom-article-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.btn-add-to-list, .btn-save-article {
    display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4);
    border: none; border-radius: var(--radius-md); font-size: var(--text-sm);
    font-weight: 600; cursor: pointer; font-family: var(--font-sans); transition: all var(--dur-fast);
}
.btn-add-to-list { background: var(--accent); color: white; }
.btn-add-to-list:hover { background: var(--accent-hover); }
.btn-save-article { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-save-article:hover { border-color: var(--accent); color: var(--accent); }
.custom-article-msg {
    padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-md);
    font-size: var(--text-sm); font-weight: 500;
}
.custom-article-msg.success { background: rgba(34,197,94,0.12); color: #16a34a; }
.custom-article-msg.error   { background: rgba(239,68,68,0.12);  color: #dc2626; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .bring-chips { grid-template-columns: repeat(4,1fr); gap: var(--sp-2); }
    .bring-chip { min-height: 74px; }
    .bring-chip-icon { width: 40px; height: 40px; }
    .bring-chip-icon svg { width: 22px; height: 22px; }
    .quick-add-bar { flex-wrap: wrap; }
    .quick-add-bar .form-input:first-child { flex-basis: 100%; }
    .quick-add-bar .qty-input { flex: 1; }
    .quick-add-bar .unit-select { flex: 1; }
}
@media (max-width: 480px) {
    .bring-chips { grid-template-columns: repeat(3,1fr); gap: var(--sp-2); }
    .bring-chip { min-height: 70px; padding: var(--sp-2) var(--sp-1); }
    .bring-chip-icon { width: 36px; height: 36px; }
    .bring-chip-icon svg { width: 20px; height: 20px; }
    .custom-article-actions { flex-direction: column; }
    .btn-add-to-list, .btn-save-article { justify-content: center; }
    .qty-dialog { padding: var(--sp-4); }
    .qty-actions { flex-direction: column; }
}

/* -- Eingekauft-Sektion (verbessert) ----------------------------- */
.checked-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    margin-top: 1rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    cursor: pointer;
    user-select: none;
    border: 1px solid var(--border);
}

.checked-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.checked-header-left svg {
    color: var(--text-muted);
    transition: transform 0.2s var(--ease-out);
    flex-shrink: 0;
}

.checked-badge {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.05rem 0.45rem;
}

.checked-clear-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
    transition: color 0.15s, border-color 0.15s;
}

.checked-clear-btn:hover {
    color: var(--red);
    border-color: var(--red);
}

.checked-items-list {
    margin-top: 0.5rem;
    opacity: 0.7;
}
