/* ==========================================================================
   極簡美學 CSS 設計系統
   採用深色科技風與優雅的玻璃擬態 (Glassmorphism)
   ========================================================================== */

/* 全域變數定義：和諧的配色方案 */
:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --panel-bg: rgba(30, 41, 59, 0.45);
    --panel-border: rgba(255, 255, 255, 0.08);
    --primary-color: #6366f1; /* 靛藍色 */
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.3);
    --accent-color: #10b981; /* 綠色，代表現貨或成功 */
    --accent-glow: rgba(16, 185, 129, 0.2);
    --danger-color: #f43f5e; /* 玫瑰紅，代表刪除 */
    --danger-hover: #e11d48;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-border: rgba(255, 255, 255, 0.1);
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius-lg: 20px;
    --border-radius-md: 12px;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

/* 主要容器 */
.app-container {
    width: 100%;
    max-width: 1280px;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 頂部標題設計 */
.app-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 24px;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2.2rem;
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

.logo h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo h1 span {
    font-weight: 300;
    color: var(--text-secondary);
    margin-left: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 300;
}

/* 會員驗證控制區 */
.auth-status-bar.glass-card {
    padding: 10px 20px;
    border-radius: 40px;
    background: rgba(30, 41, 59, 0.6);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

.user-info-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    font-size: 1.3rem;
    color: var(--primary-color);
}

.user-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* 主要排版：左表單，右清單 */
.app-main {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 30px;
    align-items: start;
}

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

/* 玻璃擬態卡片 */
.glass-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--border-radius-lg);
    padding: 30px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px 0 rgba(99, 102, 241, 0.05);
}

/* 表單區塊設計 */
.card-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.card-title i {
    color: var(--primary-color);
}

.nice-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* 輸入框包裝與圖示 */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 1rem;
    transition: var(--transition-smooth);
}

.input-wrapper input,
.input-wrapper textarea {
    width: 100%;
    padding: 14px 14px 14px 42px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    outline: none;
}

.input-wrapper textarea {
    resize: none;
}

.input-wrapper input:focus,
.input-wrapper textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(15, 23, 42, 0.85);
}

.input-wrapper input:focus + .input-icon,
.input-wrapper textarea:focus + .input-icon {
    color: var(--primary-color);
}

/* 現貨開關切換 (Toggle Switch) */
.row-group {
    flex-direction: row;
    align-items: center;
}

.switch-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    cursor: pointer;
}

.label-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--text-muted);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-glow);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* 按鈕美學 */
.btn {
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 12px 24px;
    border-radius: var(--border-radius-md);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #4f46e5 100%);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.btn-danger {
    background: rgba(244, 63, 94, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.btn-danger:hover {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--primary-color);
    transform: rotate(180deg);
}

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

.hidden {
    display: none !important;
}

/* 右側清單設計 */
.list-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title {
    font-size: 1.4rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title i {
    color: var(--accent-color);
}

.badge {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-color);
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* 商品卡片網格 */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* 個別商品卡片 */
.product-card {
    background: rgba(30, 41, 59, 0.35);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.product-card:hover {
    transform: translateY(-4px);
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(30, 41, 59, 0.5);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* 商品現貨標籤背景發光效果 */
.product-card.in-stock::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-color);
}

.product-card.out-of-stock::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--text-muted);
}

.product-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 現貨徽章 */
.stock-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.stock-badge.yes {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.stock-badge.no {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.product-card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
}

.product-card-price {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f1f5f9;
}

.product-card-price span {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-right: 2px;
}

.product-card-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 42px;
}

/* 卡片操作區 */
.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 14px;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.btn-edit {
    background: rgba(99, 102, 241, 0.1);
    color: #a5b4fc;
}

.btn-edit:hover {
    background: var(--primary-color);
    color: white;
}

.btn-delete {
    background: rgba(244, 63, 94, 0.1);
    color: #fda4af;
}

.btn-delete:hover {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

/* 空狀態與載入動畫 */
.empty-state-card {
    text-align: center;
    padding: 60px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.empty-icon {
    font-size: 3.5rem;
    color: var(--text-muted);
}

.empty-state-card h3 {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.empty-state-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* 精緻的載入動畫 (Spinner) */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 150px;
}

.double-bounce1, .double-bounce2 {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    opacity: 0.6;
    position: absolute;
    animation: sk-bounce 2.0s infinite ease-in-out;
}

.double-bounce2 {
    animation-delay: -1.0s;
}

@keyframes sk-bounce {
    0%, 100% { 
        transform: scale(0.0);
    } 50% { 
        transform: scale(1.0);
    }
}

/* ==========================================================================
   新增的會員註冊/登入彈窗 (Auth Modal) 樣式
   ========================================================================== */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 當有 active 類別時才顯示 */
.auth-modal.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.auth-modal-content {
    width: 100%;
    max-width: 420px;
    position: relative;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(30px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 當外層 active 時，內部卡片產生彈升動畫 */
.auth-modal.active .auth-modal-content {
    transform: translateY(0) scale(1);
}

/* 關閉按鈕 */
.auth-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: var(--transition-smooth);
}

.auth-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    transform: scale(1.1);
}

.auth-title {
    font-size: 1.6rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #f8fafc 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.auth-actions .btn {
    width: 100%;
}

.auth-toggle-tip {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-smooth);
    margin-left: 4px;
}

.auth-link:hover {
    color: #818cf8;
    text-decoration: underline;
}

/* ==========================================================================
   Toast 提示訊息系統
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 9999;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 16px 24px;
    border-radius: var(--border-radius-md);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transform: translateY(50px);
    opacity: 0;
    animation: toast-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.success {
    border-left: 4px solid var(--accent-color);
}

.toast.success i {
    color: var(--accent-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.error i {
    color: var(--danger-color);
}

@keyframes toast-in {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast.toast-out {
    animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-out {
    to {
        transform: translateY(-20px);
        opacity: 0;
    }
}

/* 頁尾 */
.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 300;
    margin-top: 20px;
}
