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

:root {
    /* 主色彩系統 */
    --primary-color: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --secondary-color: #f59e0b;
    --accent-color: #10b981;
    
    /* 中性色彩 */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* 功能色彩 */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
    
    /* 陰影系統 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* 圓角系統 */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* 間距系統 */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
}

body {
    font-family: 'Inter', 'Noto Sans TC', '微軟正黑體', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: var(--gray-800);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* 容器系統 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

/* 頁面佈局 */
.page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: var(--space-xl) 0;
}

/* Header 設計 */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) 0;
}

.logo {
    font-size: 1.875rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    transition: all 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

/* 導航設計 */
#main-nav {
    display: flex;
    gap: var(--space-lg);
}

#main-nav a {
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
    position: relative;
}

#main-nav a:hover {
    color: var(--primary-color);
    background: var(--gray-50);
    transform: translateY(-2px);
}

#user-nav {
    display: flex;
    gap: var(--space-sm);
}

#user-nav a {
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
    border: 1px solid var(--gray-200);
}

#user-nav a:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.admin-link {
    background: var(--secondary-color) !important;
    color: white !important;
    border-color: var(--secondary-color) !important;
}

/* 卡片系統 */
.card {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card-header {
    margin-bottom: var(--space-lg);
    text-align: center;
}

.card-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: var(--space-sm);
}

/* 商品篩選器 */
.product-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin: var(--space-xl) 0;
    padding: var(--space-lg);
    background: var(--gray-50);
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
}

.filter-btn {
    padding: var(--space-sm) var(--space-lg);
    border: 2px solid var(--gray-300);
    background: white;
    color: var(--gray-700);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
}

.product-count-info {
    text-align: center;
    margin: var(--space-xl) 0;
    padding: var(--space-md);
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    color: var(--gray-600);
    font-weight: 500;
}

/* 商品網格 */
.products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-xl);
    margin: var(--space-2xl) 0;
}

.product {
    background: white;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all 0.4s ease;
    position: relative;
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

.product-image-container {
    position: relative;
    height: 220px;
    overflow: hidden;
}

.product img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: all 0.4s ease;
    background: var(--gray-50);
}

.product:hover img {
    transform: scale(1.05);
}

.product-info {
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    flex: 1;
}

.product h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
    line-height: 1.3;
}

.product p {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin: 0;
    line-height: 1.5;
    flex: 1;
}

.product-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: var(--space-sm) 0;
}

/* 按鈕系統 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-md) var(--space-lg);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    width: 100%;
    margin-top: auto;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-200);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-color), #059669);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-danger {
    background: linear-gradient(135deg, var(--error-color), #dc2626);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* 表單設計 */
.auth-container {
    max-width: 400px;
    margin: var(--space-2xl) auto;
}

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-sm);
}

.form-group input {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 表格設計 */
.table-container {
    background: white;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--gray-50);
    color: var(--gray-700);
    font-weight: 600;
    padding: var(--space-lg);
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

td {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--gray-100);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: var(--gray-50);
}

/* 購物車特殊樣式 */
.cart-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin: var(--space-xl) 0;
}

.cart-item {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    gap: var(--space-lg);
    padding: var(--space-lg);
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    transition: all 0.3s ease;
}

.cart-item:hover {
    background: white;
    box-shadow: var(--shadow-md);
}

.cart-item-image {
    display: flex;
    align-items: center;
}

.cart-item-image img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.cart-item-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--space-sm);
}

.cart-item-info h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.cart-item-description {
    color: var(--gray-600);
    font-size: 0.875rem;
    line-height: 1.4;
    margin: 0;
}

.cart-item-price {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1rem;
}

.cart-item-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-md);
    min-width: 180px;
}

.quantity-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.quantity-controls label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

