/**
 * FUN乐园 - 预测页面增强样式
 * 提供完整的视觉设计和交互效果
 * 创建日期：2026年4月16日
 */

/* CSS變數定義 */
:root {
    --fun-primary: #4f85ac;
    --fun-secondary: #78b3db;
    --fun-accent: #6298c0;
    --fun-accent-2: #5a8bb5;
    --fun-background: #f8fafc;
    --fun-surface: #ffffff;
    --fun-surface-2: #f1f5f9;
    --fun-panel: #ffffff;
    --fun-panel-2: #f8fafc;
    --fun-text: #1e293b;
    --fun-text-muted: #64748b;
    --fun-border: #e2e8f0;
    --fun-button: #4f85ac;
    --fun-button-hover: #3d6b94;
    --fun-success: #10b981;
    --fun-warning: #f59e0b;
    --fun-error: #ef4444;
    --fun-radius: 12px;
    --fun-radius-small: 8px;
    --fun-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --fun-shadow-soft: 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --fun-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 基礎重置與佈局 */
* {
    box-sizing: border-box;
}

body {
    background-color: var(--fun-background);
    color: var(--fun-text);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* 選擇框樣式（用於48個國家選擇，最多選16個） */
.fun-choice-grid, .wpforms-image-choices {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
    padding: 1rem;
    background-color: var(--fun-surface);
    border-radius: var(--fun-radius);
    border: 1px solid var(--fun-border);
}

.fun-choice-item, .wpforms-image-choices-item {
    background-color: var(--fun-panel);
    border: 2px solid var(--fun-border);
    border-radius: var(--fun-radius-small);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--fun-transition);
    position: relative;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.fun-choice-item:hover, .wpforms-image-choices-item:hover {
    background-color: var(--fun-surface-2);
    border-color: var(--fun-accent);
    transform: translateY(-2px);
    box-shadow: var(--fun-shadow-soft);
}

.fun-choice-item.selected, 
.wpforms-image-choices-item input[type="checkbox"]:checked + .wpforms-image-choices-label::before {
    background-color: var(--fun-button);
    border-color: var(--fun-accent-2);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(98, 152, 192, 0.3);
}

.fun-choice-item img, .wpforms-image-choices-image img {
    max-width: 60px;
    max-height: 40px;
    height: auto;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    object-fit: contain;
}

.fun-choice-item span, .wpforms-image-choices-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--fun-text);
    line-height: 1.2;
}

/* WPForms 樣式覆蓋 */
.wpforms-container {
    background-color: var(--fun-surface) !important;
    border-radius: var(--fun-radius) !important;
    padding: 2rem !important;
    border: 1px solid var(--fun-border) !important;
    box-shadow: var(--fun-shadow) !important;
}

.wpforms-field-label {
    color: var(--fun-accent-2) !important;
    font-weight: 600 !important;
    margin-bottom: 0.75rem !important;
    font-size: 1.1rem !important;
}

.wpforms-field input[type="text"], 
.wpforms-field input[type="tel"], 
.wpforms-field input[type="email"],
.wpforms-field textarea {
    background-color: var(--fun-panel) !important;
    border: 1px solid var(--fun-border) !important;
    border-radius: var(--fun-radius-small) !important;
    color: var(--fun-text) !important;
    padding: 0.75rem !important;
    font-size: 1rem !important;
    transition: var(--fun-transition) !important;
    width: 100% !important;
}

.wpforms-field input[type="text"]:focus, 
.wpforms-field input[type="tel"]:focus,
.wpforms-field input[type="email"]:focus,
.wpforms-field textarea:focus {
    border-color: var(--fun-accent) !important;
    box-shadow: 0 0 0 3px rgba(120, 179, 219, 0.15) !important;
    outline: none !important;
}

.wpforms-submit {
    background-color: var(--fun-button) !important;
    color: #ffffff !important;
    border: none !important;
    padding: 1rem 2rem !important;
    border-radius: var(--fun-radius) !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: var(--fun-transition) !important;
    box-shadow: 0 6px 20px rgba(98, 152, 192, 0.3) !important;
    width: auto !important;
    min-width: 200px !important;
}

.wpforms-submit:hover:not(:disabled) {
    background-color: var(--fun-button-hover) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(79, 133, 172, 0.4) !important;
}

.wpforms-submit:disabled {
    background-color: #6c757d !important;
    cursor: not-allowed !important;
    transform: none !important;
    opacity: 0.6 !important;
}

