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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background-color: #2c3e50;
    color: white;
    border-radius: 8px;
}

header h1 {
    font-size: 1.8rem;
}

header p {
    opacity: 0.8;
    font-size: 0.95rem;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.user-info span {
    opacity: 0.8;
}

#logout-btn {
    padding: 5px 12px;
    font-size: 0.8rem;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

#logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Auth styles */
.auth-card {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    margin: 0 auto;
}

.auth-card h2 {
    margin-bottom: 20px;
    text-align: center;
}

.auth-error {
    color: #e74c3c;
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-align: center;
}

.auth-toggle {
    text-align: center;
    margin-top: 15px;
    font-size: 0.9rem;
    color: #666;
}

.auth-toggle a {
    color: #3498db;
    text-decoration: none;
    font-weight: 600;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

#auth-submit-btn {
    width: 100%;
    background-color: #2c3e50;
    color: white;
}

/* Form styles */
.form-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-section h2 {
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-actions {
    display: flex;
    gap: 10px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
}

.hidden {
    display: none;
}

/* Back button */
.btn-back {
    background: none;
    color: #3498db;
    padding: 0;
    font-size: 0.95rem;
    margin-bottom: 15px;
}

.btn-back:hover {
    text-decoration: underline;
}

/* Floating action button */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #27ae60;
    color: white;
    font-size: 2rem;
    line-height: 1;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    background-color: #219a52;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* Detail page actions */
.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

#detail-save-btn {
    flex: 1;
    background-color: #27ae60;
    color: white;
}

#detail-delete-btn {
    background-color: #e74c3c;
    color: white;
}

.btn-to-shopping {
    background-color: #3498db;
    color: white;
}

.btn-to-shopping:hover {
    background-color: #2980b9;
}

#add-submit-btn {
    width: 100%;
    background-color: #27ae60;
    color: white;
}

/* Barcode scanner styles */
.barcode-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

#barcode-reader,
#shopping-barcode-reader {
    margin-bottom: 15px;
    border-radius: 6px;
    overflow: hidden;
}

.barcode-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.btn-scan {
    flex: 1;
    background-color: #8e44ad;
    color: white;
}

.btn-scan:hover {
    background-color: #7d3c98;
}

.btn-scan-stop {
    flex: 1;
    background-color: #95a5a6;
    color: white;
}

.barcode-input-row {
    display: flex;
    gap: 8px;
}

.barcode-input-row input {
    flex: 1;
}

#barcode-lookup-btn,
#shopping-barcode-lookup-btn {
    background-color: #3498db;
    color: white;
    padding: 10px 16px;
    white-space: nowrap;
}

.barcode-status {
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 10px;
}

.barcode-status.found {
    background-color: #eafaf1;
    color: #27ae60;
    border: 1px solid #27ae60;
}

.barcode-status.not-found {
    background-color: #fef5e7;
    color: #f39c12;
    border: 1px solid #f39c12;
}

/* Product list styles */
.list-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.list-section h2 {
    margin-bottom: 15px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.search-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
}

.search-bar input:focus {
    outline: none;
    border-color: #3498db;
}

.btn-search-scan {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    background-color: #3498db;
    color: white;
    font-size: 1.1rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-search-scan:hover {
    background-color: #2980b9;
}

.btn-search-clear {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    background-color: #e74c3c;
    color: white;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

#product-search-reader,
#shopping-search-reader {
    margin-bottom: 10px;
    border-radius: 6px;
    overflow: hidden;
}

#empty-message,
#shopping-empty-message {
    text-align: center;
    color: #999;
    padding: 20px;
}

.product-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 5px solid #27ae60;
    background-color: #f9f9f9;
    cursor: pointer;
    transition: background-color 0.15s;
}

.product-card:hover {
    filter: brightness(0.97);
}

.product-card.expired {
    border-left-color: #e74c3c;
    background-color: #fdeaea;
}

.product-card.expiring-soon {
    border-left-color: #f39c12;
    background-color: #fef5e7;
}

.product-card.fresh {
    border-left-color: #27ae60;
    background-color: #eafaf1;
}

.product-card.no-date {
    border-left-color: #bbb;
    background-color: #f9f9f9;
}

.product-info {
    flex: 1;
}

.product-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.product-date {
    font-size: 0.9rem;
    color: #666;
    margin-top: 2px;
}

.product-countdown {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 2px;
    color: #27ae60;
}

.product-countdown.expiring-soon {
    color: #f39c12;
}

