/* public/styles/modals/modalArena.css */

/* Define root variables for consistency with other modals */
:root {
    --arena-primary-font: 'Roboto Mono', monospace;
    --arena-accent-font: 'Press Start 2P', cursive;
    --arena-glow-color: #00FFDC; /* Standard cyan glow */
    --arena-text-primary: #E0F0FF;
    --arena-text-secondary: #A0C0E0;
    --arena-victory-color: #50C878; /* Bright Green from event modal */
    --arena-defeat-color: #FF6B6B; /* Reddish Pink from event modal */
    --arena-draw-color: #FFD43B; /* Yellow from event modal */
}

/* Modal container/backdrop */
.arena-modal {
    display: flex; /* Use flex for centering */
    position: fixed;
    z-index: 1001; 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(6px);
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}

.arena-modal.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease;
}

/* Modal content box */
.arena-modal-content {
    background: linear-gradient(145deg, rgba(10, 25, 40, 0.97), rgba(20, 35, 55, 0.97));
    margin: auto;
    padding: 0;
    border: 1px solid rgba(0, 255, 220, 0.6);
    border-radius: 15px;
    width: 90%;
    max-width: 650px; /* Arena can be a bit wider for combat log */
    box-shadow: 0 10px 50px rgba(0, 255, 220, 0.7), 0 0 20px rgba(0,0,0,0.4);
    color: var(--arena-text-primary);
    font-family: var(--arena-primary-font);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 90vh;
}

/* Modal header */
.arena-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: rgba(13, 26, 38, 0.85); /* Dark, semi-transparent background */
    border-bottom: 1px solid var(--arena-glow-color, #4f9ec4);
}

.arena-modal-header h2 {
    margin: 0;
    color: #e0e0e0;
    font-family: 'Orbitron', sans-serif; /* Sci-fi font */
    font-size: 24px;
    letter-spacing: 2px;
    text-shadow: 0 0 5px var(--arena-glow-color, #4f9ec4);
}

.arena-modal-header-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Close Button */
.arena-modal-close-button {
    background: none;
    border: none;
    color: var(--arena-text-secondary, #a0c0d0);
    font-size: 2.2em;
    font-weight: bold;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    transition: color 0.2s ease, transform 0.2s ease;
}

.arena-modal-close-button:hover,
.arena-modal-close-button:focus {
    color: var(--arena-glow-color, #7ccee6);
    transform: scale(1.1);
}

/* Leaderboard button in header */
.arena-modal-leaderboard-button {
    background-color: rgba(160, 192, 224, 0.1);
    color: var(--arena-text-primary, #d4e0ec);
    border: 1px solid var(--arena-border-color, rgba(160, 192, 224, 0.5));
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.arena-modal-leaderboard-button:hover {
    background-color: rgba(170, 202, 234, 0.2);
    color: #ffffff;
    border-color: var(--arena-glow-color, #7ccee6);
    box-shadow: 0 0 8px rgba(124, 206, 230, 0.5);
}

/* Modal body */
.arena-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background-color: rgba(13, 26, 38, 0.9); /* Slightly more opaque for content readability */
}

/* Custom Scrollbar for body */
.arena-modal-body::-webkit-scrollbar {
    width: 8px;
}
.arena-modal-body::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}
.arena-modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 220, 0.5);
    border-radius: 4px;
}
.arena-modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 220, 0.8);
}

/* --- VERSUS Section --- */
.arena-versus-section {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0;
}

.arena-avatar-wrapper {
    position: relative;
    border-radius: 9999px;
    border: 2px solid rgba(0, 255, 220, 0.5);
    background-color: rgba(0,0,0,0.4);
    overflow: hidden; /* Ensures the flash doesn't spill if content scales */
    transition: transform 0.2s ease-in-out;
}

.arena-vs-text {
    font-family: var(--arena-accent-font);
    font-size: 2em;
    color: var(--arena-glow-color);
    text-shadow: 0 0 8px rgba(0, 255, 220, 0.7);
    transition: transform 0.2s ease-in-out;
}

.arena-versus-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 3px solid var(--arena-glow-color);
    box-shadow: 0 0 12px rgba(255, 100, 100, 0.5);
    object-fit: cover;
}

