/* Tận dụng lại các style từ team-builder.css */

.builder-layout.double-mode {
    display: flex;
    flex-direction: row;
    gap: 15px;
    align-items: flex-start;
    max-width: 1400px;
    margin: 20px auto;
}

/* 2 Cột danh sách 2 bên */
.side-bench {
    flex: 0 0 280px; /* Độ rộng cố định cho sidebar */
    height: 850px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Sân bóng ở giữa */
.double-mode .formation-section {
    flex: 1;
    min-width: 500px;
}

.pitch-controls-double {
    display: flex;
    align-items: center;
    justify-content: space-between; 
    width: 100%;
    padding: 10px 20px;
    border-radius: 8px;
    box-sizing: border-box;
}
.ctrl-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
}

.ctrl-group:last-child {
    align-items: flex-end;
}

.vs-divider {
    flex: 0 0 auto; /* Không cho chữ VS co giãn */
    font-weight: 900;
    font-size: 1.2rem;
    color: #ef4444;
    font-style: italic;
    padding: 0 15px;
    text-align: center;
}

.pitch-controls-double select {
    appearance: none;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 12px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.pitch-controls-double select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.pitch-controls-double optgroup {
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    font-style: normal;
}

.pitch-controls-double option {
    font-size: 0.9rem;
    color: #1e293b;
    background: #ffffff;
}

.pitch-controls-double .label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 2px;
}

/* Sân bóng đối đầu dọc */
.field {
    width: 100%;
    aspect-ratio: 2 / 3;
    background: #1a3a2a; /* Màu cỏ xanh đậm chuyên nghiệp */
    position: relative;
    border: 4px solid rgba(255, 255, 255, 0.4); /* Viền bao quanh sân */
    border-radius: 8px;
    overflow: hidden;

    background-image: 
        linear-gradient(to bottom, transparent 49.7%, rgba(255,255,255,0.3) 49.7%, rgba(255,255,255,0.3) 50.3%, transparent 50.3%),
        radial-gradient(circle at 50% 50%, transparent 14.8%, rgba(255,255,255,0.3) 14.8%, rgba(255,255,255,0.3) 15.5%, transparent 15.5%),
        radial-gradient(circle at 50% 50%, rgba(255,255,255,0.4) 1.5%, transparent 1.5%);
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

/* KHU VỰC KHUNG THÀNH (Vẽ bằng pseudo-elements để chuẩn xác) */
.field::before, .field::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 50%; /* Độ rộng vòng cấm */
    height: 12%; /* Độ sâu vòng cấm */
    border: 2px solid rgba(255, 255, 255, 0.3);
    z-index: 1;
}

/* Vòng cấm bên trên (Away) */
.field::before {
    top: -2px;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

/* Vòng cấm bên dưới (Home) */
.field::after {
    bottom: -2px;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}

.field-half {
    position: absolute;
    width: 100%;
    height: 50%;
    overflow: visible !important;
}
.field-half.top { top: 0; border-bottom: 1px solid rgba(255,255,255,0.2);z-index: 2; }
.field-half.bottom { bottom: 0; }

#away-team {
    transform: rotate(180deg);
    width: 100%;
    height: 100%;
}

.pitch-slot {
    position: absolute;
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(2px);
}

.pitch-slot span {
    color: #fff;
    font-size: 0.75rem;
    font-weight: bold;
    opacity: 0.7;
}

/* Style cho cầu thủ khi đã vào sân (Occupied) */
.pitch-slot.occupied {
    border: 2px solid #22c55e; /* Viền xanh lá */
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.6); /* Glow phát sáng */
}

.player-on-pitch {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.player-on-pitch .rating {
    background: #22c55e;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #fff;
    margin-bottom: 2px;
}

.player-on-pitch .name {
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    text-shadow: 1px 1px 3px #000;
    white-space: nowrap;
}

/* Lật ngược lại card cho đội khách để tên không bị ngược */
#away-team .player-on-pitch, 
#away-team span {
    transform: rotate(180deg);
}

/* Container chứa các card cầu thủ */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 cột như ảnh 3 */
    gap: 10px;
}

/* Thẻ cầu thủ (Giống hệt ảnh 3) */
.inventory-card {
    background: #fff;
    border: 1px dashed #cbd5e1; /* Viền nét đứt */
    border-radius: 12px;
    padding: 15px 0px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.inventory-card:hover {
    border-style: solid;
    border-color: #3b82f6;
    background: #f8fafc;
}

.inventory-card.selected {
    border: 2px solid #22c55e !important;
    background: #f0fdf4 !important;
}

.card-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
    width: 100%;
}

.inventory-card .rating {
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}

.position-badge {
    color: #1e293b;
    font-size: 0.75rem;
    font-weight: bold;
}

.inventory-card .name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #1e293b;
    text-align: center;
    margin-bottom: 5px;
}

.price-tag {
    font-size: 0.7rem;
    color: #475569;
    font-weight: 500;
}

/* Nút X xóa màu đỏ */
.btn-delete-player {
    position: absolute;
    top: -5px;
    right: -5px;
    color: #ef4444;
    background: #fff;
    border-radius: 50%;
    line-height: 1;
    font-size: 18px;
    z-index: 5;
    transition: transform 0.2s;
}

.btn-delete-player:hover {
    transform: scale(1.2);
}

/* Popup hướng dẫn ở giữa màn hình */
.status-instruction-box {
    position: fixed;
    top: 15%; /* Đẩy cao lên một chút để tránh che khuất GK */
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 41, 59, 0.9);
    padding: 10px 20px;
    border-radius: 30px;
    z-index: 9999;
    /* QUAN TRỌNG NHẤT */
    pointer-events: none !important;
    border: 2px solid #3b82f6;
    transition: opacity 0.3s;
    opacity: 0;
}

.status-instruction-box.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Hiệu ứng bóng lên cho ô trống trên sân */
.pitch-slot.highlight-mode {
    border: 2.5px solid #22c55e;
    box-shadow: 0 0 20px #22c55e;
    animation: pulse-green 1.5s infinite;
}

@keyframes pulse-glow {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    50% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
}

/* Đảm bảo ô đã có cầu thủ thì không có dashed border */
.pitch-slot.occupied {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

@keyframes pulse-green {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
    100% { transform: translate(-50%, -50%) scale(1); }
}


/* Responsive */
@media screen and (max-width: 1200px) {
    .builder-layout.double-mode {
        flex-direction: column;
        align-items: center;
    }
    .side-bench {
        width: 100%;
        height: auto;
        max-height: 400px;
    }
    .inventory-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}