/* =========================================================
   clubs.css — v8
   - قائمة الأندية
   - Modal لاعبين مرتبين بالنقاط
   - ألوان Finalissima (عنابي + ذهبي)
========================================================= */

/* ⭐ CSS Variables — Qatar 2022 */
:root {
    --purple-50:   #FAF6F0;
    --purple-100:  #E5D4A5;
    --purple-300:  #C8A95F;
    --purple-500:  #8B1A2F;
    --purple-600:  #6B0F1F;
    --purple-700:  #4A0A15;
}

/* ========== Controls ========== */

.clubs-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
    padding: 0 4px;
}

.clubs-edit-btn {
    padding: 8px 16px;
    background: #FFFFFF;
    border: 1.5px solid var(--purple-100, #E5D4A5);
    border-radius: 10px;
    color: var(--purple-600, #6B0F1F);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.5px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(139, 26, 47, 0.06);
}

.clubs-edit-btn:hover {
    border-color: var(--purple-300, #C8A95F);
    box-shadow: 0 4px 14px rgba(139, 26, 47, 0.15);
}

.clubs-edit-btn.active {
    background: linear-gradient(135deg, #8B1A2F 0%, #6B0F1F 100%);
    border-color: var(--purple-500, #8B1A2F);
    color: #fff;
}

/* ========== Clubs List ========== */

.clubs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.clubs-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary, #9CA3AF);
    font-size: 13px;
    font-weight: 700;
    background: var(--purple-50, #FAF6F0);
    border-radius: 12px;
    border: 1px dashed var(--purple-100, #E5D4A5);
}

.club-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #FFFFFF;
    border: 1.5px solid var(--purple-100, #E5D4A5);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(139, 26, 47, 0.06);
}

.club-item:hover {
    border-color: var(--purple-300, #C8A95F);
    box-shadow: 0 6px 20px rgba(139, 26, 47, 0.15);
    transform: translateY(-2px);
}

.club-item-logo {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    flex-shrink: 0;
    overflow: visible;
}

.club-item-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.club-item-logo-empty {
    background: var(--purple-50, #FAF6F0);
    border-radius: 50%;
    border: 1px solid var(--purple-100, #E5D4A5);
}

.club-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.club-item-name {
    font-size: 14px;
    font-weight: 900;
    color: var(--text-primary, #111827);
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.club-item-count {
    font-size: 11px;
    font-weight: 800;
    color: var(--purple-600, #6B0F1F);
    letter-spacing: 0.5px;
}

.club-item-arrow {
    font-size: 22px;
    font-weight: 900;
    color: var(--purple-500, #8B1A2F);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.club-item:hover .club-item-arrow {
    transform: translateX(-4px);
}

/* =========================================================
   Club Players Modal
========================================================= */

.cp-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.cp-modal.show {
    display: flex;
}

.cp-modal-box {
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    background: #FFFFFF;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(17, 24, 39, 0.3);
    animation: cpIn 0.25s ease;
}

@keyframes cpIn {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Header */
.cp-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #8B1A2F 0%, #6B0F1F 100%);
    color: #fff;
    position: relative;
    flex-shrink: 0;
    border-bottom: 3px solid #C8A95F;
}

.cp-header-logo {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(200, 169, 95, 0.5);
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    padding: 6px;
}

.cp-header-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.cp-header-info {
    flex: 1;
    min-width: 0;
}

.cp-header-title {
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 0.5px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cp-header-sub {
    font-size: 11px;
    font-weight: 700;
    color: #E5D4A5;
    margin-top: 2px;
    letter-spacing: 0.5px;
}

.cp-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #C8A95F;
    color: #C8A95F;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease;
    flex-shrink: 0;
    font-family: inherit;
}

.cp-close:hover {
    background: #C8A95F;
    color: #8B1A2F;
}

/* List Header */
.cp-list-header {
    display: grid;
    grid-template-columns: 34px 34px 1fr 60px;
    gap: 8px;
    align-items: center;
    padding: 10px 16px;
    background: var(--purple-50, #FAF6F0);
    border-bottom: 1.5px solid var(--purple-100, #E5D4A5);
    color: var(--purple-700, #4A0A15);
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.cp-lh-rank { text-align: center; }
.cp-lh-logo { width: 34px; }
.cp-lh-name { text-align: left; padding-left: 2px; }
.cp-lh-points { text-align: right; }

/* Players List */
.cp-players-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: #FFFFFF;
}

.cp-player-row {
    display: grid;
    grid-template-columns: 34px 34px 1fr 60px;
    gap: 8px;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #F3F4F6;
    transition: background 0.2s ease;
    background: #FFFFFF;
}

.cp-player-row:last-child {
    border-bottom: none;
}

.cp-player-row:hover {
    background: var(--purple-50, #FAF6F0);
}

/* Top 3 */
.cp-player-row.cp-top-1 {
    background: linear-gradient(90deg, rgba(200, 169, 95, 0.20) 0%, transparent 60%);
    border-left: 4px solid #C8A95F;
}
.cp-player-row.cp-top-2 {
    background: linear-gradient(90deg, rgba(200, 169, 95, 0.12) 0%, transparent 60%);
    border-left: 4px solid #C8A95F;
    opacity: 0.95;
}
.cp-player-row.cp-top-3 {
    background: linear-gradient(90deg, rgba(139, 26, 47, 0.08) 0%, transparent 60%);
    border-left: 4px solid #8B1A2F;
}

/* Rank */
.cp-rank {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 900;
    color: #6B7280;
    margin: 0 auto;
    border-radius: 50%;
    background: #F3F4F6;
}

.cp-top-1 .cp-rank {
    background: linear-gradient(135deg, #C8A95F 0%, #8B7340 100%);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(200, 169, 95, 0.5);
}

.cp-top-2 .cp-rank {
    background: linear-gradient(135deg, #E5E5E5 0%, #A8A8A8 100%);
    color: #333;
}

.cp-top-3 .cp-rank {
    background: linear-gradient(135deg, #CD7F32 0%, #8B4513 100%);
    color: #FFFFFF;
}

/* Logo */
.cp-logo {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    flex-shrink: 0;
    overflow: visible;
}

.cp-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.cp-logo-empty {
    background: var(--purple-50, #FAF6F0);
    border-radius: 50%;
    border: 1px solid var(--purple-100, #E5D4A5);
}

/* Names */
.cp-names {
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cp-name {
    font-size: 13px;
    font-weight: 900;
    color: var(--text-primary, #111827);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.cp-player {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary, #9CA3AF);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Points */
.cp-points {
    text-align: right;
    font-size: 15px;
    font-weight: 900;
    color: #8B1A2F;
    letter-spacing: 0.5px;
}

.cp-points-label {
    display: block;
    font-size: 8px;
    font-weight: 800;
    color: var(--text-tertiary, #9CA3AF);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: right;
    margin-top: 1px;
}

/* Loading */
.cp-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 14px;
    color: #8B1A2F;
    font-size: 13px;
    font-weight: 700;
}

.cp-loading .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(139, 26, 47, 0.2);
    border-top-color: #8B1A2F;
    border-radius: 50%;
    animation: cpSpin 0.8s linear infinite;
}

@keyframes cpSpin {
    to { transform: rotate(360deg); }
}

/* Error / Empty */
.cp-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-tertiary, #9CA3AF);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.7;
}

.cp-empty-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* =========================================================
   Old Club Detail Modal (احتياطي)
========================================================= */

#clubModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    z-index: 99998;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#clubModal.show {
    display: flex;
}

.club-modal-box {
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    background: #FFFFFF;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(17, 24, 39, 0.25);
    display: flex;
    flex-direction: column;
    direction: rtl;
}

.club-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #8B1A2F 0%, #6B0F1F 100%);
    color: #fff;
    border-bottom: 3px solid #C8A95F;
}

.club-modal-logo {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    padding: 6px;
    flex-shrink: 0;
}

.club-modal-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.club-modal-title {
    flex: 1;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0.3px;
}

.club-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #C8A95F;
    color: #C8A95F;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-family: inherit;
}

.club-modal-sub {
    padding: 12px 18px;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-secondary, #6B7280);
    background: var(--purple-50, #FAF6F0);
    border-bottom: 1.5px solid var(--purple-100, #E5D4A5);
}

.club-players-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.club-player-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-bottom: 1px solid #F3F4F6;
}

.club-player-num {
    width: 24px;
    font-size: 11px;
    font-weight: 900;
    color: #6B0F1F;
    text-align: center;
}

.club-player-name {
    flex: 1;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary, #111827);
}

.club-player-del {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    border: none;
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-family: inherit;
}

.club-add-btn {
    margin: 8px 18px 14px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #8B1A2F 0%, #6B0F1F 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
    font-family: inherit;
}

.club-stats-btn {
    margin: 12px 18px 4px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #C8A95F 0%, #8B7340 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
    font-family: inherit;
    display: block;
    width: calc(100% - 36px);
}

/* Mobile */
@media (max-width: 480px) {
    .cp-header {
        padding: 14px;
        gap: 10px;
    }

    .cp-header-logo {
        width: 40px;
        height: 40px;
        padding: 5px;
    }

    .cp-header-title { font-size: 14px; }

    .cp-list-header,
    .cp-player-row {
        grid-template-columns: 30px 30px 1fr 52px;
        gap: 6px;
        padding: 9px 12px;
    }

    .cp-logo {
        width: 30px;
        height: 30px;
    }

    .cp-name { font-size: 12px; }
    .cp-player { font-size: 9px; }
    .cp-points { font-size: 14px; }

    .cp-rank {
        width: 22px;
        height: 22px;
        font-size: 10px;
    }
}

/* ⭐ للاعبين بدون نقاط (مو في FPL) */
.cp-player-row.cp-not-found {
    opacity: 0.75;
}

.cp-player-row.cp-not-found .cp-rank {
    background: #E5E7EB;
    color: #9CA3AF;
}

.cp-player-row.cp-not-found .cp-name {
    color: #6B7280;
}

.cp-points.cp-points-empty {
    color: #9CA3AF;
    font-weight: 700;
}