.arena-nickname {
    font-family: 'Press Start 2P', cursive;
    color: var(--arena-text-primary);
    font-size: 1em; /* Reverted to default size for desktop */
    text-shadow: 0 0 4px var(--arena-glow-color);
    margin-top: 10px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.arena-health-bar-container {
    width: 90%;
    max-width: 150px; /* Reverted to default size for desktop */
    background-color: rgba(0,0,0,0.5);
    border: 1px solid rgba(0, 255, 220, 0.3);
    border-radius: 4px;
    height: 20px;
    margin-top: 6px;
    position: relative;
    overflow: hidden;
}

.arena-health-bar {
    background: linear-gradient(90deg, #FF6B6B, #FF4747);
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease-in-out;
}

.arena-health-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8em;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px black;
}

/* NEW: Action Gauge Styles */
.arena-gauge-container {
    width: 90%;
    max-width: 150px; /* Matched with health bar for desktop consistency */
    background-color: rgba(0,0,0,0.5);
    border: 1px solid rgba(0, 255, 220, 0.3);
    border-radius: 4px;
    height: 12px;
    margin-top: 4px;
    position: relative;
    overflow: hidden;
}

.arena-gauge-bar {
    background: linear-gradient(90deg, #00BFFF, #00FFDC); /* Deep sky blue to turquoise */
    box-shadow: 0 0 8px rgba(0, 255, 220, 0.75);
    height: 100%;
    width: 0%; /* Start empty */
    border-radius: 3px;
    transition: width 0.1s linear; /* Smooth fill */
}

/* --- TABS Section --- */
.arena-tabs {
    display: flex;
    justify-content: center;
    border-bottom: 1px solid rgba(0, 255, 220, 0.4);
    margin-bottom: 10px;
}

.arena-tab-button {
    font-family: var(--arena-accent-font);
    background: none;
    border: none;
    color: var(--arena-text-secondary);
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1em;
    transition: color 0.3s, border-bottom 0.3s;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px; /* Overlap the container's border */
}

.arena-tab-button:hover {
    color: var(--arena-text-primary);
}

.arena-tab-button.active {
    color: var(--arena-glow-color);
    border-bottom: 3px solid var(--arena-glow-color);
}

.arena-tab-panels .arena-tab-panel {
    display: none;
}

.arena-tab-panels .arena-tab-panel.active {
    display: block;
}


/* --- STATS COMPARISON Panel --- */
.arena-stats-comparison {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 5px;
}

.stat-row {
    display: grid;
    grid-template-columns: 1fr auto 50px auto 1fr;
    align-items: center;
    gap: 10px;
    background-color: rgba(0,0,0,0.2);
    padding: 4px 8px;
    border-radius: 5px;
}

.stat-value {
    font-weight: bold;
    font-size: 1.1em;
}

.stat-value.player { text-align: right; color: var(--arena-text-primary); }
.stat-value.opponent { text-align: left; color: #FF6B6B; }

.stat-label {
    font-size: 0.9em;
    color: var(--arena-text-secondary);
    text-transform: uppercase;
}

.stat-icon-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    margin: 0 auto;
}

.stat-icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Icons using unicode characters for now */
.stat-icon.attack::before { content: '⚔️'; font-size: 20px; }
.stat-icon.hp::before { content: '❤️'; font-size: 20px; }
.stat-icon.defense::before { content: '🛡️'; font-size: 20px; }
.stat-icon.crit::before { content: '💥'; font-size: 20px; }
.stat-icon.dodge::before { content: '💨'; font-size: 20px; }
.stat-icon.speed::before { content: '⚡'; font-size: 20px; }
.stat-icon.elo::before { content: '⭐'; font-size: 20px; }


/* --- LOGS Panel --- */
#arena-combat-log-container {
    display: block; /* Always visible inside its tab */
}

#arena-combat-log-container h3.arena-log-title {
    font-family: var(--arena-accent-font);
    text-align: center;
    margin: 0 0 15px 0;
    font-size: 1.2em;
}

/* --- Original Card Styles (for reference/cleanup if needed) --- */
/* Keep .arena-container for basic padding and borders */
.arena-container {
    flex: 1;
    padding: 15px;
    background-color: transparent; /* Changed */
    border: none; /* Changed */
    border-radius: 8px;
    min-width: 0; /* Allow flex item to shrink below its content size */
}

