/* 全域重設與變數定義 */
:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #10b981;
    --accent-bento: #f59e0b; /* 橘黃色用於便當 */
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition-speed: 0.3s;
}

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

body {
    font-family: 'Noto Sans TC', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.app-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

/* 標頭樣式與微動畫 */
.app-header {
    text-align: center;
    margin-bottom: 30px;
    animation: fadeInDown 0.8s ease-out;
}

.app-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #a78bfa, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header .subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    letter-spacing: 2px;
}

/* 主要排版：自適應網格 */
.main-content {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 25px;
    animation: fadeInUp 0.8s ease-out;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* 卡片通用樣式 (玻璃擬態) */
.order-form-card, .order-list-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.order-form-card:hover, .order-list-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.2);
}

.order-form-card h2, .order-list-card h2 {
    font-size: 1.4rem;
    font-weight: 500;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 分頁切換 (Tabs) 樣式 */
.tabs-container {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 25px;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.25s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* 顯示與隱藏實用類 */
.d-none {
    display: none !important;
}

.form-section {
    animation: fadeIn 0.4s ease-out;
}

/* 表單群組與選擇按鈕 */
.form-group {
    margin-bottom: 25px;
}

.group-label {
    display: block;
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
}

/* 暱稱/備註輸入框美化 */
.text-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 14px 16px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.text-input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.text-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 480px) {
    .grid-cols-2 {
        grid-template-columns: 1fr;
    }
}

/* 選項按鈕美化與動畫 */
.option-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.option-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
    transform: scale(1.02);
}

/* 便當與飲料選項圖片及 Emoji 對齊樣式 */
.option-img, .option-emoji-placeholder {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    margin-bottom: 6px;
    transition: all 0.25s ease;
}

.option-img {
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.option-btn:hover .option-img {
    border-color: rgba(255, 255, 255, 0.3);
}

.option-btn.active .option-img {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.option-emoji-placeholder {
    background: rgba(255, 255, 255, 0.04);
    font-size: 1.8rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.option-btn:hover .option-emoji-placeholder {
    background: rgba(255, 255, 255, 0.08);
}

.option-btn.active .option-emoji-placeholder {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

/* 數量控制 */
.quantity-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quantity-controller {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
}

.qty-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 8px;
}

.qty-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

#quantity-display {
    width: 40px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 500;
}

/* 提交按鈕 */
.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border: none;
    color: white;
    padding: 16px;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

.submit-btn:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
}

.submit-btn:active {
    transform: translateY(0);
}

/* 訂單清單標頭 */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.list-header h2 {
    margin-bottom: 0;
}

.refresh-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* 訂單容器 */
.orders-container {
    max-height: 450px;
    overflow-y: auto;
    padding-right: 5px;
}

/* 客製化滾動條 */
.orders-container::-webkit-scrollbar {
    width: 6px;
}

.orders-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}

.orders-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* 訂單卡片項目與進場動畫 */
.order-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.25s;
    animation: slideIn 0.3s ease-out;
}

.order-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

.order-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.order-title {
    font-size: 1.05rem;
    font-weight: 500;
}

.order-nickname {
    color: #a78bfa;
    font-weight: 700;
}

.order-drink, .order-bento-title {
    color: var(--text-primary);
}

.order-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.order-time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
}

.order-notes {
    font-size: 0.8rem;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 4px 8px;
    border-radius: 6px;
    margin-top: 4px;
    display: inline-block;
    align-self: flex-start;
    max-width: 90%;
    word-break: break-all;
}

.order-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid rgba(16, 185, 129, 0.2);
    margin-left: 10px;
    flex-shrink: 0;
}

/* 便當徽章樣式 */
.order-badge-bento {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-bento);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

/* 狀態顯示 */
.loading-state, .empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 0;
    font-size: 0.95rem;
}

.empty-state {
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

/* 頁尾 */
.app-footer {
    text-align: center;
    margin-top: 30px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* CSS 動畫效果 */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