.wpforms-field-description {
    color: var(--fun-text-muted) !important;
    font-size: 0.9rem !important;
    margin-top: 0.5rem !important;
    font-style: italic !important;
}

/* 隱藏原始checkbox，使用自定義樣式 */
.wpforms-screen-reader-element {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* 自定義選擇框選中樣式 */
.wpforms-image-choices-item {
    position: relative;
}

.wpforms-image-choices-item input[type="checkbox"]:checked + * {
    background-color: var(--fun-button);
    color: #ffffff;
}

.wpforms-image-choices-item::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: transparent;
    border: 2px solid var(--fun-border);
    transition: var(--fun-transition);
}

.wpforms-image-choices-item:has(input:checked)::after {
    background-color: var(--fun-accent-2);
    border-color: var(--fun-accent-2);
}

.wpforms-image-choices-item:has(input:checked)::before {
    content: '✓';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 12px;
    height: 12px;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    z-index: 1;
}

/* 通知系統 */
.fun-notification {
    padding: 1rem 1.5rem;
    border-radius: var(--fun-radius-small);
    margin-bottom: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fun-notification.success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.fun-notification.warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.fun-notification.error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.fun-notification-popup {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 2000 !important;
    min-width: 300px !important;
    max-width: 500px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
}

/* 選擇計數器 */
.fun-selection-counter {
    background: linear-gradient(135deg, var(--fun-button) 0%, var(--fun-accent) 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--fun-radius);
    box-shadow: 0 4px 16px rgba(98, 152, 192, 0.3);
    font-weight: 600;
    text-align: center;
    margin-bottom: 1rem;
    animation: slideInDown 0.3s ease;
}

.fun-selection-counter.warning {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
}

.fun-selection-counter.success {
    background: linear-gradient(135deg, #51cf66 0%, #40c057 100%);
}

/* 快捷選擇按鈕 */
.fun-quick-select-container {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    padding: 1rem;
    background: var(--fun-surface);
    border-radius: var(--fun-radius);
    border: 1px solid var(--fun-border);
}

.fun-quick-select-btn {
    animation: fadeInUp 0.5s ease forwards;
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--fun-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--fun-transition);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* 動畫效果 */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes bounce {
    0%, 20%, 60%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    80% {
        transform: translateY(-5px);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(98, 152, 192, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(98, 152, 192, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(98, 152, 192, 0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 響應式設計 */
@media (max-width: 768px) {
    .fun-choice-grid,
    .wpforms-image-choices {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .fun-choice-item,
    .wpforms-image-choices-item {
        padding: 0.75rem;
        min-height: 100px;
    }
    
    .fun-choice-item img,
    .wpforms-image-choices-image img {
        max-width: 40px;
        max-height: 30px;
    }
    
    .fun-quick-select-container {
        flex-direction: column;
        align-items: center;
    }
    
    .fun-quick-select-btn {
        width: 100%;
        max-width: 200px;
    }
    
    .fun-selection-counter {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 0;
        z-index: 1000;
        margin: 0;
    }
    
    .fun-notification-popup {
        left: 10px !important;
        right: 10px !important;
        min-width: auto !important;
        max-width: none !important;
    }
}

@media (max-width: 480px) {
    .fun-choice-grid,
    .wpforms-image-choices {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .wpforms-container {
        padding: 1rem !important;
    }
}

/* 錯誤狀態樣式 */
.fun-field-error {
    border-color: var(--fun-error) !important;
    background-color: rgba(239, 68, 68, 0.1) !important;
}

/* Loading狀態 */
.fun-loading {
    position: relative;
    overflow: hidden;
}

.fun-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* 工具提示 */
.fun-tooltip {
    position: relative;
    cursor: help;
}

.fun-tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.fun-tooltip:hover::before {
    opacity: 1;
}

/* 額外的動畫效果 */
.wpforms-image-choices-item:hover,
.fun-choice-item:hover {
    animation: pulse 2s infinite;
}

.wpforms-image-choices-item.selected,
.fun-choice-item.selected {
    animation: bounce 0.6s ease;
}

.fun-quick-select-btn:nth-child(1) {
    animation-delay: 0.1s;
}

.fun-quick-select-btn:nth-child(2) {
    animation-delay: 0.2s;
}

.fun-quick-select-btn:nth-child(3) {
    animation-delay: 0.3s;
}