.arena-profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: var(--arena-text-secondary);
    padding: 10px; /* Added padding */
    transition: transform 0.2s ease-in-out;
    width: 100%; /* Ensure card takes full width of its container */
}

.arena-profile-card h3 {
    display: none; /* No longer needed in the new design */
    text-align: center;
    letter-spacing: 1px;
    min-width: 250px;
}

.arena-profile-card p {
    display: none; /* No longer needed in the new design */
}

.arena-stats-grid {
    display: none; /* Replaced by stats comparison panel */
}

/* --- END NEW STYLES --- */

/* Main action button */
.arena-button {
    background-color: transparent; 
    border: 2px solid var(--arena-glow-color);
    color: var(--arena-glow-color);
    padding: 12px 20px; 
    font-family: var(--arena-accent-font);
    font-size: 0.9em;
    font-weight: normal;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
    border-radius: 5px;
    text-align: center;
    letter-spacing: 1px;
    min-width: 250px;
}

#arena-controls {
    text-align: center;
    padding: 5px 0 10px 0;
}

.arena-button:hover:not(:disabled) {
    background-color: var(--arena-glow-color);
    color: #0A1E32; 
}

.arena-button:disabled {
    background-color: #444;
    color: #888;
    cursor: not-allowed;
    border-color: #555;
}

/* Styles for energy cost in fight button */
.arena-button .arena-fight-cost {
  display: inline-flex;
  align-items: center;
  margin-left: 10px;
  font-size: 0.9em;
  opacity: 0.8;
}

.arena-button .energy-icon-inline {
  width: 16px;
  height: 16px;
  margin-left: 5px;
  vertical-align: middle;
}

/* Opponent info section - NO LONGER USED, replaced by versus section */
#arena-opponent-info {
   display: none;
}

.arena-opponent-avatar {
    /* This class is now used for the versus avatars, let's adjust */
    width: 100px;
    height: 100px;
    border-radius: 8px; /* Squared to match design */
    border: 3px solid var(--arena-glow-color);
    box-shadow: 0 0 15px rgba(0, 255, 220, 0.6);
}

/* Combat log section */
#arena-combat-log-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#arena-combat-log-container h3.arena-victory { color: var(--arena-victory-color); text-shadow: 0 0 8px var(--arena-victory-color); }
#arena-combat-log-container h3.arena-defeat { color: var(--arena-defeat-color); text-shadow: 0 0 8px var(--arena-defeat-color); }
#arena-combat-log-container h3.arena-draw { color: var(--arena-draw-color); text-shadow: 0 0 8px var(--arena-draw-color); }


#arena-combat-log {
    background-color: #0A1929;
    border: 1px solid rgba(0, 255, 220, 0.4);
    padding: 15px;
    height: 300px;
    overflow-y: scroll;
    font-family: var(--arena-primary-font);
    font-size: 0.9em;
    border-radius: 8px;
    color: var(--arena-text-secondary);
}

/* Custom Scrollbar for Combat Log */
#arena-combat-log::-webkit-scrollbar {
    width: 8px;
}
#arena-combat-log::-webkit-scrollbar-track {
    background: rgba(10, 25, 40, 0.8);
    border-radius: 4px;
}
#arena-combat-log::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 220, 0.5);
    border-radius: 4px;
}
#arena-combat-log::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 220, 0.8);
}

#arena-combat-log ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#arena-combat-log li {
    padding: 5px 2px;
    border-bottom: 1px solid rgba(0, 255, 220, 0.15);
    line-height: 1.5;
}

#arena-combat-log li:last-child {
    border-bottom: none;
}

/* Log entry coloring and styling */

/* We need to be more specific to override existing styles that might color all damage logs orange. */

#arena-combat-log ul li.log-entry-player {
    color: #45DDE5; /* Turquoise for player text by default */
}
#arena-combat-log ul li.log-entry-player strong {
    color: #8CF2F8; /* Lighter turquoise for player name */
}

#arena-combat-log ul li.log-entry-opponent {
    color: #E55353; /* Red for opponent text by default */
}
#arena-combat-log ul li.log-entry-opponent strong {
    color: #F88C8C; /* Lighter red for opponent name */
}

