/* TapGo 線上點餐系統樣式 */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #f8fafc;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--secondary-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: white;
    box-shadow: var(--shadow-lg);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: bold;
}

.kitchen-link {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.5rem;
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.1);
}

.kitchen-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.cart-btn {
    position: relative;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.cart-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.cart-icon {
    font-size: 1.25rem;
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger-color);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.cart-badge.hidden {
    display: none;
}

/* Main Content */
.main {
    padding: 1rem;
    padding-bottom: 2rem;
}

.category {
    margin-bottom: 2rem;
}

.category-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.category-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.items-grid {
    display: grid;
    gap: 0.75rem;
}

.item-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
}

.item-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.item-content {
    width: 100%;
}

.item-main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.item-name {
    font-weight: 600;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.item-price {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.1rem;
    flex-shrink: 0;
    white-space: nowrap;
}

.item-note {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 0.25rem;
    word-break: break-word;
}

/* 手機優化 */
@media (max-width: 480px) {
    .item-main {
        gap: 0.75rem;
    }
    
    .item-name {
        font-size: 1rem;
        line-height: 1.3;
    }
    
    .item-price {
        font-size: 1rem;
        font-weight: 700;
    }
    
    .item-note {
        font-size: 0.8rem;
        margin-top: 0.5rem;
        padding-left: 0;
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalSlideUp 0.3s ease-out;
}

.cart-modal-content {
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--secondary-color);
    color: var(--text-color);
}

.modal-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.item-info {
    text-align: center;
    margin-bottom: 2rem;
}

.modal-body .item-price {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.quantity-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.qty-btn {
    width: 40px;
    height: 40px;
    border: 2px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    border-radius: 50%;
    font-size: 1.25rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qty-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

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

.qty-display {
    font-size: 1.5rem;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.add-to-cart-btn,
.submit-order-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.add-to-cart-btn:hover,
.submit-order-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

.submit-order-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

/* Cart Items */
.cart-items {
    margin-bottom: 1rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.cart-item-price {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-qty-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cart-qty-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.cart-qty-display {
    min-width: 30px;
    text-align: center;
    font-weight: bold;
}

.cart-remove-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

.cart-remove-btn:hover {
    background: #b91c1c;
}

.cart-total {
    border-top: 2px solid var(--border-color);
    padding-top: 1rem;
    margin-bottom: 1rem;
}

.total-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.25rem;
    font-weight: bold;
}

.total-amount {
    color: var(--primary-color);
}

/* Form */
.customer-info {
    margin-top: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group input:invalid {
    border-color: var(--danger-color);
}

/* Empty State */
.empty-cart {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.empty-cart-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 375px) {
    .app {
        max-width: 100%;
    }
    
    .main {
        padding: 0.75rem;
    }
    
    .modal-content {
        width: 95%;
    }
    
    .quantity-control {
        gap: 0.75rem;
    }
    
    .qty-btn {
        width: 36px;
        height: 36px;
    }
}

/* 金額上限相關樣式 */
.amount-limit-notice {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: rgba(100, 116, 139, 0.1);
    border-radius: 6px;
    border-left: 3px solid var(--text-muted);
}

.total-amount.over-limit {
    color: var(--danger-color);
    font-weight: bold;
    animation: pulseRed 1s ease-in-out;
}

.submit-order-btn.over-limit {
    background: var(--danger-color) !important;
    color: white !important;
    cursor: not-allowed !important;
    opacity: 0.8 !important;
}

.submit-order-btn.over-limit:hover {
    background: var(--danger-color) !important;
    transform: none !important;
    box-shadow: var(--shadow) !important;
}

.submit-order-btn.over-limit:disabled {
    background: var(--danger-color) !important;
    color: white !important;
    opacity: 0.8 !important;
}

@keyframes pulseRed {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 手機版金額上限樣式 */
@media (max-width: 480px) {
    .amount-limit-notice {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
        padding: 0.4rem;
    }
}