/* 移動端友好的出場名單表單樣式 */

/* 觸發按鈕 */
.player-form-trigger-wrapper {
    text-align: center;
    margin: 20px 0;
}

.player-form-trigger-btn {
    padding: 15px 40px;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--bricks-border-color);
    border-radius: 8px;
    width: auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-image: linear-gradient(90deg, #1b76ff, #ff5ba6);
}

.player-form-trigger-btn:hover {
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
    transform: translateY(-2px);
}

.player-form-trigger-btn:active {
    transform: translateY(0);
}

/* Modal 遮罩層 */
.player-form-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9998;
    overflow-y: auto;
    padding: 20px;
}

.player-form-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

/* Modal 容器 */
.player-form-modal {
    position: relative;
    max-width: 900px;
    width: 100%;
    overflow-y: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

/* 關閉按鈕 */
.modal-close-btn {
    position: sticky;
    top: 10px;
    right: 10px;
    float: right;
    background: #f44336;
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: -40px;
}

.modal-close-btn:hover {
    background: #d32f2f;
    transform: rotate(90deg);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

/* 表單容器 */
.match-player-form-container {
    max-width: 100%;
    margin: 0;
    padding: 30px;
    background: #fff;
    border-radius: 0 0 12px 12px;
}

.form-title {
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

/* 步驟指示器 */
.form-steps-indicator {
    margin-bottom: 30px;
    padding: 20px 0;
}

.step-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.step-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.step-item.active .step-circle {
    background: #2196F3;
    color: #fff;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.step-item.completed .step-circle {
    background: #4CAF50;
    color: #fff;
}

.step-label {
    font-size: 14px;
    color: #999;
    font-weight: 500;
    transition: color 0.3s ease;
}

.step-item.active .step-label {
    color: #2196F3;
    font-weight: 600;
}

.step-item.completed .step-label {
    color: #4CAF50;
}

.step-line {
    flex: 0 0 60px;
    height: 2px;
    background: #e0e0e0;
    position: relative;
    overflow: hidden;
}

.step-line::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: #4CAF50;
    transition: width 0.3s ease;
}

.step-item.completed ~ .step-line::after {
    width: 100%;
}

.match-player-form {
    width: 100%;
}

/* 步驟容器 */
.form-step {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.form-step.active {
    display: block;
    opacity: 1;
    animation: fadeInStep 0.3s ease-out;
}

@keyframes fadeInStep {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.player-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 6px;
}

.section-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #444;
}

.players-list {
    margin-bottom: 15px;
    /* max-height: 450px; */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px;
    /* 美化滾動條 */
    scrollbar-width: thin;
    scrollbar-color: #bbb #f0f0f0;
    /* 添加內陰影提示可滾動 */
    position: relative;
}

.players-list::before,
.players-list::after {
    content: '';
    position: sticky;
    display: block;
    height: 10px;
    margin: -10px 0;
    pointer-events: none;
    z-index: 1;
}

.players-list::before {
    top: 0;
    background: linear-gradient(to bottom, rgba(249, 249, 249, 1) 0%, rgba(249, 249, 249, 0) 100%);
}

.players-list::after {
    bottom: 0;
    background: linear-gradient(to top, rgba(249, 249, 249, 1) 0%, rgba(249, 249, 249, 0) 100%);
}

/* Webkit 瀏覽器滾動條樣式 */
.players-list::-webkit-scrollbar {
    width: 8px;
}

.players-list::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.players-list::-webkit-scrollbar-thumb {
    background: #bbb;
    border-radius: 4px;
}

.players-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.player-row {
    display: grid;
    grid-template-columns: 2fr 1.2fr 0.8fr auto;
    gap: 8px;
    margin-bottom: 10px;
    padding: 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

.player-select,
.position-select,
.number-input {
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.3s;
}

.player-select:focus,
.position-select:focus,
.number-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.number-input {
    width: 100%;
}

.remove-player-btn {
    padding: 10px 15px;
    background: #f44336;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
    line-height: 1;
    height: 42px;
}

.remove-player-btn:hover {
    background: #d32f2f;
}

.add-player-btn {
    width: 100%;
    padding: 12px;
    background: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.add-player-btn:hover {
    background: #45a049;
}

.form-actions {
    margin-top: 30px;
    text-align: center;
}

/* 按鈕組 */
.btn-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

.btn-primary,
.btn-secondary {
    padding: 15px 30px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

.btn-primary {
    background: #2196F3;
    color: #fff;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.btn-primary:hover {
    background: #1976D2;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e0e0e0;
    color: #333;
}

.submit-btn {
    padding: 15px 40px;
    background: #2196F3;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    min-width: 200px;
}

.submit-btn:hover {
    background: #1976D2;
}

.player-form-notice,
.player-form-success {
    padding: 15px 20px;
    margin: 20px auto;
    max-width: 800px;
    border-radius: 4px;
    text-align: center;
    font-size: 16px;
}

.player-form-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.player-form-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 防止背景滾動 */
body.modal-open {
    overflow: hidden;
}

/* 平板設備 */
@media screen and (max-width: 768px) {
    .player-form-modal-overlay {
        padding: 10px;
        align-items: flex-start;
    }
    
    .player-form-modal {
        margin-top: 10px;
    }
    
    .match-player-form-container {
        padding: 20px 15px;
    }
    
    .form-title {
        font-size: 20px;
    }
    
    .players-list {
        /* max-height: 350px; */
    }
    
    .player-row {
        grid-template-columns: 2fr 1.2fr 0.8fr auto;
        gap: 6px;
        padding: 10px;
    }

    .form-group label {
        font-weight: 600;
        font-size: 12px;
    }

    .remove-player-btn {
        padding: 8px 12px;
        font-size: 16px;
    }
    
    .submit-btn {
        width: 100%;
        min-width: unset;
    }
    
    .player-form-trigger-btn {
        width: 100%;
        max-width: 300px;
    }
}

/* 手機設備 */
@media screen and (max-width: 480px) {
    .player-form-modal-overlay {
        padding: 10px 5px;
        align-items: flex-start;
    }
    
    .player-form-modal {
        margin-top: 10px;
        margin-bottom: 10px;
        border-radius: 8px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        height: 100%;
    }
    
    .modal-close-btn {
        width: 32px;
        height: 32px;
        font-size: 22px;
        top: 6px;
        right: 6px;
    }
    
    .match-player-form-container {
        padding: 10px 8px;
        border-radius: 0 0 8px 8px;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .form-title {
        font-size: 16px;
        margin-bottom: 10px;
        padding-bottom: 8px;
        flex-shrink: 0;
    }
    
    .form-steps-indicator {
        margin-bottom: 15px;
        padding: 10px 0;
        flex-shrink: 0;
    }
    
    .step-circle {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .step-label {
        font-size: 12px;
    }
    
    .step-line {
        flex: 0 0 40px;
    }
    
    .match-player-form {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .form-step {
        flex: 1;
        display: none;
        flex-direction: column;
        overflow: hidden;
    }
    
    .form-step.active {
        display: flex;
    }
    
    .player-section {
        padding: 10px 8px;
        margin-bottom: 0;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .section-title {
        font-size: 15px;
        margin-bottom: 8px;
        flex-shrink: 0;
    }
    
    .players-list {
        margin-bottom: 10px;
        flex: 1;
        overflow-y: auto;
        min-height: 100px;
        height: auto;
    }
    
    .add-player-btn {
        flex-shrink: 0;
    }
    
    .form-actions {
        margin-top: 10px;
        flex-shrink: 0;
    }
    
    .btn-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
        padding: 12px 20px;
        font-size: 15px;
        min-width: unset;
    }
    
    .player-row {
        display: grid;
        grid-template-columns: 2fr 1fr 0.7fr auto;
        gap: 4px;
        padding: 8px;
        margin-bottom: 8px;
    }
    
    .form-group label {
        font-size: 11px;
        margin-bottom: 3px;
        font-weight: 600;
    }
    
    .player-select,
    .position-select,
    .number-input {
        /* padding: 6px 8px; */
        font-size: 14px;
    }
    
    .remove-player-btn {
        padding: 8px 10px;
        font-size: 18px;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .add-player-btn {
        padding: 8px;
        margin-top: auto;
        font-size: 13px;
    }
    
    .form-actions {
        margin-top: 15px;
    }
    
    .player-form-trigger-btn {
        padding: 10px 24px;
        font-size: 15px;
        min-width: 140px;
    }
    
    .player-form-success {
        margin: 10px;
        left: 0;
        right: 0;
        transform: none;
        max-width: calc(100% - 20px);
        padding: 12px 15px;
        font-size: 14px;
    }
}

/* 無障礙增強 */
.player-select:focus-visible,
.position-select:focus-visible,
.number-input:focus-visible,
.add-player-btn:focus-visible,
.submit-btn:focus-visible,
.remove-player-btn:focus-visible {
    outline: 2px solid #2196F3;
    outline-offset: 2px;
}

/* 加載狀態 */
.match-player-form.submitting .submit-btn {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.match-player-form.submitting .submit-btn::after {
    content: "...";
}

/* 表單驗證錯誤狀態 */
.player-select.error,
.position-select.error,
.number-input.error {
    border-color: #f44336;
}

.form-group .error-message {
    margin-top: 4px;
    font-size: 12px;
    color: #f44336;
}

