/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Orbitron', monospace;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
    color: #fff;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1920px;
    margin: 0 auto;
}

/* Header Styles */
.header {
    background: linear-gradient(90deg, #0f3460 0%, #16537e 100%);
    padding: 1rem 2rem;
    border-bottom: 3px solid #e94560;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.3);
    position: relative;
    z-index: 100;
}

.title {
    font-size: 2rem;
    font-weight: 900;
    color: #e94560;
    text-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
    letter-spacing: 3px;
}

.controls {
    display: flex;
    gap: 1rem;
}

/* Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(45deg, #e94560, #f27121);
    color: white;
}

.btn-secondary {
    background: linear-gradient(45deg, #16537e, #0f3460);
    color: white;
}

.btn-danger {
    background: linear-gradient(45deg, #dc2626, #991b1b);
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* Main Content Area */
.main-content {
    display: flex;
    flex: 1;
    height: calc(100vh - 80px);
    position: relative;
    /* transition: width 0.3s ease; */
}

.sidebar-toggle-btn {
    position: absolute;
    top: 50%;
    left: 240px; /* Initial position */
    transform: translateY(-50%);
    width: 25px;
    height: 50px;
    background-color: #e94560;
    border: none;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    cursor: pointer;
    z-index: 1500;
    transition: left 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn .arrow-icon {
    border: solid white;
    border-width: 0 3px 3px 0;
    display: inline-block;
    padding: 3px;
    transform: rotate(135deg); /* Pointing left */
    transition: transform 0.3s ease;
}

.hero-panel.collapsed + .sidebar-toggle-btn .arrow-icon {
    transform: rotate(-45deg); /* Pointing right */
}

/* Sidebar */
.hero-panel {
    width: 240px;
    background: linear-gradient(180deg, #16213e 0%, #0a0a0a 100%);
    border-right: 2px solid #e94560;
    display: flex;
    flex-direction: column;
    position: relative; /* Changed from fixed */
    z-index: 50;
    box-shadow: 4px 0 20px rgba(233, 69, 96, 0.3);
    transition: margin-left 0.3s ease;
    margin-left: 0;
}

.hero-panel.collapsed {
    margin-left: -240px;
}

/* Map Container */
.map-container {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0a0a0a 100%);
    overflow: hidden;
    height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.3s ease;
}

.map-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.map-area {
    position: relative;
    width: 900px; /* Fixed size for consistent layout */
    height: 900px; /* Square aspect ratio for Dota 2 map */
    max-width: min(calc((100vh - 200px) * 1), calc(100vw - 380px));
    max-height: calc(100vh - 200px);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(233, 69, 96, 0.3);
    margin: auto; /* Center within map container */
    flex-shrink: 0; /* Prevent shrinking */
}

.map-image {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Changed from 'cover' to prevent cropping */
    user-select: none;
    pointer-events: none;
}

.formation-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: all;
    transition: all 0.2s ease;
}

.placed-hero {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid #00ff00;
    cursor: grab;
    transition: transform 0.1s ease;
    pointer-events: all;
    background: rgba(0, 255, 0, 0.3);
    backdrop-filter: blur(2px);
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.9), 0 0 30px rgba(0, 255, 0, 0.5);
    overflow: hidden;
    transform: translate(-50%, -50%);
    opacity: 1 !important;
    z-index: 100;
}

.placed-hero:hover {
    transform: translate(-50%, -50%) scale(1.2);
    border-color: #00ff88;
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.8);
    opacity: 1 !important;
}

.placed-hero:active {
    cursor: grabbing;
    opacity: 1 !important;
}

.placed-hero.sticky-mode {
    cursor: grabbing !important;
    transition: none !important;
    pointer-events: none !important;
}

.placed-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    opacity: 1 !important;
}

.placed-hero .hero-label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #00ff00;
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
    font-size: 0.45rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid #00ff00;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.placed-hero:hover .hero-label {
    opacity: 1;
}

/* When drawing is active, make placed heroes non-interactive */
.map-area.drawing-active .placed-hero {
    pointer-events: none;
}

