/* ListBucket - Mobile-First Shopping List */

:root {
    --primary: #4CAF50;
    --primary-dark: #388E3C;
    --secondary: #607D8B;
    --danger: #f44336;
    --background: #f5f5f5;
    --surface: #ffffff;
    --text: #212121;
    --text-secondary: #757575;
    --border: #e0e0e0;
    --checked-bg: #f9f9f9;
    --suggestion-bg: #E8F5E9;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --radius: 8px;
}

/* Dark Mode */
[data-theme="dark"] {
    --primary: #66BB6A;
    --primary-dark: #4CAF50;
    --secondary: #90A4AE;
    --danger: #ef5350;
    --background: #121212;
    --surface: #1e1e1e;
    --text: #e0e0e0;
    --text-secondary: #9e9e9e;
    --border: #333333;
    --checked-bg: #2a2a2a;
    --suggestion-bg: #1b3a1e;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
}

[data-theme="dark"] .restock-container {
    background: #2d2010;
    border-left-color: #FF9800;
}

[data-theme="dark"] .restock-header {
    color: #FFB74D;
}

[data-theme="dark"] .restock-item {
    background: var(--surface);
}

[data-theme="dark"] .flash-error {
    background: #3c1515;
    color: #ef9a9a;
}

[data-theme="dark"] .flash-success {
    background: #1b3a1e;
    color: #a5d6a7;
}

[data-theme="dark"] input,
[data-theme="dark"] select {
    background: var(--surface);
    color: var(--text);
}

