/* 邀請頁面樣式 */

/* === CSS 變數（支援淺色/深色模式） === */
:root {
    --invite-bg-primary: #1a1a2e;
    --invite-bg-secondary: #16213e;
    --invite-bg-tertiary: #0f3460;
    --invite-card-bg: rgba(47, 49, 54, 0.95);
    --invite-card-bg-alt: rgba(32, 34, 37, 0.95);
    --invite-text-primary: #ffffff;
    --invite-text-secondary: #b9bbbe;
    --invite-text-muted: #72767d;
    --invite-accent: #5865F2;
    --invite-accent-light: #7289DA;
    --invite-success: #3ba55c;
    --invite-error: #ed4245;
    --invite-border: rgba(255, 255, 255, 0.05);
    --invite-input-bg: rgba(0, 0, 0, 0.3);
}

/* 淺色模式 */
.invite-page.light-mode {
    --invite-bg-primary: #f5f5f5;
    --invite-bg-secondary: #e8e8e8;
    --invite-bg-tertiary: #d0d0d0;
    --invite-card-bg: rgba(255, 255, 255, 0.95);
    --invite-card-bg-alt: rgba(245, 245, 245, 0.95);
    --invite-text-primary: #1a1a1a;
    --invite-text-secondary: #4a4a4a;
    --invite-text-muted: #6a6a6a;
    --invite-border: rgba(0, 0, 0, 0.1);
    --invite-input-bg: rgba(0, 0, 0, 0.05);
}

/* === 主題切換按鈕 === */
.theme-toggle {
    position: absolute;
    top: -0.5rem;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--invite-card-bg);
    border: 1px solid var(--invite-border);
    color: var(--invite-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s ease;
    z-index: 10;
}

.theme-toggle:hover {
    background: var(--invite-accent);
    color: white;
    transform: rotate(180deg);
}

.theme-toggle:focus {
    outline: 2px solid var(--invite-accent);
    outline-offset: 2px;
}

/* === 頁面基礎樣式 === */
.invite-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    position: relative;
    overflow: hidden;
    transition: background 0.3s ease;
}

/* === 背景效果 === */
.invite-background {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    overflow: hidden;
}

.bg-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, 
        var(--invite-bg-primary) 0%, 
        var(--invite-bg-secondary) 25%, 
        var(--invite-bg-tertiary) 50%, 
        var(--invite-bg-primary) 75%, 
        #0d1117 100%
    );
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    transition: background 0.3s ease;
}

/* 淺色模式背景 */
.invite-page.light-mode .bg-gradient {
    background: linear-gradient(135deg, 
        #f0f4ff 0%, 
        #e8eeff 25%, 
        #dde6ff 50%, 
        #f0f4ff 75%, 
        #f5f7fa 100%
    );
    background-size: 400% 400%;
}

.invite-page.light-mode .bg-particles {
    background-image: radial-gradient(circle, rgba(88, 101, 242, 0.15) 1px, transparent 1px);
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.bg-particles {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(88, 101, 242, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: particleFloat 20s linear infinite;
}

@keyframes particleFloat {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50px); }
}

/* === 容器 === */
.invite-container {
    max-width: 480px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
}

/* === 伺服器卡片 === */
.server-card {
    background: linear-gradient(145deg, var(--invite-card-bg), var(--invite-card-bg-alt));
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid var(--invite-border);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.invite-page.light-mode .server-card {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.server-banner {
    height: 100px;
    background: linear-gradient(135deg, #5865F2 0%, #7289DA 50%, #99AAB5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.server-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid rgba(32, 34, 37, 0.95);
    position: absolute;
    bottom: -40px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    object-fit: cover;
}

.server-icon-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid rgba(32, 34, 37, 0.95);
    position: absolute;
    bottom: -40px;
    background: #5865F2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.server-info {
    padding: 3rem 1.5rem 1.5rem;
    text-align: center;
}

.server-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--invite-text-primary);
    margin: 0 0 0.5rem 0;
}

.server-description {
    color: var(--invite-text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 1rem 0;
}

.server-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--invite-text-secondary);
    font-size: 0.85rem;
}

.stat-item i {
    color: var(--invite-accent);
}

.stat-value {
    font-weight: 600;
    color: var(--invite-text-primary);
}

.online-dot {
    width: 8px;
    height: 8px;
    background: #3ba55c;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.95); }
}

