/* ==========================================
   Authentication Pages - Master Styles
   認證頁面主模板CSS (登入 + 註冊)
   File: /public/css/layouts/auth-master.css
   Version: 4.0 - Cleanup & Consolidated Variables
   Date: 2025-10-14
   
   職責: 提供認證頁面的基礎結構和共享樣式
   依賴: app.min.css (全局樣式)
   子模板: login.css, register.css (局部樣式)
   
   ⚠️ 重要變更 (v4.0):
   - 整合所有CSS變數到:root (移除.auth-page--login內的重複變數)
   - 統一命名: 使用 --auth-* 前綴 (移除 --login-* 前綴)
   - 子模板CSS現在只需引用 --auth-* 變數
   ========================================== */

/* ========================================
   1. CSS Variables - Consolidated (統一變數)
   ======================================== */
:root {
    /* Auth Colors - 認證主題色彩 */
    --auth-primary: #667eea;
    --auth-primary-dark: #5a67d8;
    --auth-primary-light: #7c8aed;
    --auth-secondary: #764ba2;
    --auth-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Background Colors - 背景色彩 */
    --auth-bg-main: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --auth-bg-card: rgba(255, 255, 255, 0.95);
    --auth-tab-bg: rgba(255, 255, 255, 0.15);
    --auth-tab-hover-bg: rgba(255, 255, 255, 0.25);
    --auth-tab-active-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Text Colors - 文字色彩 */
    --auth-text-primary: #1A202C;
    --auth-text-secondary: #718096;
    --auth-text-muted: #A0AEC0;
    
    /* Border & Divider - 邊框與分隔線 */
    --auth-border: #E2E8F0;
    --auth-divider: #E2E8F0;
    --auth-tab-border: #E2E8F0;
    
    /* Input States - 輸入框狀態 */
    --auth-focus-border: #667eea;
    --auth-focus-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    --auth-error: #F56565;
    --auth-error-bg: #FFF5F5;
    --auth-success: #48BB78;
    --auth-success-bg: #F0FFF4;
    
    /* Spacing - 間距 */
    --auth-space-xs: 4px;
    --auth-space-sm: 8px;
    --auth-space-md: 16px;
    --auth-space-lg: 24px;
    --auth-space-xl: 32px;
    --auth-space-2xl: 40px;
    --auth-space-3xl: 48px;
    --auth-space-4xl: 64px;
    
    /* Typography - 字體 */
    --auth-font-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --auth-font-size-base: 15px;
    --auth-line-height: 1.6;
    
    /* Transitions - 動畫過渡 */
    --auth-transition-fast: 0.2s ease;
    --auth-transition-normal: 0.3s ease;
    --auth-transition-slow: 0.5s ease;
    
    /* Shadows - 陰影 */
    --auth-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --auth-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --auth-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --auth-shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
    --auth-tab-active-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    
    /* Border Radius - 圓角 */
    --auth-radius-sm: 8px;
    --auth-radius-md: 12px;
    --auth-radius-lg: 16px;
    --auth-radius-xl: 20px;
}
    line-height: var(--auth-line-height);
    color: var(--auth-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Reset box-sizing for auth pages */
.auth-page *,
.auth-page *::before,
.auth-page *::after {
    box-sizing: border-box;
}

/* ========================================
   3. Page Container (整個認證頁面容器)
   ======================================== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--auth-space-4xl) var(--auth-space-xl);
    background: var(--auth-bg-main);
    background-attachment: fixed;
}

/* Remove header offset for auth pages */
body.auth-page {
    padding-top: 0;
}

/* ========================================
   4. Container (內容容器)
   ======================================== */
.auth-page__container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

/* ========================================
   5. Card (卡片容器)
   ======================================== */
.auth-page__card {
    background: var(--auth-bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--auth-radius-xl);
    box-shadow: var(--auth-shadow-xl);
    padding: var(--auth-space-2xl);
    width: 100%;
}


/* ========================================
   5.5. Logo & Title (Logo 與標題 - 置中)
   ======================================== */
.auth-page__logo {
    text-align: center;
    margin-bottom: var(--auth-space-2xl);
}

.auth-page__logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--auth-space-lg);
    width: 80px;
    height: 80px;
}

.auth-page__logo-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.auth-page__title {
    font-size: 24px;
    font-weight: 700;
    color: var(--auth-text-primary);
    margin: 0 0 var(--auth-space-sm) 0;
    line-height: 1.3;
}

.auth-page__subtitle {
    font-size: 15px;
    font-weight: 400;
    color: var(--auth-text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* ========================================
   6. Form (表單容器)
   ======================================== */
.auth-page__form {
    width: 100%;
}

/* Ensure all form children are block-level */
.auth-page__form > * {
    display: block;
}

/* ========================================
   7. Form Field (表單欄位容器)
   ======================================== */
.auth-page__field {
    margin-bottom: var(--auth-space-lg);
}

.auth-page__field:last-of-type {
    margin-bottom: var(--auth-space-xl);
}

/* ========================================
   8. Label (標籤)
   ======================================== */
.auth-page__label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--auth-text-primary);
    margin-bottom: var(--auth-space-sm);
}

