/* Global Reset & Base Styles */
:root {
    --bg-primary: #0f1923; /* Valorant Dark Blue */
    --bg-secondary: #1f2731; /* Lighter Panel Background */
    --accent-red: #ff4655; /* Valorant Red */
    --accent-dark-red: #bd3944;
    --text-primary: #ece8e1; /* Off-white */
    --text-secondary: #768079; /* Gray */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --font-heading: 'Oswald', sans-serif;
    --font-body: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow-x: hidden;
    line-height: 1.6;
}

h1, h2, h3, h4, button {
    font-family: var(--font-heading);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    background: rgba(15, 25, 35, 0.95);
    border-bottom: 1px solid var(--accent-red);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-red);
    letter-spacing: 2px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    margin-left: 1rem;
    transition: color 0.3s, transform 0.2s;
}

.nav-btn:hover, .nav-btn.active {
    color: var(--text-primary);
    transform: translateY(-2px);
    text-shadow: 0 0 8px rgba(255, 70, 85, 0.5);
}

/* View Sections */
.view-section {
    padding: 2rem;
    flex: 1;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden {
    display: none !important;
}

/* Maps Grid */
#maps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2.5rem;
    padding: 2rem;
}

.map-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s, border-color 0.3s;
    border: 2px solid transparent;
}

.map-card:hover {
    transform: translateY(-15px) scale(1.05);
    box-shadow: 0 20px 40px rgba(255, 70, 85, 0.4), 0 0 30px rgba(255, 70, 85, 0.2);
    border-color: var(--accent-red);
    z-index: 10;
}

.map-card img {
    width: 100%;
    height: 240px;
    object-fit: cover;
    display: block;
    filter: brightness(0.75) contrast(1.1);
    transition: filter 0.4s, transform 0.4s;
}

.map-card:hover img {
    filter: brightness(1.2) contrast(1.2);
    transform: scale(1.1);
}

.map-card-name {
    padding: 1.25rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.9) 100%);
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

/* Home Screen */
.hero-section {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, 
        rgba(255, 70, 85, 0.1) 0%, 
        rgba(0, 0, 0, 0.3) 50%,
        rgba(255, 70, 85, 0.1) 100%);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 70, 85, 0.1) 0%, transparent 70%);
    animation: pulse 8s ease-in-out infinite;
}

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

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-family: 'Tungsten', sans-serif;
    font-size: 5rem;
    font-weight: 700;
    color: var(--accent-red);
    text-shadow: 0 0 20px rgba(255, 70, 85, 0.5);
    margin-bottom: 1rem;
    letter-spacing: 0.1em;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.hero-description {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.feature-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-red), transparent);
    transform: scaleX(0);
    transition: transform 0.3s;
}

.feature-card:hover::before {
    transform: scaleX(1);
}

.feature-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent-red);
    box-shadow: 0 12px 30px rgba(255, 70, 85, 0.3);
    background: linear-gradient(135deg, rgba(255, 70, 85, 0.1), rgba(255, 255, 255, 0.05));
}

.feature-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.feature-card h2 {
    font-family: 'Tungsten', sans-serif;
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

.feature-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.feature-btn {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
}

.feature-btn:hover {
    background: #e63946;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(255, 70, 85, 0.4);
}

/* Builder Layout */
.builder-layout {
    display: flex;
    gap: 2rem;
    height: calc(100vh - 120px); /* Adjust for header/padding */
}

.map-stage-container {
    flex: 2;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--glass-border);
    overflow-y: auto; /* Allow scrolling if content is tall */
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.map-header h2 {
    font-size: 2rem;
    color: var(--accent-red);
}

.comp-actions {
    display: flex;
    gap: 1rem;
}

input[type="text"], textarea {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: var(--font-body);
}

input[type="text"]:focus, textarea:focus {
    border-color: var(--accent-red);
    outline: none;
}

.primary-btn {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    transition: background 0.3s;
}

.primary-btn:hover {
    background: var(--accent-dark-red);
}

.icon-btn {
    background: none;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
}

.icon-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.map-visualizer {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    flex-grow: 1; /* Take available space */
    min-height: 400px;
    max-height: 600px;
    background: #000;
}

#map-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Fill entire space */
    opacity: 0.6;
}

.agent-slots-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 1rem;
    border-radius: 12px;
    backdrop-filter: blur(5px);
    border: 1px solid var(--glass-border);
}

.comp-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.comp-stats {
    display: flex;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    align-items: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: 'Tungsten', sans-serif;
    font-size: 1.5rem;
    color: var(--accent-red);
}

.comp-attributes {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    border: 1px solid var(--glass-border);
}

.attributes-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.attributes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.attribute-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 70, 85, 0.15);
    border: 1px solid var(--accent-red);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: 500;
}

.attribute-badge .count {
    background: var(--accent-red);
    color: white;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-weight: 700;
    font-size: 0.7rem;
}

.agent-slot {
    width: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: default;
    position: relative;
}

