/* ==============================================
   Dream Team Module - Ultimate XI Builder
   ============================================== */

/* Page Container */
.dream-team-page {
    position: relative;
    min-height: calc(100vh - 40px);
    padding: var(--spacing-xl);
    overflow: hidden;
}

/* Animated Background */
.dream-team-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.bg-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
        rgba(16, 185, 129, 0.1) 0%,
        rgba(59, 130, 246, 0.05) 50%,
        rgba(139, 92, 246, 0.1) 100%);
    animation: gradientShift 15s ease-in-out infinite;
}

.bg-particles {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 20% 80%, rgba(16, 185, 129, 0.15) 0%, transparent 50%),
                      radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
                      radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
    animation: particleFloat 20s ease-in-out infinite;
}

.bg-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at center, rgba(16, 185, 129, 0.03) 0%, transparent 70%);
    animation: glowPulse 8s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes particleFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

@keyframes glowPulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* Header */
.dream-team-header {
    position: relative;
    z-index: 1;
    margin-bottom: var(--spacing-xl);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.header-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.title-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
    animation: iconPulse 3s ease-in-out infinite;
}

.title-icon svg {
    width: 28px;
    height: 28px;
    stroke: white;
    fill: rgba(255, 255, 255, 0.2);
    stroke-width: 2;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.header-title h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #10B981 0%, #34D399 50%, #6EE7B7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-title p {
    font-size: 14px;
    color: var(--text-secondary);
}


.header-stats {
    display: flex;
    gap: var(--spacing-xl);
}

.header-stat {
    text-align: center;
    padding: var(--spacing-md) var(--spacing-xl);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
}

.header-stat .stat-value {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
}