/* Required field indicator */
.auth-page__label--required::after {
    content: ' *';
    color: var(--auth-error);
    font-weight: 700;
}

/* ========================================
   9. Input Wrapper (輸入框包裝器)
   ======================================== */
.auth-page__input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* ========================================
   10. Input Icon (輸入框圖標)
   ======================================== */
.auth-page__input-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--auth-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}

.auth-page__input-icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* ========================================
   11. Input (輸入框)
   ======================================== */
.auth-page__input {
    width: 100%;
    padding: 14px 15px 14px 48px;
    font-size: 15px;
    font-family: inherit;
    color: var(--auth-text-primary);
    background: #FFFFFF;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-md);
    transition: all var(--auth-transition-fast);
    outline: none;
}

.auth-page__input::placeholder {
    color: var(--auth-text-muted);
}

.auth-page__input:hover {
    border-color: var(--auth-primary-light);
}

.auth-page__input:focus {
    border-color: var(--auth-focus-border);
    box-shadow: var(--auth-focus-shadow);
}

/* Input Error State */
.auth-page__input--error {
    border-color: var(--auth-error);
    background: #FFF5F5;
}

.auth-page__input--error:focus {
    box-shadow: 0 0 0 3px rgba(245, 101, 101, 0.1);
}

/* Input Success State */
.auth-page__input--valid {
    border-color: var(--auth-success);
    background: #F0FFF4;
}

/* ========================================
   12. Toggle Password Button
   ======================================== */
.auth-page__toggle-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--auth-text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--auth-transition-fast);
    z-index: 2;
}

.auth-page__toggle-password:hover {
    color: var(--auth-primary);
}

.auth-page__toggle-password:focus {
    outline: 2px solid var(--auth-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.auth-page__toggle-password-icon {
    width: 20px;
    height: 20px;
}

/* Adjust input padding when toggle button exists */
.auth-page__input-wrapper:has(.auth-page__toggle-password) .auth-page__input {
    padding-right: 48px;
}

/* ========================================
   13. Background Override for Auth Pages
   ======================================== */

/* Remove white background from main-content */
body.auth-page .main-content {
    background: transparent;
    padding: 0;
    min-height: 100vh;
}

/* Content wrapper for both login and register */
.auth-content-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

/* ========================================
   14. Responsive Design
   ======================================== */

/* Tablet (≤768px) */
@media (max-width: 768px) {
    .auth-page {
        padding: var(--auth-space-xl) var(--auth-space-md);
    }
    
    .auth-page__container {
        max-width: 100%;
    }
    
    .auth-page__card {
        padding: var(--auth-space-xl);
    }
}

/* Mobile (≤640px) */
@media (max-width: 640px) {
    .auth-page {
        padding: var(--auth-space-lg) var(--auth-space-md);
    }
    
    .auth-page__card {
        padding: var(--auth-space-lg);
        border-radius: var(--auth-radius-lg);
    }
    
    .auth-page__input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .auth-content-wrapper {
        padding: 1rem;
    }
}

/* Small Mobile (≤480px) */
@media (max-width: 480px) {
    .auth-page {
        padding: var(--auth-space-md);
    }
    
    .auth-page__card {
        padding: var(--auth-space-md);
    }
}

/* ========================================
   15. Force Transparent Background (Fix)
   ======================================== */
body.auth-page,
body.auth-page--login,
body.auth-page--register {
    background: var(--auth-bg-main);
    background-attachment: fixed;
}

body.auth-page .main-content,
body.auth-page--login .main-content,
body.auth-page--register .main-content {
    background: transparent;
    padding: 0;
    min-height: 100vh;
}

/* Ensure content containers are transparent */
.auth-page,
.auth-content-wrapper {
    background: transparent;
}

/* ========================================
/* ========================================
   12. Input Action Button (密碼顯示/隱藏按鈕)
   ======================================== */
.auth-page__input-action {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--auth-text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--auth-transition-fast);
    z-index: 2;
    line-height: 1;
}

.auth-page__input-action:hover {
    color: var(--auth-primary);
}

.auth-page__input-action:focus {
    outline: 2px solid var(--auth-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.auth-page__input-action svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Adjust input padding when action button exists */
.auth-page__input-wrapper:has(.auth-page__input-action) .auth-page__input {
    padding-right: 48px;
}

/* ========================================
   13. Buttons (按鈕基礎樣式)
   ======================================== */

/* Base Button Style */
.auth-page__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--auth-space-sm);
    padding: 14px var(--auth-space-lg);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--auth-font-base);
    text-decoration: none;
    border-radius: var(--auth-radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--auth-transition-normal);
    white-space: nowrap;
    user-select: none;
    position: relative;
    overflow: hidden;
    line-height: 1.5;
}

.auth-page__button:focus-visible {
    outline: 2px solid var(--auth-primary);
    outline-offset: 2px;
}

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

/* Primary Button */
.auth-page__button--primary {
    background: var(--auth-gradient);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
}

.auth-page__button--primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.auth-page__button--primary:active:not(:disabled) {
    transform: translateY(0);
}