/* Drawing Canvas */
.drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.drawing-canvas.drawing-mode {
    pointer-events: all;
    cursor: crosshair;
}

.drawing-canvas.erasing-mode {
    pointer-events: all;
    cursor: grab;
}

/* Drawing Controls */
.drawing-controls {
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    padding: 0.5rem;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    border: 1px solid #00ff00;
    z-index: 20; /* Ensure controls are above the canvas */
}

.drawing-controls button {
    padding: 0.5rem;
    border: none;
    border-radius: 4px;
    background: rgba(0, 255, 0, 0.2);
    color: #00ff00;
    font-family: 'Orbitron', monospace;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #00ff00;
}

.drawing-controls button:hover {
    background: rgba(0, 255, 0, 0.4);
    transform: scale(1.05);
}

.drawing-controls button.active {
    background: #e94560; /* Use a consistent accent color for active mode */
    color: #fff;
    box-shadow: 0 0 10px #e94560;
}

.color-palette {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.color-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-btn:hover {
    transform: scale(1.15);
}

.color-btn.active {
    transform: scale(1.25);
    border-width: 3px;
    box-shadow: 0 0 12px 2px rgba(255, 255, 255, 0.8);
}

/* Drop Zone Indicator */
.drop-zone-outside {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 0, 0, 0.1);
    border: 3px dashed #ff0000;
    display: none;
    z-index: 1000;
    pointer-events: none;
}

.drop-zone-outside.active {
    display: block;
}

.drop-zone-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff0000;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

/* Formation Info - Footer Overlay */
.formation-info {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 52, 96, 0.85);
    border-top: 2px solid #e94560;
    border-left: 2px solid #e94560;
    border-right: 2px solid #e94560;
    padding: 0.5rem 1.5rem;
    backdrop-filter: blur(8px);
    z-index: 100;
    height: auto;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.team-composition h4 {
    color: #e94560;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.composition-stats {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.stat {
    font-size: 0.8rem;
    font-weight: 700;
}

.stat span {
    color: #e94560;
}

/* Hero Tooltip */
.hero-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #e94560;
    border-radius: 8px;
    padding: 1rem;
    max-width: 250px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(10px);
}

.hero-tooltip.visible {
    opacity: 1;
}

.tooltip-name {
    color: #e94560;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.tooltip-role {
    color: #f27121;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.tooltip-description {
    font-size: 0.7rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
}

/* Drag and Drop States */
.drag-over {
    background: rgba(233, 69, 96, 0.15) !important;
    border: 2px dashed #e94560 !important;
    box-shadow: inset 0 0 20px rgba(233, 69, 96, 0.3) !important;
}

.dragging {
    opacity: 0.6;
    transform: rotate(3deg) scale(0.95);
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.4);
}

/* Responsive Design */
@media (max-width: 1024px) {
    body {
        overflow: hidden; /* Prevent body from scrolling */
    }

    /* Hide desktop controls on mobile */
    .header .controls,
    .sidebar-toggle-btn,
    .formation-info {
        display: none;
    }

    /* Make the hero panel compact and contain the horizontally-scrolling grid */
    .hero-panel {
        position: relative;
        width: 100%;
        height: auto;
        flex-shrink: 0;
        top: auto;
        bottom: auto;
        left: auto;
        border-right: none;
        border-bottom: 2px solid #e94560;
        display: flex;
        flex-direction: column;
        padding: 0.5rem;
        overflow: hidden;
        gap: 0.5rem;
    }

    /* Hide category filters and title on mobile */
    .hero-panel h3,
    .hero-categories {
        display: none !important;
    }

    .search-container {
        margin: 0;
        flex-shrink: 0;
        height: 36px;
    }

    .search-input {
        padding: 0.5rem;
        font-size: 0.9rem;
        height: 36px;
    }

    .map-container {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        flex: 1;
        min-height: 0; /* Allow map to shrink and fit */
        height: auto;
        align-items: flex-start; /* Align to top instead of center */
    }

    .map-wrapper {
        padding: 0.5rem; /* Reduce padding on mobile */
        align-items: flex-start; /* Align to top instead of center */
        justify-content: flex-start; /* Align to top */
    }

    .map-area {
        width: 100%;
        height: 100%;
        aspect-ratio: 1 / 1;
        max-width: 100vw;
        max-height: calc(100vh - 160px); /* Adjusted for tighter fit */
    }

    .main-content {
        flex-direction: column;
        height: calc(100vh - 45px); /* Smaller header on mobile */
        overflow: hidden;
    }

    /* Style the hero grid for horizontal scrolling with one row */
    .hero-grid {
        display: flex;
        flex-direction: row;
        overflow-y: hidden;
        overflow-x: auto;
        gap: 0.5rem;
        padding: 0;
        height: 90px;
        align-items: flex-start;
        -webkit-overflow-scrolling: touch;
    }

    .hero-item {
        width: 80px;
        height: 90px;
        flex-shrink: 0;
    }

    /* Reposition drawing controls for mobile */
    .drawing-controls {
        top: auto;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
        width: auto;
    }

    .drawing-controls .color-palette {
        margin-top: 0;
        margin-left: 0.5rem;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: row;
        gap: 0.5rem;
        text-align: center;
        padding: 0.5rem 1rem;
        justify-content: center;
    }

    .title {
        font-size: 1rem;
        letter-spacing: 1px;
    }

    .controls {
        justify-content: center;
        flex-wrap: wrap;
    }

    .composition-stats {
        gap: 1rem;
    }
}