.server-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.feature-badge {
    background: rgba(88, 101, 242, 0.15);
    color: #8b9dff;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.feature-badge i {
    font-size: 0.7rem;
}

/* === 邀請產生區塊 === */
.invite-generator {
    background: var(--invite-card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid var(--invite-border);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.invite-page.light-mode .invite-generator {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--invite-text-primary);
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title i {
    color: var(--invite-accent);
}

.invite-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-group label {
    color: var(--invite-text-secondary);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.option-group label i {
    color: var(--invite-accent);
    font-size: 0.75rem;
}

.invite-select {
    background: var(--invite-input-bg);
    border: 1px solid var(--invite-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--invite-text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.invite-select:hover {
    border-color: rgba(88, 101, 242, 0.5);
}

.invite-select:focus {
    outline: none;
    border-color: #5865F2;
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2);
}

.btn-generate {
    width: 100%;
    background: linear-gradient(135deg, #5865F2 0%, #7289DA 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(88, 101, 242, 0.4);
}

.btn-generate:active {
    transform: translateY(0);
}

.btn-generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* === 邀請結果 === */
.invite-result {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #3ba55c;
    font-weight: 600;
    margin-bottom: 1rem;
}

.result-header i {
    font-size: 1.2rem;
}

.invite-link-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.invite-link-input {
    flex: 1;
    background: var(--invite-input-bg);
    border: 1px solid var(--invite-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--invite-text-primary);
    font-family: monospace;
    font-size: 0.85rem;
}

.btn-copy {
    background: rgba(88, 101, 242, 0.2);
    border: 1px solid rgba(88, 101, 242, 0.3);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--invite-accent);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-copy:hover {
    background: rgba(88, 101, 242, 0.3);
}

.btn-copy.copied {
    background: rgba(59, 165, 92, 0.2);
    border-color: rgba(59, 165, 92, 0.3);
    color: #3ba55c;
}

.invite-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--invite-text-secondary);
    font-size: 0.8rem;
}

.meta-item i {
    color: var(--invite-accent);
    font-size: 0.75rem;
}

.invite-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-action {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-discord {
    background: var(--invite-accent);
    color: #fff;
    border: none;
}

.btn-discord:hover {
    background: #4752C4;
    color: #fff;
}

.btn-share {
    background: transparent;
    color: var(--invite-text-secondary);
    border: 1px solid var(--invite-border);
}

.btn-share:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--invite-text-primary);
}

/* === QR Code 區塊 === */
.qr-code-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--invite-border);
}

