/* ============================================
   卡片式參與者選擇 - Mobile First Design
   TourSplit 記帳 App - 手機優化 UI
   ============================================ */

/* 隱藏原生 checkbox，使用卡片替代 */
.participant-checkbox-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* 參與者卡片容器 */
.participant-card {
    display: block;
    padding: 16px;
    margin-bottom: 10px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

/* 卡片內容佈局 */
.participant-card-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.participant-info {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.participant-icon {
    font-size: 20px;
    color: #64748b;
    margin-right: 12px;
    flex-shrink: 0;
}

.participant-name {
    font-size: 16px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.participant-checkmark {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 8px;
}

.participant-checkmark i {
    font-size: 14px;
    color: #ffffff;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Hover 狀態 (桌面版) */
@media (hover: hover) {
    .participant-card:hover {
        border-color: #cbd5e1;
        background: #f8fafc;
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
}

/* Active 觸控反饋 */
.participant-card:active {
    transform: scale(0.98);
}

/* 選中狀態 - 使用 :has() 選擇器 (現代瀏覽器) */
.participant-card:has(.participant-checkbox-hidden:checked) {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
}

.participant-card:has(.participant-checkbox-hidden:checked) .participant-checkmark {
    background: #4f46e5;
}

.participant-card:has(.participant-checkbox-hidden:checked) .participant-checkmark i {
    opacity: 1;
}

.participant-card:has(.participant-checkbox-hidden:checked) .participant-icon {
    color: #4f46e5;
}

.participant-card:has(.participant-checkbox-hidden:checked) .participant-name {
    color: #4f46e5;
    font-weight: 600;
}

/* 舊版瀏覽器兼容性 (fallback) - 使用 JavaScript 添加 .selected class */

.participant-card.selected {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
}

.participant-card.selected .participant-checkmark {
    background: #4f46e5;
}

.participant-card.selected .participant-checkmark i {
    opacity: 1;
}

.participant-card.selected .participant-icon {
    color: #4f46e5;
}

.participant-card.selected .participant-name {
    color: #4f46e5;
    font-weight: 600;
}

/* ============================================
   全選按鈕
   ============================================ */

.btn-select-all {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #fbbf24;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    outline: none;
}

.select-all-icon {
    width: 44px;
    height: 44px;
    background: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.select-all-icon i {
    font-size: 20px;
    color: #f59e0b;
    transition: color 0.2s ease;
}

.select-all-text {
    flex: 1;
    min-width: 0;
}

.select-all-text strong {
    display: block;
    color: #92400e;
    font-size: 16px;
    margin-bottom: 2px;
}

.select-all-text small {
    color: #b45309;
    font-size: 13px;
    display: block;
}

.select-all-status {
    width: 28px;
    height: 28px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.select-all-status i {
    font-size: 16px;
    color: #e2e8f0;
    transition: all 0.2s ease;
}

/* 全選按鈕 - 已全選狀態 */
.btn-select-all.all-selected {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-color: #10b981;
}

.btn-select-all.all-selected .select-all-icon {
    background: #10b981;
}

.btn-select-all.all-selected .select-all-icon i {
    color: #ffffff;
}

.btn-select-all.all-selected .select-all-text strong {
    color: #065f46;
}

.btn-select-all.all-selected .select-all-text small {
    color: #047857;
}

.btn-select-all.all-selected .select-all-status i {
    color: #10b981;
}

/* 全選按鈕 - 互動效果 */
.btn-select-all:active {
    transform: scale(0.97);
}

@media (hover: hover) {
    .btn-select-all:hover {
        box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
        transform: translateY(-2px);
    }

    .btn-select-all.all-selected:hover {
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    }
}

/* ============================================
   自訂金額區塊
   ============================================ */

.custom-amount-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #cbd5e1;
}

.custom-amount-wrapper {
    margin-top: 12px;
}

/* ============================================
   參與者列表容器
   ============================================ */

.participants-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
    /* 自訂滾動條樣式 */
}

.participants-container::-webkit-scrollbar {
    width: 8px;
}

.participants-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.participants-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.participants-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================
   響應式調整
   ============================================ */

/* 平板及以上 */
@media (min-width: 768px) {
    .participant-card {
        padding: 14px 18px;
    }

    .participant-name {
        font-size: 15px;
    }

    .participants-container {
        max-height: 350px;
    }
}

/* 小螢幕手機優化 */
@media (max-width: 360px) {
    .participant-card {
        padding: 14px;
    }

    .participant-name {
        font-size: 15px;
    }

    .participant-checkmark {
        width: 24px;
        height: 24px;
    }

    .select-all-text strong {
        font-size: 15px;
    }

    .select-all-text small {
        font-size: 12px;
    }
}

/* 大螢幕優化 */
@media (min-width: 1024px) {
    .participants-container {
        max-height: 300px;
    }
}