.product-countdown.expired {
    color: #e74c3c;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

.status-badge.expired {
    background-color: #e74c3c;
    color: white;
}

.status-badge.expiring-soon {
    background-color: #f39c12;
    color: white;
}

.product-chevron {
    color: #bbb;
    font-size: 1.2rem;
    margin-left: 10px;
}

/* Tab navigation */
.tab-nav {
    display: flex;
    margin-bottom: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: white;
    color: #666;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    color: #2c3e50;
    border-bottom-color: #27ae60;
    background-color: #f0faf4;
}

/* Product store display */
.product-store {
    font-size: 0.85rem;
    color: #888;
    margin-top: 2px;
}

/* Collapsible group headers */
.group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 4px;
    margin-top: 10px;
    margin-bottom: 4px;
    border-bottom: 2px solid #2c3e50;
    cursor: pointer;
    user-select: none;
}

.group-header:first-child {
    margin-top: 0;
}

.group-header:hover {
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 4px 4px 0 0;
}

.group-arrow {
    font-size: 0.75rem;
    color: #888;
    width: 14px;
    text-align: center;
}

.group-title {
    font-weight: 700;
    font-size: 1rem;
    color: #2c3e50;
}

.group-count {
    font-size: 0.8rem;
    color: #888;
    background-color: #eee;
    padding: 1px 8px;
    border-radius: 10px;
    margin-left: auto;
}

.shopping-group-header {
    border-bottom-color: #3498db;
}

/* Shopping list styles */

.shopping-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 5px solid #3498db;
    background-color: #eaf2f8;
    transition: background-color 0.15s;
}

.shopping-card:hover {
    filter: brightness(0.97);
}

.shopping-info {
    flex: 1;
    cursor: pointer;
}

.shopping-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.shopping-meta {
    font-size: 0.9rem;
    color: #666;
    margin-top: 2px;
    display: flex;
    gap: 10px;
}

.shopping-quantity {
    font-weight: 600;
    color: #3498db;
}

.shopping-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 10px;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

.btn-qty {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #3498db;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-qty:hover {
    background-color: #2980b9;
}

.qty-value {
    min-width: 28px;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    color: #2c3e50;
}

.btn-shopping-delete {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
    transition: background-color 0.15s;
}

.btn-shopping-delete:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

/* Convert to product view */
.convert-info {
    margin-bottom: 15px;
    color: #666;
    font-size: 0.95rem;
}

#shopping-add-submit-btn,
#convert-submit-btn {
    width: 100%;
    background-color: #27ae60;
    color: white;
}

/* --- Date Scroll Picker --- */

/* Display field (looks like a regular input) */
.date-picker-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 1rem;
    color: #333;
    user-select: none;
    min-height: 42px;
    transition: border-color 0.15s;
}

.date-picker-wrapper:hover {
    border-color: #999;
}

.dp-field-icon {
    font-size: 1rem;
    opacity: 0.4;
    flex-shrink: 0;
}

.date-picker-wrapper.dp-disabled {
    opacity: 0.35;
    pointer-events: none;
}

.no-date-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
    font-size: 0.9rem;
    color: #555;
    cursor: pointer;
    user-select: none;
}

.no-date-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Modal overlay */
.dp-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dp-modal.hidden {
    display: none;
}

.dp-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.dp-card {
    position: relative;
    background: white;
    border: 2px solid #2c3e50;
    border-radius: 10px;
    overflow: hidden;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.dp-actions {
    display: flex;
    border-top: 1px solid #eee;
}

.dp-actions button {
    flex: 1;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    border-radius: 0;
}

#dp-cancel-btn {
    background: #f5f5f5;
    color: #555;
    border-right: 1px solid #eee;
}

#dp-cancel-btn:hover {
    background: #ebebeb;
}

#dp-confirm-btn {
    background: #27ae60;
    color: white;
}

#dp-confirm-btn:hover {
    background: #219a52;
}

/* Drum-roll picker (inside modal) */
.picker-header {
    display: flex;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.picker-col-head {
    flex: 1;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 5px 0;
}

.picker-row {
    display: flex;
    height: 220px;
    position: relative;
    overflow: hidden;
}

.picker-row::before,
.picker-row::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 38%;
    pointer-events: none;
    z-index: 2;
}

.picker-row::before {
    top: 0;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.93), transparent);
}

.picker-row::after {
    bottom: 0;
    background: linear-gradient(to top, rgba(255, 255, 255, 0.93), transparent);
}

.picker-selection-indicator {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 44px;
    border-top: 1.5px solid #2c3e50;
    border-bottom: 1.5px solid #2c3e50;
    pointer-events: none;
    z-index: 3;
}

.picker-col {
    flex: 1;
    overflow: hidden;
}

.picker-col:not(:last-child) {
    border-right: 1px solid #eee;
}

.picker-scroller {
    height: 220px;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.picker-scroller::-webkit-scrollbar {
    display: none;
}

.picker-item {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #333;
    scroll-snap-align: center;
    cursor: default;
    user-select: none;
}

.picker-pad {
    height: 44px;
    scroll-snap-align: none;
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .header-row {
        flex-direction: column;
        gap: 8px;
    }

    .fab {
        bottom: 20px;
        right: 20px;
    }
}
