/* auth.css - 認證相關樣式 */

/* 登入模態框 */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.auth-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.auth-modal .modal-content {
    position: relative;
    background: var(--card-background, #ffffff);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.auth-modal .modal-header h2 {
    color: var(--text-primary, #333);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.auth-modal .modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary, #666);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.auth-modal .modal-close:hover {
    background: var(--background-secondary, #f5f5f5);
    color: var(--text-primary, #333);
}

.auth-modal .modal-body {
    padding: 1.5rem;
}

/* 表單樣式 */
#login-form .form-group,
#register-form .form-group {
    margin-bottom: 1.25rem;
}

#login-form label,
#register-form label {
    display: block;
    color: var(--text-secondary, #666);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

#login-form input[type="text"],
#login-form input[type="email"],
#login-form input[type="password"],
#register-form input[type="text"],
#register-form input[type="email"],
#register-form input[type="password"] {
    width: 100%;
    padding: 0.875rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    background: var(--input-background, #ffffff);
    color: var(--text-primary, #333);
    font-size: 1rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

#login-form input[type="text"]:focus,
#login-form input[type="email"]:focus,
#login-form input[type="password"]:focus,
#register-form input[type="text"]:focus,
#register-form input[type="email"]:focus,
#register-form input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color, #4A90E2);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary, #666);
}

.checkbox-label input[type="checkbox"] {
    margin-right: 0.5rem;
    transform: scale(1.1);
}

.forgot-password {
    color: var(--primary-color, #4A90E2);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.forgot-password:hover {
    color: var(--primary-dark, #357ABD);
    text-decoration: underline;
}

.login-submit-btn,
.register-submit-btn {
    width: 100%;
    padding: 0.875rem;
    background: var(--primary-color, #4A90E2);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1.5rem;
}

.login-submit-btn:hover:not(:disabled),
.register-submit-btn:hover:not(:disabled) {
    background: var(--primary-dark, #357ABD);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.login-submit-btn:disabled,
.register-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 分隔線 */
.auth-divider {
    position: relative;
    text-align: center;
    margin: 1.5rem 0;
}

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

.auth-divider span {
    background: var(--card-background, #ffffff);
    color: var(--text-secondary, #666);
    padding: 0 1rem;
    font-size: 0.9rem;
}

/* 社交登入按鈕 */
.social-login {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.875rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    background: var(--card-background, #ffffff);
    color: var(--text-primary, #333);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.social-btn:hover {
    background: var(--background-secondary, #f5f5f5);
    border-color: var(--primary-color, #4A90E2);
    transform: translateY(-1px);
}

.social-icon {
    font-size: 1.2rem;
}

.google-btn:hover {
    border-color: #4285f4;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.2);
}

.facebook-btn:hover {
    border-color: #1877f2;
    box-shadow: 0 2px 8px rgba(24, 119, 242, 0.2);
}

/* 頁腳 */
.auth-footer {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

.auth-footer p {
    color: var(--text-secondary, #666);
    font-size: 0.9rem;
    margin: 0;
}

.auth-footer a {
    color: var(--primary-color, #4A90E2);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* 消息提示 */
.auth-message {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1001;
    animation: messageSlideIn 0.3s ease;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.auth-message.success {
    background: #10B981;
}

.auth-message.error {
    background: #EF4444;
}

.auth-message.info {
    background: #3B82F6;
}

/* 用戶資料顯示 */
.user-profile {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0;
    background: transparent;
}

.profile-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    background: var(--surface-color, #fff);
    color: var(--text-primary, #333);
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-toggle:hover,
.profile-toggle[aria-expanded="true"] {
    background: var(--background-color, #f5f5f5);
    border-color: var(--primary-color, #4A90E2);
}

.user-profile img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--background-color, #f5f5f5);
    border: 1px solid var(--border-color, #e0e0e0);
}

.profile-toggle .username { color:var(--text-primary, #333); }

.account-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    display: none;
    min-width: 150px;
    padding: 0.5rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    background: var(--surface-color, #fff);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.user-profile.menu-open .account-menu {
    display: grid;
    gap: 0.35rem;
}

.username {
    color: var(--text-primary, #333);
    font-weight: 500;
    font-size: 0.9rem;
}

.account-link {
    color: var(--primary-color, #4A90E2);
    display: block;
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
}

.account-link:hover {
    background: var(--background-color, #f5f7fb);
    text-decoration: none;
}

.demo-hint {
    margin-top: 0.5rem !important;
    color: var(--text-secondary, #666);
    font-size: 0.8rem !important;
}

.terms-checkbox {
    margin-bottom: 1.25rem;
}

#logout-btn {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border-color, #e0e0e0);
    color: var(--text-secondary, #666);
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

#logout-btn:hover {
    background: var(--danger-color, #EF4444);
    border-color: var(--danger-color, #EF4444);
    color: white;
}

/* 響應式設計 */
@media (max-width: 480px) {
    .auth-modal .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .auth-modal .modal-header,
    .auth-modal .modal-body {
        padding: 1rem;
    }
    
    .auth-message {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
    
    .social-login {
        gap: 0.5rem;
    }
    
    .form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* 深色主題支援 */
@media (prefers-color-scheme: dark) {
    .auth-modal .modal-content {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .auth-modal .modal-header h2 {
        color: #f9fafb;
    }
    
    .auth-modal .modal-close {
        color: #9ca3af;
    }
    
    .auth-modal .modal-close:hover {
        background: #374151;
        color: #f9fafb;
    }
    
    #login-form input[type="text"],
    #login-form input[type="email"],
    #login-form input[type="password"],
    #register-form input[type="text"],
    #register-form input[type="email"],
    #register-form input[type="password"] {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .social-btn {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .social-btn:hover {
        background: #4b5563;
    }
    
    .auth-divider span {
        background: #1f2937;
        color: #9ca3af;
    }
}

