/* Self-Order Style - Mobile First Colorful Design */

:root {
    --bg-main: #f5f5f0;
    --card-yellow: #f5c842;
    --card-green: #a8e6cf;
    --card-pink: #ffb6c1;
    --card-blue: #87ceeb;
    --card-purple: #dda0dd;
    --card-orange: #ffcc80;
    --text-dark: #1a1a1a;
    --text-gray: #666;
    --border-color: #2a2a2a;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --radius: 16px;
    --radius-sm: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
    min-height: 100vh;
}

/* Header - Fixed on mobile */
.header {
    background: white;
    border-bottom: 2px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
}

.logo-icon {
    background: var(--card-yellow);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-btn {
    position: relative;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.cart-btn:active {
    transform: scale(0.95);
}

.cart-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #c62828;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
}

.cart-badge.show {
    display: flex;
}

.logout-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #c62828;
    cursor: pointer;
    padding: 8px;
}

/* Main Content - Mobile First */
.main-content-mobile {
    padding: 16px;
    padding-bottom: 100px;
}

/* Search Bar */
.search-bar {
    margin-bottom: 16px;
}

.search-input {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-input i {
    color: var(--text-gray);
}

.search-input input {
    border: none;
    outline: none;
    font-size: 1rem;
    width: 100%;
    background: transparent;
}

/* Product Grid - 2 columns on mobile */
.product-grid-mobile {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Product Card - Mobile */
.product-card-mobile {
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.product-card-mobile.yellow {
    background: var(--card-yellow);
}

.product-card-mobile.green {
    background: var(--card-green);
}

.product-card-mobile.pink {
    background: var(--card-pink);
}

.product-card-mobile.blue {
    background: var(--card-blue);
}

.product-card-mobile.purple {
    background: var(--card-purple);
}

.product-card-mobile.orange {
    background: var(--card-orange);
}

.product-top {
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.product-icon-box {
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.stock-badge {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.product-info {
    padding: 0 12px 8px;
    flex: 1;
}

.product-name {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 2px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-unit {
    font-size: 0.75rem;
    color: var(--text-gray);
}

.product-action {
    padding: 0 12px 12px;
}

.add-cart-btn {
    width: 100%;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 600;
}

.add-cart-btn:active {
    transform: scale(0.98);
    background: rgba(0, 0, 0, 0.05);
}

.add-cart-btn i {
    font-size: 1rem;
}

/* Cart Modal - Full Screen on Mobile */
.cart-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.cart-modal.show {
    display: flex;
}

.cart-modal-content {
    background: white;
    width: 100%;
    max-height: 85vh;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.cart-modal-header {
    padding: 20px;
    border-bottom: 2px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-modal-header h2 {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-gray);
    line-height: 1;
}

.cart-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.cart-item {
    background: #f9f9f9;
    border: 2px solid #eee;
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-item> :first-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-item-unit {
    font-size: 0.75rem;
    color: var(--text-gray);
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 6px;
}

.qty-btn {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: background 0.2s;
}

.qty-btn:active {
    background: #eee;
}

.qty-input {
    width: 48px;
    height: 32px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.del-btn {
    background: none;
    border: none;
    color: #c62828;
    cursor: pointer;
    padding: 6px;
    margin-left: 4px;
}

.cart-item-note {
    width: 100%;
}

.note-input {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.8rem;
    outline: none;
    background: white;
    transition: border-color 0.2s;
}

.note-input:focus {
    border-color: var(--card-yellow);
}

.note-input::placeholder {
    color: #bbb;
    font-style: italic;
}

.cart-modal-footer {
    padding: 16px;
    border-top: 2px solid #eee;
    background: white;
}

.date-label {
    font-size: 0.85rem;
    font-weight: 600;
    display: block;
    margin-bottom: 6px;
}

.date-input {
    width: 100%;
    border: 2px solid #eee;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 1rem;
    margin-bottom: 12px;
}

.btn-submit {
    width: 100%;
    background: var(--border-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 16px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-submit:active {
    opacity: 0.9;
}

/* Auth Screen */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-main);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.auth-card {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-icon {
    background: var(--card-yellow);
    border: 2px solid var(--border-color);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 20px;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--text-gray);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.auth-input-wrapper {
    position: relative;
    margin-bottom: 16px;
}

.auth-input {
    width: 100%;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.auth-input:focus {
    border-color: var(--card-yellow);
}

.auth-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
}

.auth-suggestions.show {
    display: block;
}

.suggestion-item {
    padding: 14px 16px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    text-align: left;
    transition: background 0.2s;
}

.suggestion-item:active {
    background: var(--card-yellow);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-name {
    font-weight: 700;
}

.suggestion-username {
    font-size: 0.85rem;
    color: var(--text-gray);
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

.btn-primary {
    flex: 1;
    background: var(--border-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 14px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
}

.btn-primary:active {
    opacity: 0.9;
}

.btn-secondary {
    background: var(--card-purple);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    font-weight: 700;
    cursor: pointer;
}

.btn-secondary:active {
    opacity: 0.9;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 400px;
}

.modal-icon {
    background: var(--card-purple);
    border: 2px solid var(--border-color);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.modal-subtitle {
    color: var(--text-gray);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.modal-input {
    width: 100%;
    border: 2px solid #eee;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 1rem;
    outline: none;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}

.modal-input:focus {
    border-color: var(--card-purple);
}

.modal-textarea {
    width: 100%;
    border: 2px solid #eee;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 1rem;
    outline: none;
    resize: vertical;
    min-height: 100px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.modal-textarea:focus {
    border-color: var(--card-purple);
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.btn-cancel {
    flex: 1;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-weight: 600;
    cursor: pointer;
}

.btn-process {
    flex: 1;
    background: var(--card-purple);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 16px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.toast {
    background: var(--border-color);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    max-width: 300px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: #2e7d32;
}

.toast.error {
    background: #c62828;
}

.toast.warning {
    background: #f57c00;
}

@keyframes slideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-gray);
    font-style: italic;
    grid-column: 1 / -1;
}

/* Loading */
.loading {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Desktop adjustments */
@media (min-width: 768px) {
    .product-grid-mobile {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .main-content-mobile {
        max-width: 900px;
        margin: 0 auto;
    }

    .cart-modal-content {
        max-width: 500px;
        border-radius: var(--radius);
        margin-bottom: 20px;
    }

    .user-name {
        max-width: none;
    }
}

@media (min-width: 1024px) {
    .product-grid-mobile {
        grid-template-columns: repeat(4, 1fr);
    }

    .main-content-mobile {
        max-width: 1200px;
    }
}

@media (min-width: 1400px) {
    .product-grid-mobile {
        grid-template-columns: repeat(5, 1fr);
    }

    .main-content-mobile {
        max-width: 1500px;
        padding: 24px 32px;
    }
}

/* Updated Cart Layout Mobile */
.cart-item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s;
    color: var(--text-gray);
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-btn:active,
.action-btn.active {
    background: #eee;
    color: var(--text-dark);
}

.action-btn.del-btn {
    color: #c62828;
}

.action-btn.note-btn.active {
    color: var(--card-purple);
    background: #f3e5f5;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center the controls */
    gap: 12px;
    margin-bottom: 8px;
    background: white;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #eee;
}

.cart-item-controls .qty-btn {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
}

.cart-item-controls .qty-input {
    width: 60px;
    height: 36px;
    font-size: 1.1rem;
}

.cart-item-note {
    display: none;
    /* Hidden by default */
    margin-top: 8px;
    animation: slideInInput 0.2s ease;
}

.cart-item-note.show {
    display: block;
}

@keyframes slideInInput {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}