/* Scrollbar Styling for hero panel */
.hero-panel::-webkit-scrollbar,
.hero-grid::-webkit-scrollbar {
    width: 8px;
}

.hero-panel::-webkit-scrollbar-track,
.hero-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.hero-panel::-webkit-scrollbar-thumb,
.hero-grid::-webkit-scrollbar-thumb {
    background: #e94560;
    border-radius: 4px;
}

.hero-panel::-webkit-scrollbar-thumb:hover,
.hero-grid::-webkit-scrollbar-thumb:hover {
    background: #f27121;
} 

/* Hero Panel Styles */
.hero-panel {
    padding: 1rem; /* Reduced padding */
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.hero-panel h3 {
    color: #e94560;
    margin-bottom: 0.8rem; /* Slightly reduced */
    font-size: 1.1rem;
    text-align: center;
}

.hero-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem; /* Reduced gap */
    margin-bottom: 0.8rem;
}

.category-btn {
    padding: 0.4rem 0.6rem; /* Reduced padding */
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem; /* Slightly smaller */
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    text-align: center;
}

.category-btn:hover, .category-btn.active {
    background: #e94560;
    border-color: #e94560;
    transform: scale(1.05);
}

.search-container {
    margin-bottom: 1rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    font-family: 'Orbitron', monospace;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

/* Desktop hero grid - only apply on larger screens */
@media (min-width: 1025px) {
    .hero-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
        max-height: calc(100vh - 400px);
        overflow-y: auto;
        padding-right: 0.5rem;
    }
}

.hero-item {
    width: 90px; /* Slightly larger to fill space better */
    height: 90px;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    user-select: none;
}

.hero-item:hover {
    transform: scale(1.1);
    border-color: #e94560;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
}

.hero-item:active {
    cursor: grabbing;
}

.hero-item.dragging {
    opacity: 0.6;
    transform: rotate(3deg) scale(0.95);
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.4);
    z-index: 1000;
}

.hero-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.hero-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    font-size: 0.55rem;
    text-align: center;
    padding: 0.2rem;
    font-weight: 700;
} 

/* Save Modal Styles */
.save-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.save-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.save-modal-content {
    background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
    padding: 2rem;
    border-radius: 12px;
    border: 2px solid #e94560;
    box-shadow: 0 20px 60px rgba(233, 69, 96, 0.4);
    min-width: 400px;
    max-width: 500px;
}

.save-modal-content h3 {
    color: #e94560;
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
}

.save-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.save-form label {
    color: #fff;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.save-form input {
    padding: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-family: 'Orbitron', monospace;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.save-form input:focus {
    outline: none;
    border-color: #e94560;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.3);
}

.save-form input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.save-modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.save-modal-buttons .btn {
    flex: 1;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
} 