[data-theme="dark"] .inline-suggestions {
    background: var(--suggestion-bg);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background: var(--surface);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 16px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-link:hover {
    color: var(--primary);
}

.nav-user {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* Flash Messages */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.flash-error {
    background: #FFEBEE;
    color: #C62828;
}

.flash-success {
    background: #E8F5E9;
    color: #2E7D32;
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 100px);
}

.auth-card {
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.auth-subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--primary);
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group small {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    width: 100%;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

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

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

.btn-block {
    width: 100%;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-icon {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: var(--border);
}

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

/* List Header */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.list-header h1 {
    font-size: 1.5rem;
}

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

/* Add Item Form */
.add-item-container {
    margin-bottom: 16px;
}

.add-item-form {
    display: flex;
    gap: 8px;
}

.add-item-form input {
    flex: 1;
}

.add-item-form .btn {
    flex-shrink: 0;
}

/* Suggestions */
.suggestions-container {
    background: var(--suggestion-bg);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 16px;
}

.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    margin-bottom: 8px;
}

.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.suggestion-item {
    background: var(--surface);
    padding: 10px 12px;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.suggestion-item .item-name {
    font-weight: 500;
}

.suggestion-item .item-reason {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.suggestion-actions {
    display: flex;
    gap: 8px;
}

/* Shopping List */
.shopping-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.list-item {
    background: var(--surface);
    padding: 12px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: background 0.2s, opacity 0.2s;
}

.list-item.checked {
    background: var(--checked-bg);
    opacity: 0.7;
}

.list-item.checked .item-name {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.list-item.ai-suggested {
    border-left: 3px solid var(--primary);
}

/* Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.checkbox-container input {
    display: none;
}

.checkmark {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.checkbox-container input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-container input:checked + .checkmark::after {
    content: '';
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

/* Item Content */
.item-content {
    flex: 1;
    min-width: 0;
}

.item-name {
    display: block;
    font-weight: 500;
}

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

.item-suggestion-reason {
    font-size: 0.75rem;
    color: var(--primary-dark);
    display: block;
}

.item-category {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--background);
    padding: 2px 8px;
    border-radius: 12px;
}

.delete-btn {
    opacity: 0.5;
}

.list-item:hover .delete-btn {
    opacity: 1;
}

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

.empty-hint {
    font-size: 0.9rem;
    margin-top: 8px;
}

/* Bottom Actions */
.bottom-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    padding: 16px;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
    display: flex;
    gap: 8px;
    max-width: 600px;
    margin: 0 auto;
}

.bottom-actions .btn {
    flex: 1;
}

/* Add padding at bottom for fixed actions */
.shopping-list {
    padding-bottom: 100px;
}

/* Settings */
.settings-container {
    max-width: 500px;
}

.settings-container h1 {
    margin-bottom: 24px;
}

.settings-section {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.settings-section h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.setting-row {
    margin-bottom: 16px;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-row label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
}

.setting-row small {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.setting-row small a {
    color: var(--primary);
}

.invite-code-container {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.invite-code-container code {
    background: var(--background);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 1.1rem;
}

.member-list {
    list-style: none;
}

.member-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.member-list li:last-child {
    border-bottom: none;
}

.member-list li {
    flex-wrap: wrap;
}

.member-name {
    flex: 1;
    min-width: 100px;
}

.member-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    width: 100%;
}

.member-actions .btn {
    font-size: 0.75rem;
    padding: 4px 8px;
}

.invite-link-input {
    flex: 1;
    font-size: 0.85rem;
    background: var(--background);
}

@media (min-width: 480px) {
    .member-actions {
        width: auto;
        margin-top: 0;
    }
}

.badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--secondary);
    color: white;
}

.badge-you {
    background: var(--primary);
}

.settings-actions {
    margin-top: 24px;
}

.status-success {
    color: var(--primary);
}

.status-error {
    color: var(--danger);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius);
    z-index: 1000;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .navbar {
        padding: 10px 12px;
    }

    .nav-links {
        gap: 12px;
    }

    .nav-user {
        display: none;
    }

    .container {
        padding: 12px;
    }

    .list-item {
        padding: 10px;
    }

    .item-category {
        display: none;
    }

    .auth-card {
        padding: 24px 16px;
    }
}

/* Inline Suggestions (under each item) */
.list-item-wrapper {
    margin-bottom: 4px;
}

.inline-suggestions {
    background: var(--suggestion-bg);
    margin-left: 36px;
    margin-top: 2px;
    padding: 8px 12px;
    border-radius: 0 0 var(--radius) var(--radius);
    border-left: 2px solid var(--primary);
}

.inline-suggestion {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.inline-suggestion:last-child {
    border-bottom: none;
}

.suggestion-info {
    flex: 1;
}

.suggestion-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.suggestion-reason {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
}

.learned-badge {
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
}

.suggestion-actions {
    display: flex;
    gap: 6px;
}

.suggestion-loading,
.no-suggestions,
.suggestion-error {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 4px 0;
}

/* Restock Suggestions */
.restock-container {
    background: #FFF3E0;
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 16px;
    border-left: 3px solid #FF9800;
}

.restock-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    margin-bottom: 8px;
    color: #E65100;
}

.restock-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.restock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 8px 12px;
    border-radius: var(--radius);
}

.restock-info {
    flex: 1;
}

.restock-name {
    font-weight: 500;
}

.restock-reason {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
}

/* Make item content clickable */
.item-content {
    cursor: pointer;
}

.item-content:hover .item-name {
    color: var(--primary);
}

/* Dark Mode Toggle */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-secondary);
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--border);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Product Images */
.item-image {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--border);
}

.item-image-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 16px;
}

/* UPC Scanner Button */
.scan-btn {
    background: var(--secondary);
    color: white;
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-btn:hover {
    background: #546E7A;
}

.scan-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* UPC Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal h2 {
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.modal-actions .btn {
    flex: 1;
}

/* Product lookup result */
.product-result {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--background);
    border-radius: var(--radius);
    margin-top: 12px;
}

.product-result img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
}

.product-result-info {
    flex: 1;
}

.product-result-name {
    font-weight: 500;
}

.product-result-brand {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Autocomplete Dropdown */
.autocomplete-container {
    position: relative;
    flex: 1;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

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

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--background);
}

.autocomplete-item-image {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--border);
    flex-shrink: 0;
}

.autocomplete-item-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.autocomplete-item-info {
    flex: 1;
    min-width: 0;
}

.autocomplete-item-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.autocomplete-item-generic {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.autocomplete-loading {
    padding: 12px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