.arena-combat-log .log-entry-system {
    color: #a0b4c8;
    font-style: italic;
    opacity: 0.8;
}

.arena-combat-log .log-entry-crit {
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.arena-combat-log .log-entry-crit strong {
    color: #FFD700; /* Gold */
}

.arena-combat-log .log-entry-dodge {
    opacity: 0.7;
}

.arena-combat-log li strong {
    font-weight: 600;
}

/* Media queries for responsiveness */
@media (max-width: 768px) {
    .arena-modal-content {
        max-width: 95%;
        max-height: 85vh;
    }
    .arena-modal-header h2 {
        font-size: 1.2em;
    }
    .arena-modal-body {
        padding: 20px;
    }
    .arena-versus-avatar, .arena-opponent-avatar {
        width: 80px;
        height: 80px;
    }
    .stat-row {
        grid-template-columns: 1fr auto 40px auto 1fr;
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    .arena-modal-body {
        padding: 10px;
        gap: 10px;
    }
    .arena-versus-section {
        padding: 0;
    }
    .arena-nickname {
        font-size: 0.65em;
    }
    .arena-modal-header h2 {
        font-size: 1em;
    }
    .arena-tab-button {
        padding: 8px 12px;
        font-size: 0.9em;
    }
    .arena-button {
        font-size: 0.8em;
        min-width: initial;
        padding: 10px 15px;
    }
    .arena-versus-avatar, .arena-opponent-avatar {
        width: 60px;
        height: 60px;
    }
    .arena-health-bar-container {
        height: 16px;
        width: 100%; /* Occupy full width on mobile */
        max-width: 110px; /* Reduced for mobile */
    }
    .arena-gauge-container {
        width: 100%;
        max-width: 110px; /* Reduced for mobile */
    }
    .arena-health-text {
        font-size: 0.7em;
        display: none; /* Hide numerical HP on mobile */
    }
    #arena-combat-log-container h3.arena-log-title {
        font-size: 1em;
        margin-bottom: 10px;
    }
    #arena-combat-log {
        height: 120px;
        font-size: 0.8em;
    }
    #arena-combat-log::-webkit-scrollbar {
        width: 6px; /* Thinner scrollbar for mobile */
    }
    .arena-vs-text {
        font-size: 1.2em;
    }
    .stat-row {
        gap: 5px;
        grid-template-columns: 1fr auto 24px auto 1fr;
        font-size: 0.8em;
        padding: 2px 6px;
    }
    .stat-icon {
        width: 18px;
        height: 18px;
    }
    .stat-icon::before {
        font-size: 16px;
    }
    .stat-label {
        display: none; /* Hide labels on very small screens to save space */
    }
    .opponent-placeholder .placeholder-avatar {
        width: 60px;
        height: 60px;
        font-size: 2em;
    }
}

/* --- VISUAL FEEDBACK ANIMATIONS --- */

@keyframes hit-flash {
    from, to { border-color: rgba(0, 255, 220, 0.5); }
    50% { border-color: var(--arena-defeat-color); }
}

.animate-hit {
    animation: hit-flash 0.4s ease-out;
}

@keyframes crit-hit-flash {
    0%, 100% { 
        transform: scale(1);
        border-color: rgba(0, 255, 220, 0.5);
        box-shadow: none;
    }
    50% { 
        transform: scale(1.03);
        border-color: #FF4747; /* A more intense red */
        box-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
    }
}

.animate-crit {
    animation: crit-hit-flash 0.5s ease-in-out;
}

@keyframes dodge-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

.animate-dodge {
    animation: dodge-shake 0.35s ease-in-out;
}

/* NEW: Opponent placeholder styles */
.opponent-placeholder .placeholder-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 3px dashed rgba(0, 255, 220, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    color: rgba(0, 255, 220, 0.6);
    font-family: var(--arena-accent-font);
    background-color: rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.placeholder-avatar.searching {
    animation: spin 1.2s linear infinite;
    color: var(--arena-glow-color);
    border-style: solid;
    border-color: rgba(0, 255, 220, 0.8);
}

/* NEW: Placeholder searching animation */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