.quantity-input {
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.btn-quantity {
    background: var(--gray-100);
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    color: var(--gray-700);
}

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

.quantity-field {
    border: none;
    width: 60px;
    height: 32px;
    text-align: center;
    font-weight: 600;
    background: white;
    outline: none;
}

.cart-item-subtotal {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.125rem;
    text-align: center;
}

.btn-remove {
    font-size: 0.875rem;
    padding: var(--space-sm) var(--space-md);
    min-width: auto;
}

/* 響應式購物車設計 */
@media (max-width: 768px) {
    .cart-item {
        grid-template-columns: 80px 1fr;
        grid-template-areas: 
            "image info"
            "image controls";
    }
    
    .cart-item-image {
        grid-area: image;
    }
    
    .cart-item-info {
        grid-area: info;
    }
    
    .cart-item-controls {
        grid-area: controls;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        min-width: unset;
    }
    
    .cart-item-image img {
        width: 70px;
        height: 70px;
    }
}

.product-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.product-info img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.cart-summary {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    margin-top: var(--space-xl);
    text-align: center;
}

#total-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--space-lg);
}

/* 管理後台樣式 */
.admin-header {
    background: linear-gradient(135deg, var(--secondary-color), #f59e0b);
    color: white;
    padding: var(--space-xl);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-xl);
    text-align: center;
}

.admin-section {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    margin-bottom: var(--space-xl);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--gray-200);
}

/* 狀態卡片樣式 */
.status-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    min-width: 200px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.status-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.status-label {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: var(--space-sm);
    font-weight: 500;
}

.status-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-color);
}

.status-value.success {
    color: var(--success-color);
}

.status-value.warning {
    color: var(--warning-color);
}

.status-value.error {
    color: var(--error-color);
}

/* 訊息樣式 */
.message {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    margin: var(--space-md) 0;
    font-weight: 500;
}

.message-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.message-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.message-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }
    
    #main-nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .products {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: var(--space-lg);
    }
    
    .container {
        padding: 0 var(--space-sm);
    }
    
    .card {
        padding: var(--space-lg);
    }
    
    .product-info {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .products {
        grid-template-columns: 1fr;
    }
    
    .auth-container {
        margin: var(--space-lg) auto;
        padding: 0 var(--space-sm);
    }
}

/* 載入動畫 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

/* 載入中狀態 */
.loading {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 滾動條美化 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* New Footer Design */
.new-footer {
    background-color: #fdfdfd;
    color: #555;
    padding: 40px 0 20px 0;
    border-top: 1px solid #eee;
}

.new-footer .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.new-footer .footer-main {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 30px;
}

.new-footer .footer-column {
    flex: 1;
    min-width: 220px;
}

.new-footer h4 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.new-footer p {
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 10px;
}

.new-footer ul {
    list-style: none;
    padding: 0;
}

.new-footer ul li {
    margin-bottom: 8px;
}

.new-footer ul li a {
    color: #555;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s;
}

.new-footer ul li a:hover {
    color: #000;
}

.new-footer .contact-info-new p {
    margin-bottom: 5px;
}

.new-footer .social-links-new {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.new-footer .social-links-new a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 50%;
    text-decoration: none;
    transition: all 0.3s;
}

.new-footer .social-links-new a:hover {
    background-color: #333;
    color: #fff;
    border-color: #333;
}

.new-footer .footer-secondary {
    border-top: 1px solid #eee;
    padding-top: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.new-footer .payment-methods-new {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.new-footer .payment-methods-new img {
    height: 20px;
    min-width: 32px;
    opacity: 0.7;
    transition: opacity 0.3s;
    flex-shrink: 0;
}

.new-footer .payment-methods-new img:hover {
    opacity: 1;
}

.new-footer .copyright {
    font-size: 13px;
    color: #777;
    text-align: right;
}

@media (max-width: 768px) {
    .new-footer .footer-main {
        flex-direction: column;
        text-align: center;
    }
    .new-footer .social-links-new {
        justify-content: center;
    }
    .new-footer .footer-secondary {
        flex-direction: column;
    }
    .new-footer .copyright {
        text-align: center;
    }
}