/* ---- Secondary (alt) pick box ---- */
.secondary-slot {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 2px dashed rgba(255, 255, 255, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.18s;
    flex-shrink: 0;
}

.secondary-slot:hover {
    border-color: rgba(255, 70, 85, 0.55);
    background: rgba(255, 70, 85, 0.08);
}

/* Targeted / awaiting pick */
.secondary-slot--active {
    border-color: var(--accent-red);
    border-style: solid;
    background: rgba(255, 70, 85, 0.12);
    box-shadow: 0 0 10px rgba(255, 70, 85, 0.25);
    animation: pulse-red 1.2s ease-in-out infinite;
}

@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 70, 85, 0.25); }
    50%       { box-shadow: 0 0 16px rgba(255, 70, 85, 0.5); }
}

/* Filled secondary slot */
.secondary-slot--filled {
    border-style: solid;
    border-color: rgba(255, 70, 85, 0.5);
}

.secondary-slot-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.secondary-slot-plus {
    font-size: 1.3rem;
    line-height: 1;
    color: rgba(255, 255, 255, 0.25);
    pointer-events: none;
    transition: color 0.18s;
}

.secondary-slot:hover .secondary-slot-plus {
    color: rgba(255, 70, 85, 0.7);
}

.secondary-slot--active .secondary-slot-plus {
    color: var(--accent-red);
}

/* ---- Primary (main) pick box ---- */
.primary-slot {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    flex-shrink: 0;
}

.primary-slot:hover {
    border-color: var(--accent-red);
    background: rgba(255, 70, 85, 0.1);
}

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

.agent-slot.filled .primary-slot {
    border-style: solid;
    border-color: var(--accent-red);
    box-shadow: 0 0 10px rgba(255, 70, 85, 0.3);
}


/* Agent Picker Sidebar */
.agent-picker-sidebar {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
    border: 1px solid var(--glass-border);
}

.role-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.role-filter {
    background: rgba(0,0,0,0.3);
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.role-filter:hover, .role-filter.active {
    background: var(--accent-red);
    color: white;
}

.agents-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Force 4 columns for consistency */
    grid-auto-rows: 160px; /* Ensure all rows are uniform based on card height */
    gap: 1.25rem; /* Spacious gap */
    overflow-y: auto;
    padding-right: 0.5rem; 
    padding-bottom: 2rem;
    align-content: start;
}

/* Responsive: 3 cols on tablet, 2 on mobile */
@media (max-width: 1200px) {
    .agents-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 768px) {
    .agents-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Toast Notification */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: linear-gradient(135deg, rgba(255, 70, 85, 0.95), rgba(255, 70, 85, 0.85));
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    min-width: 280px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideIn 0.3s ease-out;
}

.toast.success {
    background: linear-gradient(135deg, rgba(46, 213, 115, 0.95), rgba(39, 174, 96, 0.85));
}

.toast.error {
    background: linear-gradient(135deg, rgba(235, 77, 75, 0.95), rgba(214, 48, 49, 0.85));
}

.toast.info {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.95), rgba(41, 128, 185, 0.85));
}

.toast-icon {
    font-size: 1.5rem;
}

.toast.fade-out {
    animation: slideOut 0.3s ease-in forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}


/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
}
::-webkit-scrollbar-thumb {
    background: var(--accent-red);
    border-radius: 4px;
}

/* Agent Card in Picker */
.agent-card-picker {
    width: 100%;
    height: 160px; /* Fixed height to prevent squishing */
    /* aspect-ratio removed in favor of fixed height */
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.agent-card-picker:hover {
    transform: translateY(-5px);
    border-color: var(--accent-red);
    box-shadow: 0 8px 15px rgba(255, 70, 85, 0.4);
    z-index: 10;
}

.agent-card-picker img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.agent-card-picker:hover img {
    transform: scale(1.1);
}

.agent-card-name {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    color: white;
    text-align: center;
    padding: 0.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.agent-card-picker:hover .agent-card-name {
    transform: translateY(0);
}

.agent-card-picker[draggable="true"] {
    cursor: grab;
}

/* Strategy Notes */
.strat-notes {
    margin-top: 1rem;
}

.strat-notes textarea {
    width: 100%;
    min-height: 100px;
    resize: vertical;
}

/* Saved Comps List */
.comps-list {
    display: grid;
    gap: 1rem;
}

.saved-comp-card {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--accent-red);
}

.saved-comp-info h4 {
    color: var(--accent-red);
    margin-bottom: 0.25rem;
}

.saved-comp-slots {
    display: flex;
    gap: 0.5rem;
}

.mini-slot {
    width: 32px;
    height: 32px;
    background: #000;
    border-radius: 50%;
    overflow: hidden;
}

.mini-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Loading */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 50vh;
    color: var(--accent-red);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 70, 85, 0.3);
    border-top-color: var(--accent-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Responsive */
@media (max-width: 768px) {
    .builder-layout {
        flex-direction: column;
        height: auto;
    }
    
    .agent-picker-sidebar {
        max-height: 300px;
    }
    
    .map-visualizer {
        min-height: 250px;
    }
}

/* Authentication UI */
.login-btn {
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-weight: 700;
}

.login-btn:hover {
    background: white;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    color: var(--accent-red);
}

.user-display {
    margin: 0 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    padding-left: 1.5rem;
    border-left: 1px solid var(--glass-border);
}

.app-header nav {
    display: flex;
    align-items: center;
}
/* UI adjustments for spacing */
.nav-btn {
    margin-right: 0.5rem;
}
