/* =====================================================
   ProPlayerExtensions – Team Selection Modal & Fields
   ===================================================== */

/* ----- Tournament Create: injected toggle fields ----- */
.atp-team-choice-fields {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

/* ----- Info banner when players choose their own teams ----- */
.atp-players-choose-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    color: #1e40af;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
}

.atp-players-choose-info svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #3b82f6;
}

/* ----- TSM Backdrop ----- */
.tsm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(4px);
    padding: 16px;
}

.tsm-backdrop.is-open {
    display: flex;
}

/* ----- TSM Modal Card ----- */
.tsm-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    overflow: hidden;
    animation: tsm-slide-up .25s ease-out;
}

@keyframes tsm-slide-up {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tsm-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.tsm-modal__header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

.tsm-modal__close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
    padding: 0 4px;
    transition: color .15s;
}

.tsm-modal__close:hover {
    color: #111827;
}

/* ----- TSM Body ----- */
.tsm-modal__body {
    padding: 20px 24px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tsm-search-box input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 15px;
    color: #111827;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}

.tsm-search-box input:focus {
    outline: none;
    border-color: var(--color-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

.tsm-search-box input:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

/* ----- Results ----- */
.tsm-results {
    max-height: 320px;
    overflow-y: auto;
}

.tsm-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
}

.tsm-result-item:hover {
    background: var(--color-bg-secondary, #f3f4f6);
}

.tsm-result-item__logo {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: contain;
    flex-shrink: 0;
}

.tsm-result-item__logo-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    color: #9ca3af;
    font-size: 16px;
    flex-shrink: 0;
}

.tsm-result-item__info {
    min-width: 0;
    flex: 1;
}

.tsm-result-item__name {
    font-weight: 600;
    font-size: 14px;
    color: #111827;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tsm-result-item__meta {
    font-size: 12px;
    color: #6b7280;
}

.tsm-badge-custom {
    display: inline-block;
    padding: 1px 6px;
    background: #eef2ff;
    color: var(--color-primary, #6366f1);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.tsm-no-results,
.tsm-loading,
.tsm-error {
    padding: 16px;
    text-align: center;
    font-size: 14px;
    color: #6b7280;
}

.tsm-error {
    color: #b91c1c;
}

/* ----- Selected Team Pill ----- */
.tsm-selected {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
}

.tsm-selected__info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: #166534;
}

.tsm-selected__logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: contain;
}

.tsm-selected__remove {
    background: none;
    border: none;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    padding: 0 4px;
    transition: color .15s;
}

.tsm-selected__remove:hover {
    color: #ef4444;
}

/* ----- Feedback ----- */
.tsm-feedback {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

.tsm-feedback.is-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.tsm-feedback.is-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* ----- Actions ----- */
.tsm-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.tsm-confirm-btn {
    padding: 10px 24px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
}

.tsm-cancel-btn {
    padding: 10px 20px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
}

.tsm-confirm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ----- Inline Create-Team Form ----- */
.tsm-create-form {
    padding: 8px 0;
}

.tsm-create-form h4 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.tsm-create-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.tsm-create-save-btn:disabled {
    opacity: 0.6;
}

/* ----- Responsive ----- */
@media (max-width: 480px) {
    .tsm-modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 12px;
    }

    .tsm-modal__body {
        padding: 16px;
    }

    .tsm-actions {
        flex-direction: column-reverse;
        padding: 12px 16px;
    }

    .tsm-actions button {
        width: 100%;
    }

    .tsm-create-actions {
        flex-direction: column-reverse;
    }

    .tsm-create-actions button {
        width: 100%;
    }
}