.btn-qr-toggle {
    width: 100%;
    background: transparent;
    border: 1px dashed var(--invite-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--invite-text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-qr-toggle:hover {
    background: rgba(88, 101, 242, 0.1);
    border-color: var(--invite-accent);
    color: var(--invite-accent);
}

.btn-qr-toggle[aria-expanded="true"] {
    background: rgba(88, 101, 242, 0.1);
    border-style: solid;
    border-color: var(--invite-accent);
    color: var(--invite-accent);
}

.qr-container {
    margin-top: 1rem;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.qr-container canvas {
    background: white;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.qr-hint {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--invite-text-muted);
}

/* === 載入中 === */
.invite-loading {
    text-align: center;
    padding: 2rem;
    color: var(--invite-text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(88, 101, 242, 0.2);
    border-top-color: var(--invite-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === 錯誤訊息 === */
.invite-error {
    text-align: center;
    padding: 1.5rem;
    color: #ed4245;
    background: rgba(237, 66, 69, 0.1);
    border-radius: 8px;
    margin-top: 1rem;
}

.invite-error i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

.btn-retry {
    margin-top: 1rem;
    background: transparent;
    border: 1px solid #ed4245;
    color: #ed4245;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-retry:hover {
    background: rgba(237, 66, 69, 0.1);
}

/* === 功能亮點 === */
.features-highlight {
    background: var(--invite-card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid var(--invite-border);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.invite-page.light-mode .features-highlight {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.features-highlight h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--invite-text-primary);
    margin: 0 0 1rem 0;
    text-align: center;
}

.highlight-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.highlight-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--invite-input-bg);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.highlight-item:hover {
    background: rgba(88, 101, 242, 0.15);
    transform: translateY(-2px);
}

.highlight-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(88, 101, 242, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--invite-accent);
    font-size: 1rem;
}

.highlight-item span {
    color: var(--invite-text-secondary);
    font-size: 0.75rem;
    text-align: center;
}

/* === 備用連結 === */
.fallback-section {
    text-align: center;
    padding: 1rem;
}

.fallback-section p {
    color: var(--invite-text-muted);
    font-size: 0.8rem;
    margin: 0 0 0.5rem 0;
}

.fallback-link {
    color: var(--invite-accent);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.fallback-link:hover {
    color: var(--invite-accent-light);
    text-decoration: underline;
}

/* === 分享對話框 === */
.share-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--invite-card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--invite-text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--invite-text-primary);
}

.modal-content h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--invite-text-primary);
}

.share-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.share-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
}

.share-option:nth-child(1) {
    background: #1DA1F2;
    color: #fff;
}

.share-option:nth-child(2) {
    background: #4267B2;
    color: #fff;
}

.share-option:nth-child(3) {
    background: #00B900;
    color: #fff;
}

.share-option:nth-child(4) {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.share-option:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* === Toast 通知 === */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--invite-card-bg);
    color: var(--invite-text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: toastIn 0.3s ease;
}

.toast.success {
    border-left: 3px solid var(--invite-success);
}

.toast.error {
    border-left: 3px solid var(--invite-error);
}

.toast.info {
    border-left: 3px solid var(--invite-accent);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast.hide {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* === Focus 狀態樣式（無障礙支援）=== */
.btn-generate:focus,
.btn-copy:focus,
.btn-action:focus,
.btn-retry:focus,
.btn-qr-toggle:focus,
.share-option:focus,
.modal-close:focus,
.theme-toggle:focus {
    outline: 2px solid var(--invite-accent);
    outline-offset: 2px;
}

.btn-generate:focus:not(:focus-visible),
.btn-copy:focus:not(:focus-visible),
.btn-action:focus:not(:focus-visible),
.btn-retry:focus:not(:focus-visible),
.btn-qr-toggle:focus:not(:focus-visible),
.share-option:focus:not(:focus-visible),
.modal-close:focus:not(:focus-visible),
.theme-toggle:focus:not(:focus-visible) {
    outline: none;
}

/* === 降低動畫偏好 === */
@media (prefers-reduced-motion: reduce) {
    .bg-gradient {
        animation: none;
    }
    .bg-particles {
        animation: none;
    }
    .online-dot {
        animation: none;
    }
    .loading-spinner {
        animation: spin 2s linear infinite;
    }
    .highlight-item:hover {
        transform: none;
    }
    .btn-generate:hover {
        transform: none;
    }
    .share-option:hover {
        transform: none;
    }
    .toast {
        animation: none;
        opacity: 1;
    }
    .toast.hide {
        animation: none;
        opacity: 0;
    }
}

/* === 響應式設計 === */
@media (max-width: 480px) {
    .invite-page {
        padding: 1rem 0.75rem;
    }
    
    .server-info {
        padding: 2.5rem 1rem 1rem;
    }
    
    .server-name {
        font-size: 1.25rem;
    }
    
    .invite-options {
        grid-template-columns: 1fr;
    }
    
    .highlight-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .invite-actions {
        flex-direction: column;
    }
}

/* === 平板響應式設計 === */
@media (min-width: 481px) and (max-width: 768px) {
    .invite-container {
        max-width: 520px;
    }
    
    .server-name {
        font-size: 1.4rem;
    }
    
    .highlight-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
    
    .highlight-icon {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
}

/* === 大螢幕優化 === */
@media (min-width: 769px) {
    .invite-page {
        padding: 3rem 2rem;
    }
    
    .invite-container {
        max-width: 520px;
    }
    
    .server-banner {
        height: 120px;
    }
    
    .server-icon,
    .server-icon-placeholder {
        width: 90px;
        height: 90px;
        bottom: -45px;
    }
    
    .server-info {
        padding: 3.5rem 2rem 1.5rem;
    }
    
    .highlight-icon {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }
    
    .highlight-item span {
        font-size: 0.8rem;
    }
}

/* === 高對比模式 === */
@media (prefers-contrast: high) {
    .server-card,
    .invite-generator,
    .features-highlight {
        border: 2px solid rgba(255, 255, 255, 0.3);
    }
    
    .btn-generate {
        border: 2px solid #fff;
    }
    
    .feature-badge {
        border: 1px solid currentColor;
    }
}