/* Outline Button */
.auth-page__button--outline {
    background: transparent;
    color: var(--auth-primary);
    border: 2px solid var(--auth-primary);
}

.auth-page__button--outline:hover:not(:disabled) {
    background: var(--auth-primary);
    color: #FFFFFF;
}

/* Social Button */
.auth-page__button--social {
    background: #FFFFFF;
    color: var(--auth-text-primary);
    border: 1px solid var(--auth-border);
    box-shadow: var(--auth-shadow-sm);
}

.auth-page__button--social:hover:not(:disabled) {
    background: #F7FAFC;
    border-color: var(--auth-border);
    box-shadow: var(--auth-shadow-md);
}

/* Google Button */
.auth-page__button--google {
    background: #FFFFFF;
    color: var(--auth-text-primary);
    border: 1px solid var(--auth-border);
    font-weight: 500;
}

.auth-page__button--google:hover:not(:disabled) {
    background: #F7FAFC;
    box-shadow: var(--auth-shadow-md);
    transform: translateY(-1px);
}

.auth-page__button--google svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Full Width Button */
.auth-page__button--full {
    width: 100%;
}

/* Send Code Button (30% width in input group) */
.auth-page__button--send-code {
    flex: 0 0 30%;
    padding: 14px 12px;
    font-size: 14px;
    white-space: nowrap;
}

/* Loading State */
.auth-page__button--loading {
    pointer-events: none;
    opacity: 0.8;
}

/* Spinner Animation */
.auth-page__spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

/* ========================================
   14. Form Options & Elements (表單選項)
   ======================================== */

/* Remember Me & Forgot Password Container */
.auth-page__options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--auth-space-xl);
}

/* Checkbox Wrapper */
.auth-page__checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: var(--auth-space-sm);
}

/* Checkbox Input */
.auth-page__checkbox-input {
    width: 18px;
    height: 18px;
    border: 2px solid var(--auth-border);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--auth-transition-fast);
}

.auth-page__checkbox-input:checked {
    background: var(--auth-primary);
    border-color: var(--auth-primary);
}

.auth-page__checkbox-input:focus {
    outline: 2px solid var(--auth-primary);
    outline-offset: 2px;
}

/* Checkbox Label */
.auth-page__checkbox-label {
    font-size: 14px;
    color: var(--auth-text-primary);
    cursor: pointer;
    user-select: none;
}

/* Link Styles */
.auth-page__link {
    color: var(--auth-primary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: color var(--auth-transition-fast);
}

.auth-page__link:hover {
    color: var(--auth-primary-dark);
    text-decoration: underline;
}

.auth-page__link--primary {
    color: var(--auth-primary);
    font-weight: 600;
}

/* Error Message */
.auth-page__error {
    display: block;
    color: var(--auth-error);
    font-size: 13px;
    margin-top: var(--auth-space-sm);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hint Message */
.auth-page__hint {
    display: block;
    color: var(--auth-text-muted);
    font-size: 13px;
    margin-top: var(--auth-space-sm);
}

/* ========================================
   15. Input Group (輸入框組合 - Email + Send Code)
   ======================================== */

/* Input Group Container (70% + 30% layout) */
.auth-page__input-group {
    display: flex;
    gap: var(--auth-space-sm);
    align-items: flex-start;
}

/* Input Wrapper with Flex (70% width) */
.auth-page__input-wrapper--flex {
    flex: 1 1 70%;
}

/* ========================================
   16. Divider (分隔線)
   ======================================== */

.auth-page__divider {
    position: relative;
    text-align: center;
    margin: var(--auth-space-xl) 0;
}

.auth-page__divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: var(--auth-divider);
}

.auth-page__divider-text {
    position: relative;
    display: inline-block;
    padding: 0 var(--auth-space-md);
    background: var(--auth-bg-card);
    color: var(--auth-text-muted);
    font-size: 14px;
    font-weight: 500;
}

/* ========================================
   17. Social Login & Footer (社交登入與頁腳)
   ======================================== */

/* Social Login Container */
.auth-page__social {
    margin-bottom: var(--auth-space-lg);
}

/* Footer */
.auth-page__footer {
    text-align: center;
    margin-top: var(--auth-space-lg);
}

.auth-page__footer-text {
    font-size: 14px;
    color: var(--auth-text-secondary);
    margin: 0;
}

   16. Accessibility Enhancements
   ======================================== */

/* Focus Visible */
.auth-page__input:focus-visible {
    outline: 2px solid var(--auth-primary);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .auth-page__input {
        border-width: 2px;
    }
    
    .auth-page__input:focus {
        outline: 3px solid currentColor;
        outline-offset: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms;
        animation-iteration-count: 1;
        transition-duration: 0.01ms;
    }
}

/* ========================================
   17. Print Styles
   ======================================== */
@media print {
    .auth-page {
        background: white;
    }
    
    .auth-page__card {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* ========================================
   Language Switcher Styles
   ======================================== */

/* Language Button Fixed Position */
    .language-dropdown__item {
        padding: 10px 14px;
    }

    .language-dropdown__item .name {
        font-size: 13px;
    }
}

/* Language Switcher - 使用統一組件 */
/* @import url('../components/language-switcher.css'); */
