/* ==========================================================================
   暮色茶事 點餐機樣式表 (CSS)
   設計風格：質感日系暖茶色系，著重精緻的圓角、微互動與流暢過渡效果。
   ========================================================================== */

/* 全域基礎重設 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-color: #FAF6F0;          /* 暖米白背景色 */
    --panel-bg: #FFFFFF;          /* 卡片純白背景 */
    --primary-color: #5C3D2E;      /* 深茶褐（主要品牌色） */
    --accent-color: #865439;       /* 奶茶褐（醒目點綴色） */
    --light-accent: #C68B59;       /* 淺秋褐（邊框與懸停色） */
    --cream-yellow: #F4EEDB;       /* 奶油黃（啟動狀態背景） */
    --text-main: #33221C;          /* 深褐文字（主要內容） */
    --text-muted: #8A7E72;         /* 灰褐文字（副標與註解） */
    --border-color: #EFE9E1;       /* 輕柔灰褐邊框 */
    --shadow-sm: 0 4px 12px rgba(92, 61, 46, 0.04);
    --shadow-md: 0 8px 24px rgba(92, 61, 46, 0.08);
    --radius-lg: 16px;
    --radius-md: 10px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Noto Sans TC', 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
    padding: 40px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 頁首樣式 */
.app-header {
    text-align: center;
    margin-bottom: 40px;
    max-width: 800px;
}

.app-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.app-header h1 span {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--light-accent);
    border-left: 2px solid var(--border-color);
    padding-left: 12px;
}

.app-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 10px;
}

/* 主容器排版 */
.app-container {
    width: 100%;
    max-width: 1024px;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 30px;
    margin-bottom: 40px;
    align-items: start;
}

/* 面板通用樣式 */
.order-panel, .records-panel {
    background-color: var(--panel-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 30px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.order-panel:hover, .records-panel:hover {
    box-shadow: 0 12px 32px rgba(92, 61, 46, 0.12);
}

/* 單元標題 */
.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    background-color: var(--accent-color);
    border-radius: 2px;
}

/* 顧客暱稱輸入框樣式 */
.nickname-container {
    margin-bottom: 24px;
}

.nickname-container input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: var(--bg-color);
    outline: none;
    transition: var(--transition);
}

.nickname-container input:focus {
    border-color: var(--accent-color);
    background-color: var(--panel-bg);
    box-shadow: 0 4px 10px rgba(134, 84, 57, 0.05);
}

/* 歷史訂單暱稱標籤 */
.order-nickname {
    font-size: 0.8rem;
    color: var(--accent-color);
    font-weight: 500;
    background-color: var(--cream-yellow);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px dashed var(--light-accent);
}

/* 歷史訂單下午茶餐點標籤 */
.order-snack-tag {
    font-size: 0.8rem;
    color: #FFFFFF;
    font-weight: 500;
    background-color: var(--accent-color);
    padding: 2px 8px;
    border-radius: 20px;
    margin-top: 2px;
}

/* 按鈕選擇系統的排版 */
.drink-options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.options-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 28px;
}

/* 通用選項按鈕 */
.option-btn {
    background-color: var(--panel-bg);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    outline: none;
}

.option-btn:hover {
    border-color: var(--light-accent);
    background-color: rgba(198, 139, 89, 0.03);
    transform: translateY(-2px);
}

/* 飲料按鈕特化 */
.drink-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 10px;
    gap: 8px;
}

.drink-btn .btn-icon {
    font-size: 1.8rem;
    transition: var(--transition);
}

.drink-btn .btn-text {
    font-weight: 700;
    font-size: 0.95rem;
}

/* 啟動狀態的按鈕 (.active) */
.option-btn.active {
    background-color: var(--cream-yellow);
    border-color: var(--accent-color);
    color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(134, 84, 57, 0.15);
    transform: scale(1.02);
}

.drink-btn.active .btn-icon {
    transform: scale(1.15) rotate(-5deg);
}

/* 底部操作控制區 */
.action-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
}

/* 數量選擇器 */
.quantity-selector {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-color);
    overflow: hidden;
}

.qty-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    width: 44px;
    height: 44px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.qty-btn:hover {
    background-color: rgba(92, 61, 46, 0.05);
}

.qty-display {
    width: 40px;
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-color);
}

/* 送出按鈕 */
.submit-btn {
    flex: 1;
    background-color: var(--primary-color);
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-md);
    height: 46px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(92, 61, 46, 0.2);
    transition: var(--transition);
}

.submit-btn:hover {
    background-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(134, 84, 57, 0.3);
}

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

/* 送出時載入中動畫 */
.submit-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #FFFFFF;
    animation: spin 0.8s linear infinite;
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 歷史紀錄面板 */
.records-panel {
    display: flex;
    flex-direction: column;
    max-height: 520px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel-header .section-title {
    margin-bottom: 0;
}

.refresh-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: var(--transition);
}

.refresh-btn:hover {
    background-color: rgba(92, 61, 46, 0.05);
    transform: rotate(180deg);
}

/* 讀取中動畫 (三個點) */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    gap: 16px;
}

.dots-loader {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 20px;
}
.dots-loader div {
    position: absolute;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--light-accent);
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}
.dots-loader div:nth-child(1) {
    left: 8px;
    animation: dots1 0.6s infinite;
}
.dots-loader div:nth-child(2) {
    left: 8px;
    animation: dots2 0.6s infinite;
}
.dots-loader div:nth-child(3) {
    left: 32px;
    animation: dots2 0.6s infinite;
}
@keyframes dots1 {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}
@keyframes dots2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(24px, 0); }
}

/* 空白狀態 */
.empty-state {
    text-align: center;
    padding: 60px 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* 訂單列表 */
.orders-list {
    list-style: none;
    overflow-y: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 訂單卡片 */
.order-card {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease forwards;
    transition: var(--transition);
}

.order-card:hover {
    border-color: var(--light-accent);
    background-color: var(--cream-yellow);
}

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

.order-drink-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-qty-tag {
    background-color: var(--primary-color);
    color: #FFFFFF;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.order-custom-details {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
}

.order-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
}

.order-card-right {
    text-align: right;
}

.order-price-tag {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    color: var(--accent-color);
    font-size: 1.1rem;
}

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

/* 頁尾樣式 */
.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    width: 100%;
    max-width: 800px;
}

/* 工具類別：隱藏 */
.hidden {
    display: none !important;
}

/* 滾動條質感美化 */
.orders-list::-webkit-scrollbar {
    width: 6px;
}

.orders-list::-webkit-scrollbar-track {
    background: transparent;
}

.orders-list::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}

.orders-list::-webkit-scrollbar-thumb:hover {
    background-color: var(--light-accent);
}

/* ==========================================================================
   響應式排版 (Responsive Design)
   ========================================================================== */
@media (max-width: 768px) {
    body {
        padding: 20px 10px;
    }

    .app-header h1 {
        font-size: 1.8rem;
    }

    .app-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .order-panel, .records-panel {
        padding: 20px;
    }

    .drink-options-grid {
        gap: 8px;
    }
}
