/* 全域樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', 'Microsoft JhengHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    margin: 0;
    padding: 0;
    -webkit-overflow-scrolling: touch;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 登入狀態列樣式 */
.auth-container {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 20px;
    text-align: center;
}

.login-section p {
    color: white;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.user-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
}

#userName {
    font-size: 1.1rem;
    font-weight: 600;
}

/* 登出按鈕專用樣式 */
#logoutBtn {
    flex: none !important;
    min-width: auto;
    padding: 8px 16px;
    font-size: 14px;
    white-space: nowrap;
}

/* 登入按鈕專用樣式 */
#loginBtn {
    flex: none !important;
    min-width: auto;
    padding: 12px 24px;
    font-size: 16px;
    white-space: nowrap;
}

/* 頭部樣式 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

h1 {
    color: white;
    font-size: 2rem;
    font-weight: 700;
}

.add-wallet-btn {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
    flex: none;
    min-width: auto;
    white-space: nowrap;
}

.add-wallet-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.6);
}

/* 錢包容器 */
.wallets-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* 錢包卡片樣式 */
.wallet-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.wallet-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

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

.wallet-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.edit-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.edit-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.wallet-amount {
    font-size: 2.5rem;
    font-weight: 800;
    color: #2196F3;
    margin-bottom: 10px;
    text-align: center;
}

.wallet-goal {
    background: linear-gradient(45deg, #FF9800, #FF5722);
    color: white;
    padding: 10px 15px;
    border-radius: 25px;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
}

.goal-progress {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.goal-remaining {
    font-size: 0.9rem;
    opacity: 0.9;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.wallet-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 44px; /* iOS 最小觸控目標 */
    min-width: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
}

.btn-success {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
}

.btn-success:hover, .btn-success:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

.btn-danger {
    background: linear-gradient(45deg, #f44336, #da190b);
    color: white;
}

.btn-danger:hover, .btn-danger:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(244, 67, 54, 0.3);
}

.btn-primary {
    background: linear-gradient(45deg, #2196F3, #0b7dda);
    color: white;
}

.btn-primary:hover, .btn-primary:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.3);
}

.btn-secondary {
    background: linear-gradient(45deg, #6c757d, #5a6268);
    color: white;
}

.btn-secondary:hover, .btn-secondary:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* 彈出視窗樣式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-footer .btn {
    flex: none;
    min-width: 80px;
    padding: 10px 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    font-size: 16px; /* 避免 iOS 縮放 */
    transition: border-color 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-group small {
    color: #666;
    font-size: 0.9rem;
    margin-top: 5px;
    display: block;
}

/* 空狀態樣式 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.8);
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 1.1rem;
    opacity: 0.8;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
    }
    
    .wallets-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .btn {
        font-size: 16px;
        padding: 12px;
    }
    
    /* 手機版按鈕優化 */
    #logoutBtn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    #loginBtn {
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .add-wallet-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .transaction-item {
        padding: 12px;
        border-radius: 8px;
    }
    
    .transaction-amount {
        font-size: 16px;
    }
    
    .transaction-date {
        font-size: 12px;
    }
}

/* PWA 安裝按鈕樣式 */
.install-button {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin: 10px auto;
    display: block;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.install-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #20c997, #28a745);
}

/* PWA 顯示調整 */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .container {
        margin-top: 0;
    }
}

/* iOS PWA 狀態欄調整 */
@supports (-webkit-touch-callout: none) {
    @media (display-mode: standalone) {
        body {
            padding-top: 44px; /* iOS 狀態欄高度 */
        }
    }
}

/* 交易紀錄相關樣式 */
.transaction-summary {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.summary-item {
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.summary-value {
    display: block;
    font-size: 1.2rem;
    font-weight: bold;
}

.summary-value.positive {
    color: #28a745;
}

.summary-value.negative {
    color: #dc3545;
}

.transaction-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.filter-btn.active,
.filter-btn:hover {
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
    border-color: #007bff;
}

.transaction-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fafafa;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.transaction-item:hover {
    background-color: #f8f9fa;
}

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

.transaction-item.deposit {
    border-left: 4px solid #28a745;
}

.transaction-item.withdrawal {
    border-left: 4px solid #dc3545;
}

.transaction-info {
    flex: 1;
}

.transaction-type {
    font-weight: bold;
    margin-bottom: 2px;
}

.transaction-type.deposit {
    color: #28a745;
}

.transaction-type.withdrawal {
    color: #dc3545;
}

.transaction-note {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 2px;
}

.transaction-date {
    font-size: 0.8rem;
    color: #999;
}

.transaction-amount {
    font-weight: bold;
    font-size: 1.1rem;
    text-align: right;
}

.transaction-amount.positive {
    color: #28a745;
}

.transaction-amount.negative {
    color: #dc3545;
}

.transaction-balance {
    font-size: 0.8rem;
    color: #666;
    text-align: right;
    margin-top: 2px;
}

.empty-transactions {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-transactions h4 {
    margin-bottom: 10px;
    color: #999;
}

/* 三個按鈕的錢包動作列 */
.wallet-actions-extended {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-top: 20px;
}

.wallet-actions-extended .btn {
    flex: none;
    padding: 8px 12px;
    font-size: 14px;
    text-align: center;
}

.btn-info {
    background: linear-gradient(45deg, #17a2b8, #138496);
    color: white;
}

/* PWA 安裝按鈕樣式 */
.install-button {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin: 10px auto;
    display: block;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.install-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #20c997, #28a745);
}

/* PWA 顯示調整 */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .container {
        margin-top: 0;
    }
}

/* iOS PWA 狀態欄調整 */
@supports (-webkit-touch-callout: none) {
    @media (display-mode: standalone) {
        body {
            padding-top: 44px; /* iOS 狀態欄高度 */
        }
    }
}
