/* CommanderStyles.css - Стили для модального окна и панели командира */

/* ============================================
   МОДАЛЬНОЕ ОКНО КОМАНДИРА
   ============================================ */

.commander-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: linear-gradient(135deg, #1a1a2a, #252535);
    border: 3px solid #aa66ff;
    border-radius: 16px;
    padding: 24px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(170, 102, 255, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #aa66ff;
}

.modal-close {
    background: rgba(255, 0, 0, 0.2);
    border: 2px solid #ff4444;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 20px;
    color: #ff4444;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255, 0, 0, 0.4);
    transform: rotate(90deg);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.commander-card-modal {
    background: linear-gradient(135deg, #2a1a4a, #3a2a5a);
    border: 2px solid #aa66ff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(170, 102, 255, 0.3);
}

/* ============================================
   ТАБЛИЦА НИШТЯКОВ 5x4
   ============================================ */

.loots-section {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 16px;
}

.loots-grid-5x4 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
}

.loots-grid-5x2 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 6px;
    width: 100%;
}

.loot-cell {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.loot-cell.filled {
    background: linear-gradient(135deg, #2a4a2a, #1a3a1a);
    border: 2px solid #44ff44;
    cursor: pointer;
}

.loot-cell.filled:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(68, 255, 68, 0.5);
    z-index: 10;
}

.loot-cell.empty {
    background: rgba(0, 0, 0, 0.3);
    border: 2px dashed #444;
}

.loot-sprite {
    font-size: 2em;
    margin-bottom: 4px;
}

.loot-value {
    font-size: 0.7em;
    color: #ffd700;
    font-weight: bold;
}

.loot-placeholder {
    font-size: 1.5em;
    color: #333;
}

/* ============================================
   РАСКРЫВАЮЩАЯСЯ ПАНЕЛЬ ТРОФЕЕВ ВНУТРИ КАРТОЧКИ
   ============================================ */

.commander-loots-expandable {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    opacity: 0;
    margin-top: 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

/* ============================================
   ЗАКРЕПЛЕННАЯ КАРТОЧКА КОМАНДИРА В ПАНЕЛИ
   ============================================ */

.commander-panel-card {
    position: relative;
    background: linear-gradient(135deg, #3a2a5a, #2a1a4a);
    border: 3px solid #aa66ff;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 0 15px rgba(170, 102, 255, 0.3);
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.commander-panel-card:hover {
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(170, 102, 255, 0.5);
}

.commander-panel-card.selected {
    border-color: #44ff44;
    box-shadow: 0 0 20px rgba(68, 255, 68, 0.5);
}

.commander-loots-indicator {
    text-align: center;
    padding: 6px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 6px;
    color: #ffd700;
    font-size: 0.85em;
    margin-top: 8px;
    pointer-events: none;
}

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 16px;
    }
    
    .loots-grid-5x4 {
        gap: 6px;
    }
    
    .loot-sprite {
        font-size: 1.5em;
    }
    
    .loot-value {
        font-size: 0.6em;
    }
}

/* ============================================
   СКРОЛЛБАР ДЛЯ МОДАЛЬНОГО ОКНА
   ============================================ */

.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #aa66ff;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #cc88ff;
}

/* ============================================
   DRAG & DROP НИШТЯКОВ
   ============================================ */

/* Перетаскиваемые ячейки */
.loot-cell.draggable {
    cursor: grab;
}

.loot-cell.draggable:active {
    cursor: grabbing;
}

.loot-cell.dragging {
    opacity: 0.5;
    transform: scale(0.9);
}

/* Ячейки, на которые можно сбросить */
.loot-cell.droppable {
    transition: all 0.2s;
}

/* Подсветка при наведении */
.loot-cell.drag-over {
    background: linear-gradient(135deg, #4a4a2a, #3a3a1a) !important;
    border-color: #ffff44 !important;
    box-shadow: 0 0 20px rgba(255, 255, 68, 0.6);
    transform: scale(1.05);
}

/* Анимация передачи */
@keyframes lootTransfer {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.loot-cell.transferring {
    animation: lootTransfer 0.3s ease;
}

/* Подсветка карточки солдата при наведении с ништяком */
.unified-soldier-card.loot-drop-target {
    border-color: #ffff44 !important;
    box-shadow: 0 0 20px rgba(255, 255, 68, 0.6) !important;
    transform: scale(1.05);
}

/* Модальное окно ништяков солдата */
#soldier-loots-modal .modal-header h2 {
    color: #87CEEB;
}

/* Визуальная обратная связь при перетаскивании */
.loot-cell.filled.draggable::after {
    content: '↔️';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.8em;
    opacity: 0;
    transition: opacity 0.2s;
}

.loot-cell.filled.draggable:hover::after {
    opacity: 1;
}

/* Индикатор возможности обмена */
.loot-cell.filled.drag-over::before {
    content: '🔄';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2em;
    z-index: 100;
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* Индикатор пустой ячейки при наведении */
.loot-cell.empty.drag-over .loot-placeholder {
    content: '⬇️';
    color: #ffff44;
    font-size: 2em;
}


/* ============================================
   STICKY COMMANDER + SCROLLABLE SOLDIERS
   ============================================ */

.commander-sticky-container {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #12121a;
    padding-bottom: 8px;
    border-bottom: 2px solid #aa66ff;
    margin-bottom: 8px;
}

.soldiers-scrollable-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Стили для перетаскиваемых спрайтов ништяков */
.draggable-loot-sprite {
    width: 80px;
    height: 80px;
    background-image: url('Neshtiaky.png');
    background-size: 800px 800px;
    image-rendering: pixelated;
    cursor: grab;
    border: 2px solid #FFD700;
    border-radius: 4px;
    transition: all 0.2s;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
}

.draggable-loot-sprite:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
}

.draggable-loot-sprite:active {
    cursor: grabbing;
    opacity: 0.5;
    transform: scale(0.9);
}

/* Стили для области сброса ништяков */
.card-loots-area {
    width: 100%;
    min-height: 30px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    border: 2px dashed transparent;
}

.card-loots-area.drag-over {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.2);
}

/* Анимация для успешной передачи */
@keyframes lootTransferSuccess {
    0% {
        transform: scale(1);
        box-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
    }
    50% {
        transform: scale(1.2);
        box-shadow: 0 0 20px rgba(68, 255, 68, 0.8);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
    }
}

.loot-transfer-success {
    animation: lootTransferSuccess 0.5s ease;
}

/* ========== НОВАЯ СИСТЕМА DRAG & DROP ========== */

/* Активная drop-зона */
.drop-zone-active {
    position: relative;
    transition: all 0.3s ease;
}

.drop-zone-active::after {
    content: '';
    position: absolute;
    inset: -2px;
    border: 2px dashed #888;
    border-radius: 8px;
    pointer-events: none;
    animation: pulseDropZone 2s infinite;
}

@keyframes pulseDropZone {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

/* Валидная drop-зона (можно сбросить) */
.drag-over-valid {
    background: rgba(68, 255, 68, 0.1) !important;
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(68, 255, 68, 0.5) !important;
}

.drag-over-valid::after {
    border-color: #44ff44 !important;
    border-style: solid !important;
    border-width: 3px !important;
    animation: none !important;
    box-shadow: 0 0 20px rgba(68, 255, 68, 0.5);
}

/* Невалидная drop-зона (нельзя сбросить) */
.drag-over-invalid {
    background: rgba(255, 68, 68, 0.1) !important;
    transform: scale(0.98);
}

.drag-over-invalid::after {
    border-color: #ff4444 !important;
    border-style: solid !important;
    border-width: 3px !important;
    animation: none !important;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
}

/* Анимация feedback */
@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}