.header-stat .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-stat.team-rating.gold .stat-value {
    background: linear-gradient(135deg, #F59E0B 0%, #FBBF24 50%, #FCD34D 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-stat.team-rating.silver .stat-value {
    background: linear-gradient(135deg, #9CA3AF 0%, #D1D5DB 50%, #E5E7EB 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Formation Selector */
.formation-selector {
    display: flex;
    gap: var(--spacing-sm);
    background: var(--bg-card);
    padding: var(--spacing-sm);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    width: fit-content;
}

.formation-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.formation-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.formation-btn.active {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

/* Main Content */
.dream-team-content {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--spacing-xl);
}

/* Pitch Container */
.pitch-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Football Pitch - Portrait Mode */
.pitch {
    position: relative;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 2 / 3;
    margin: 0 auto;
    background: linear-gradient(180deg,
        #1a472a 0%,
        #1e5631 12.5%,
        #1a472a 25%,
        #1e5631 37.5%,
        #1a472a 50%,
        #1e5631 62.5%,
        #1a472a 75%,
        #1e5631 87.5%,
        #1a472a 100%);
    background-size: 100% 60px;
    border-radius: var(--radius-2xl);
    overflow: hidden;
    box-shadow:
        0 0 0 4px rgba(255, 255, 255, 0.1),
        0 20px 60px rgba(0, 0, 0, 0.4),
        inset 0 0 100px rgba(0, 0, 0, 0.3);
}

.pitch-gradient {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    pointer-events: none;
}

.pitch-lines {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.pitch-lines svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Pitch Positions */
.pitch-positions {
    position: absolute;
    inset: 0;
}

.pitch-position {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    animation: positionAppear 0.5s ease-out forwards;
    animation-delay: var(--delay, 0s);
    opacity: 0;
}

@keyframes positionAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Empty Position */
.pitch-position.empty {
    width: 60px;
    height: 60px;
}

.position-pulse {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px solid rgba(16, 185, 129, 0.5);
    animation: pulsate 2s ease-out infinite;
}

@keyframes pulsate {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.position-slot {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.pitch-position.empty:hover .position-slot {
    background: rgba(16, 185, 129, 0.3);
    border-color: #10B981;
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.5);
}

.position-label {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
}

.position-slot svg {
    width: 16px;
    height: 16px;
    stroke: rgba(255, 255, 255, 0.5);
    stroke-width: 2;
    margin-top: 2px;
}

/* Filled Position */
.pitch-position.filled {
    width: 70px;
    height: 90px;
}

.position-ring {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
        #10B981 0deg,
        #34D399 120deg,
        #6EE7B7 240deg,
        #10B981 360deg);
    animation: ringRotate 4s linear infinite;
    padding: 3px;
}

@keyframes ringRotate {
    from { transform: translateX(-50%) rotate(0deg); }
    to { transform: translateX(-50%) rotate(360deg); }
}

.position-player {
    position: absolute;
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 54px;
    height: 54px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-secondary);
    z-index: 1;
}

.position-player img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.position-info {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    width: 80px;
}

.position-name {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.position-rating {
    display: inline-block;
    padding: 2px 6px;
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    border-radius: var(--radius-sm);
    font-size: 9px;
    font-weight: 800;
    color: white;
    margin-top: 2px;
}

.position-remove {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #EF4444;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
    z-index: 2;
}

.pitch-position.filled:hover .position-remove {
    opacity: 1;
    transform: scale(1);
}

.position-remove svg {
    width: 12px;
    height: 12px;
    stroke: white;
    stroke-width: 2;
}

/* Pitch Actions */
.pitch-actions {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.pitch-actions .btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.pitch-actions .btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.pitch-actions .btn-success {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.pitch-actions .btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.pitch-actions .btn-danger {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.pitch-actions .btn-danger:hover {
    background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Sidebar Cards */
.dream-team-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Team Manager Card */
.team-manager-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
}

.team-manager-card h3 {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
}

.team-manager-card h3 svg {
    width: 18px;
    height: 18px;
    stroke: #F59E0B;
    fill: rgba(245, 158, 11, 0.2);
    stroke-width: 2;
}

.team-manager-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.team-manager-content label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-xs);
}

.team-selector select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.team-selector select:hover {
    border-color: var(--accent);
}

.team-selector select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.team-name-field input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.team-name-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.team-name-field input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.team-stats-card,
.quick-add-card,
.team-list-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
}

.team-stats-card h3,
.quick-add-card h3,
.team-list-card h3 {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
}

.team-stats-card h3 svg,
.quick-add-card h3 svg,
.team-list-card h3 svg {
    width: 18px;
    height: 18px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
}

/* Team Stats */
.team-stats-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.team-stat {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--spacing-sm);
}

.stat-bar {
    grid-column: 1 / -1;
    height: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    width: var(--width, 0%);
    border-radius: var(--radius-pill);
    transition: width 1s ease-out;
}

.stat-fill.attack {
    background: linear-gradient(90deg, #EF4444 0%, #F97316 100%);
}

.stat-fill.midfield {
    background: linear-gradient(90deg, #10B981 0%, #34D399 100%);
}

.stat-fill.defense {
    background: linear-gradient(90deg, #3B82F6 0%, #6366F1 100%);
}

.stat-name {
    font-size: 12px;
    color: var(--text-secondary);
}

.stat-val {
    font-size: 14px;
    font-weight: 700;
}

/* Quick Add List */
.quick-add-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    max-height: 250px;
    overflow-y: auto;
}

.quick-add-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-add-item:hover {
    background: var(--bg-hover);
}

.quick-add-item img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.quick-add-item .item-info {
    flex: 1;
    min-width: 0;
}

.quick-add-item .item-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-add-item .item-pos {
    font-size: 11px;
    color: var(--text-secondary);
}

.quick-add-item .item-add {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
}

.quick-add-item:hover .item-add {
    opacity: 1;
    transform: scale(1);
}

.quick-add-item .item-add svg {
    width: 14px;
    height: 14px;
    stroke: white;
    stroke-width: 2;
}

/* Team List */
.team-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    max-height: 300px;
    overflow-y: auto;
}

.team-list-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    font-size: 12px;
}

.team-list-item.filled {
    background: var(--bg-hover);
}

.team-list-item.empty {
    opacity: 0.5;
}

.item-position {
    width: 36px;
    height: 24px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
}

.team-list-item.filled .item-position {
    background: var(--accent);
    color: white;
}

.item-player {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    min-width: 0;
}

.item-player img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.item-player span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.item-empty {
    flex: 1;
    color: var(--text-muted);
    font-style: italic;
}

.item-rating {
    font-weight: 700;
    color: var(--accent);
}

/* Player Selector Slide Panel */
.player-selector {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.selector-search {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    padding-bottom: var(--spacing-md);
    z-index: 1;
}

.selector-tabs {
    display: flex;
    gap: var(--spacing-sm);
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--spacing-md);
}

.selector-tab {
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.selector-tab:hover {
    background: var(--bg-hover);
}

.selector-tab.active {
    background: var(--accent);
    color: white;
}

.selector-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.selector-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.selector-item:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateX(5px);
}

.selector-item img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.selector-item-info {
    flex: 1;
    min-width: 0;
}

.selector-item-info .name {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selector-item-info .details {
    font-size: 12px;
    color: var(--text-secondary);
}

.selector-item .rating {
    padding: 4px 10px;
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 700;
    color: white;
}

/* Position Selector */
.position-selector {
    padding: var(--spacing-lg);
}

.position-selector-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

.position-option {
    padding: var(--spacing-lg);
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-xl);
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
}

.position-option:hover {
    border-color: var(--accent);
    background: rgba(16, 185, 129, 0.1);
    transform: translateY(-3px);
}

.position-option .pos-label {
    display: block;
    font-size: 20px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: var(--spacing-xs);
}

.position-option .pos-name {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Loading States */
.loading-mini {
    display: flex;
    justify-content: center;
    padding: var(--spacing-xl);
}

.spinner-sm {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.empty-mini {
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--text-secondary);
}

.empty-mini a {
    color: var(--accent);
    text-decoration: none;
}

/* Responsive */
@media (max-width: 1200px) {
    .dream-team-content {
        grid-template-columns: 1fr;
    }

    .dream-team-sidebar {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-lg);
    }
}

@media (max-width: 900px) {
    .dream-team-sidebar {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-direction: column;
        gap: var(--spacing-lg);
        text-align: center;
    }

    .header-title {
        flex-direction: column;
    }

    .formation-selector {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .dream-team-page {
        padding: var(--spacing-md);
    }

    .pitch-position.empty {
        width: 45px;
        height: 45px;
    }

    .position-slot {
        width: 45px;
        height: 45px;
    }

    .pitch-position.filled {
        width: 55px;
        height: 75px;
    }

    .position-ring {
        width: 45px;
        height: 45px;
    }

    .position-player {
        width: 40px;
        height: 40px;
    }

    .position-info {
        width: 60px;
    }

    .position-name {
        font-size: 8px;
    }

    .formation-btn {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 12px;
    }
}

/* Dark Theme Specific */
[data-theme="dark"] .pitch {
    box-shadow:
        0 0 0 4px rgba(255, 255, 255, 0.05),
        0 20px 60px rgba(0, 0, 0, 0.6),
        inset 0 0 100px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .position-slot {
    background: rgba(255, 255, 255, 0.05);
}
