/**
 * D&D AI RPG - Combat System Styles
 * Turn-based D&D 5e combat visual presentation
 */

/* ============================================================================
   COMBAT PANEL
   ============================================================================ */

.combat-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.combat-panel.hidden {
    display: none;
}

/* ============================================================================
   COMBAT HEADER
   ============================================================================ */

.combat-header {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #a93226;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.combat-header h2 {
    color: white;
    margin: 0;
    font-size: 28px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.combat-round {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 10px;
    color: white;
    font-size: 18px;
    font-weight: bold;
}

/* ============================================================================
   INITIATIVE TRACKER
   ============================================================================ */

.initiative-tracker {
    background: rgba(0, 0, 0, 0.4);
    padding: 15px 20px;
    border-bottom: 2px solid #34495e;
}

.initiative-tracker h3 {
    color: #3498db;
    margin: 0 0 10px 0;
    font-size: 16px;
}

.initiative-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
}

.initiative-entry {
    background: rgba(52, 73, 94, 0.6);
    border: 2px solid #34495e;
    border-radius: 8px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 150px;
    transition: all 0.3s;
}

.initiative-entry.active {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    border-color: #f39c12;
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.6);
    transform: scale(1.1);
}

.initiative-entry.player {
    border-color: #3498db;
}

.init-number {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.init-name {
    color: white;
    font-size: 14px;
    font-weight: bold;
    flex: 1;
}

.init-arrow {
    color: #f39c12;
    font-size: 20px;
    animation: arrowPulse 1s infinite;
}

@keyframes arrowPulse {
    0%, 100% { transform: translateX(0); opacity: 1; }
    50% { transform: translateX(5px); opacity: 0.7; }
}

/* ============================================================================
   COMBAT ARENA
   ============================================================================ */

.combat-arena {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 40px;
    background: radial-gradient(circle at center, rgba(52, 73, 94, 0.3) 0%, rgba(0, 0, 0, 0.5) 100%);
    position: relative;
}

.combat-arena::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="50" cy="50" r="1" fill="rgba(255,255,255,0.1)"/></svg>');
    opacity: 0.3;
    pointer-events: none;
}

/* ============================================================================
   COMBATANT CARDS
   ============================================================================ */

.combatant-card {
    background: linear-gradient(135deg, rgba(44, 62, 80, 0.9) 0%, rgba(52, 73, 94, 0.9) 100%);
    border: 3px solid #34495e;
    border-radius: 15px;
    padding: 20px;
    min-width: 250px;
    max-width: 300px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    position: relative;
    z-index: 1;
}

.player-card {
    border-color: #3498db;
    box-shadow: 0 10px 40px rgba(52, 152, 219, 0.4);
}

.enemy-card {
    border-color: #e74c3c;
    box-shadow: 0 10px 40px rgba(231, 76, 60, 0.4);
}

.enemy-card.dead {
    opacity: 0.5;
    filter: grayscale(1);
}

.combatant-portrait {
    width: 100px;
    height: 100px;
    margin: 0 auto 15px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.1), rgba(0,0,0,0.3));
    border: 3px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

.player-card .combatant-portrait {
    border-color: #3498db;
}

.enemy-card .combatant-portrait {
    border-color: #e74c3c;
}

.portrait-icon {
    font-size: 60px;
}

.combatant-info {
    text-align: center;
    margin-bottom: 15px;
}

.combatant-name {
    font-size: 20px;
    font-weight: bold;
    color: white;
    margin-bottom: 5px;
}

.combatant-class,
.combatant-type {
    font-size: 14px;
    color: #95a5a6;
}

.health-bar-container {
    margin-bottom: 10px;
}

.health-bar {
    background: rgba(0, 0, 0, 0.5);
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 5px;
}

.health-fill {
    height: 100%;
    transition: width 0.5s ease-out;
    background: linear-gradient(90deg, #2ecc71, #27ae60);
}

.enemy-health {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.health-text {
    text-align: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.dead-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    border: 2px solid #e74c3c;
}

/* ============================================================================
   VS INDICATOR
   ============================================================================ */

.vs-indicator {
    font-size: 48px;
    color: #f39c12;
    text-shadow: 0 0 20px rgba(243, 156, 18, 0.8);
    animation: vsGlow 2s infinite;
    z-index: 0;
}

@keyframes vsGlow {
    0%, 100% { text-shadow: 0 0 20px rgba(243, 156, 18, 0.8); }
    50% { text-shadow: 0 0 40px rgba(243, 156, 18, 1); }
}

/* ============================================================================
   ENEMIES CONTAINER
   ============================================================================ */

.enemies-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ============================================================================
   COMBAT ACTIONS
   ============================================================================ */

.combat-actions {
    background: rgba(0, 0, 0, 0.4);
    padding: 20px 40px;
    border-top: 2px solid #34495e;
}

.combat-actions h3 {
    color: #f39c12;
    margin: 0 0 15px 0;
    font-size: 18px;
    text-align: center;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    max-width: 1000px;
    margin: 0 auto;
}

.combat-action-btn {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.3), rgba(41, 128, 185, 0.3));
    border: 2px solid #3498db;
    border-radius: 10px;
    padding: 15px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.combat-action-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.5), rgba(41, 128, 185, 0.5));
    border-color: #5dade2;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.4);
}

.combat-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.combat-action-btn.attack {
    border-color: #e74c3c;
}

.combat-action-btn.attack:hover:not(:disabled) {
    border-color: #ec7063;
}

.combat-action-btn.defend {
    border-color: #3498db;
}

.combat-action-btn.spell {
    border-color: #9b59b6;
}

.combat-action-btn.special {
    border-color: #f39c12;
}

.combat-action-btn.item {
    border-color: #2ecc71;
}

.combat-action-btn.flee {
    border-color: #95a5a6;
}

.action-icon {
    font-size: 32px;
}

.action-name {
    font-size: 16px;
    font-weight: bold;
}

.action-description {
    font-size: 11px;
    color: #bdc3c7;
    text-align: center;
}

/* ============================================================================
   COMBAT LOG
   ============================================================================ */

.combat-log-container {
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 20px;
    max-height: 150px;
    overflow-y: hidden;
}

.combat-log-container h3 {
    color: #95a5a6;
    margin: 0 0 10px 0;
    font-size: 14px;
}

.combat-log {
    max-height: 100px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.log-entry {
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 13px;
    line-height: 1.4;
    animation: logFadeIn 0.3s;
}

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

.log-system {
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
    border-left: 3px solid #3498db;
}

.log-player-turn {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border-left: 3px solid #2ecc71;
    font-weight: bold;
}

.log-enemy-turn {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border-left: 3px solid #e74c3c;
}

.log-player-attack {
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
}

.log-enemy-attack {
    background: rgba(231, 76, 60, 0.2);
    color: #ec7063;
}

.log-critical {
    background: rgba(243, 156, 18, 0.3);
    color: #f39c12;
    font-weight: bold;
    border-left: 3px solid #f39c12;
}

.log-miss {
    background: rgba(149, 165, 166, 0.2);
    color: #95a5a6;
}

.log-spell {
    background: rgba(155, 89, 182, 0.2);
    color: #9b59b6;
    border-left: 3px solid #9b59b6;
}

.log-defend {
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
}

.log-flee {
    background: rgba(149, 165, 166, 0.2);
    color: #95a5a6;
}

.log-flee-failed {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.log-victory {
    background: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
    font-weight: bold;
    font-size: 16px;
    border: 2px solid #2ecc71;
}

.log-defeat {
    background: rgba(231, 76, 60, 0.3);
    color: #e74c3c;
    font-weight: bold;
    font-size: 16px;
    border: 2px solid #e74c3c;
}

.log-enemy-death {
    background: rgba(149, 165, 166, 0.2);
    color: #ecf0f1;
    font-weight: bold;
}

.log-reward {
    background: rgba(243, 156, 18, 0.2);
    color: #f39c12;
    font-weight: bold;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 1024px) {
    .combat-arena {
        flex-direction: column;
        gap: 20px;
    }

    .vs-indicator {
        transform: rotate(90deg);
    }

    .action-buttons {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

@media (max-width: 768px) {
    .combat-header {
        flex-direction: column;
        gap: 10px;
    }

    .initiative-list {
        flex-wrap: wrap;
    }

    .combatant-card {
        min-width: 200px;
        max-width: 250px;
    }

    .action-buttons {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================================================
   DEATH SAVES
   ============================================================================ */

.death-saves-container {
    margin-top: 15px;
    padding: 10px;
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.3), rgba(192, 57, 43, 0.3));
    border: 2px solid #e74c3c;
    border-radius: 8px;
    animation: deathSavesPulse 2s infinite;
}

.death-saves-container.hidden {
    display: none;
}

@keyframes deathSavesPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(231, 76, 60, 0.5); }
    50% { box-shadow: 0 0 25px rgba(231, 76, 60, 0.8); }
}

.death-saves-title {
    color: #e74c3c;
    font-weight: bold;
    font-size: 12px;
    text-align: center;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.death-saves-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 5px 0;
    font-size: 12px;
}

.death-save-label {
    color: #bdc3c7;
}

.death-save-marks {
    font-size: 16px;
    letter-spacing: 5px;
    color: #2ecc71;
}

.death-save-marks.failure {
    color: #e74c3c;
}

/* Death save log entries */
.log-death-save {
    background: rgba(155, 89, 182, 0.2);
    color: #9b59b6;
    border-left: 3px solid #9b59b6;
}

.log-critical-success {
    background: rgba(46, 204, 113, 0.4);
    color: #2ecc71;
    font-weight: bold;
    font-size: 14px;
    border: 2px solid #2ecc71;
    animation: successGlow 0.5s;
}

@keyframes successGlow {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 20px rgba(46, 204, 113, 0.8); }
}

.log-critical-fail {
    background: rgba(231, 76, 60, 0.4);
    color: #e74c3c;
    font-weight: bold;
    border: 2px solid #e74c3c;
    animation: failShake 0.5s;
}

@keyframes failShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.log-success {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
}

.log-failure {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.log-stabilized {
    background: rgba(52, 152, 219, 0.3);
    color: #3498db;
    font-weight: bold;
    border-left: 3px solid #3498db;
}

.log-death {
    background: rgba(0, 0, 0, 0.8);
    color: #e74c3c;
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    border: 3px solid #e74c3c;
    padding: 15px;
    animation: deathFade 2s;
}

@keyframes deathFade {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

.log-levelup {
    background: linear-gradient(90deg, rgba(155, 89, 182, 0.3), rgba(243, 156, 18, 0.3));
    color: #ffd700;
    font-weight: bold;
    font-size: 14px;
    border: 2px solid #ffd700;
    text-align: center;
    animation: levelUpGlow 1s infinite;
}

@keyframes levelUpGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
    50% { box-shadow: 0 0 25px rgba(255, 215, 0, 0.8); }
}

/* ============================================================================
   STATUS EFFECTS
   ============================================================================ */

.status-effects {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    margin-top: 10px;
    min-height: 28px;
}

.status-effect-icon {
    position: relative;
    font-size: 20px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: help;
    transition: transform 0.2s, box-shadow 0.2s;
}

.status-effect-icon:hover {
    transform: scale(1.2);
    z-index: 10;
}

/* Effect type colors */
.status-effect-icon.buff {
    background: rgba(46, 204, 113, 0.3);
    border: 2px solid #2ecc71;
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
}

.status-effect-icon.debuff {
    background: rgba(231, 76, 60, 0.3);
    border: 2px solid #e74c3c;
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.5);
}

.status-effect-icon.dot {
    background: rgba(230, 126, 34, 0.3);
    border: 2px solid #e67e22;
    box-shadow: 0 0 8px rgba(230, 126, 34, 0.5);
    animation: dotPulse 1.5s infinite;
}

.status-effect-icon.hot {
    background: rgba(26, 188, 156, 0.3);
    border: 2px solid #1abc9c;
    box-shadow: 0 0 8px rgba(26, 188, 156, 0.5);
    animation: hotPulse 2s infinite;
}

.status-effect-icon.special {
    background: rgba(155, 89, 182, 0.3);
    border: 2px solid #9b59b6;
    box-shadow: 0 0 8px rgba(155, 89, 182, 0.5);
}

@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(230, 126, 34, 0.5); }
    50% { box-shadow: 0 0 15px rgba(230, 126, 34, 0.8); }
}

@keyframes hotPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(26, 188, 156, 0.5); }
    50% { box-shadow: 0 0 15px rgba(26, 188, 156, 0.8); }
}

/* Duration indicator */
.effect-duration {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 10px;
    min-width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* DOT/HOT log entries */
.log-dot-damage {
    background: rgba(230, 126, 34, 0.2);
    color: #e67e22;
    border-left: 3px solid #e67e22;
}

.log-hot-heal {
    background: rgba(26, 188, 156, 0.2);
    color: #1abc9c;
    border-left: 3px solid #1abc9c;
}

.log-effect-expire {
    background: rgba(149, 165, 166, 0.2);
    color: #95a5a6;
    font-style: italic;
}

/* ============================================================================
   SPELL SELECTION UI
   ============================================================================ */

.spell-selection-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.spell-slots-display {
    background: rgba(155, 89, 182, 0.2);
    border: 2px solid #9b59b6;
    border-radius: 8px;
    padding: 10px 15px;
}

.slots-title {
    color: #9b59b6;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.slots-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.slot-level {
    display: flex;
    gap: 5px;
    align-items: center;
}

.slot-label {
    color: #bdc3c7;
    font-size: 12px;
}

.slot-count {
    background: rgba(0, 0, 0, 0.3);
    color: #9b59b6;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
}

.spell-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.spell-option {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.3), rgba(142, 68, 173, 0.3));
    border: 2px solid #9b59b6;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    color: white;
}

.spell-option:hover {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.5), rgba(142, 68, 173, 0.5));
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(155, 89, 182, 0.4);
}

.spell-option.cantrip {
    border-color: #1abc9c;
    background: linear-gradient(135deg, rgba(26, 188, 156, 0.3), rgba(22, 160, 133, 0.3));
}

.spell-option.cantrip:hover {
    background: linear-gradient(135deg, rgba(26, 188, 156, 0.5), rgba(22, 160, 133, 0.5));
    box-shadow: 0 5px 15px rgba(26, 188, 156, 0.4);
}

.spell-name {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 5px;
}

.spell-level {
    font-size: 11px;
    color: #bdc3c7;
    margin-bottom: 3px;
}

.spell-school {
    font-size: 10px;
    color: #95a5a6;
    text-transform: capitalize;
}

/* ============================================================================
   CLASS ABILITIES UI
   ============================================================================ */

.ability-selection-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.resources-display {
    display: flex;
    gap: 20px;
    background: rgba(243, 156, 18, 0.2);
    border: 2px solid #f39c12;
    border-radius: 8px;
    padding: 10px 15px;
    flex-wrap: wrap;
}

.resource-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.resource-icon {
    font-size: 18px;
}

.resource-name {
    color: #bdc3c7;
    font-size: 12px;
}

.resource-count {
    background: rgba(0, 0, 0, 0.3);
    color: #f39c12;
    padding: 2px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 14px;
}

.ability-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.ability-option {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.3), rgba(230, 126, 34, 0.3));
    border: 2px solid #f39c12;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.ability-option:hover:not(.disabled) {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.5), rgba(230, 126, 34, 0.5));
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(243, 156, 18, 0.4);
}

.ability-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #7f8c8d;
}

.ability-icon {
    font-size: 24px;
}

.ability-name {
    font-weight: bold;
    font-size: 13px;
}

.ability-action {
    font-size: 10px;
    color: #bdc3c7;
    text-transform: capitalize;
}

.ability-reason {
    font-size: 9px;
    color: #e74c3c;
    margin-top: 3px;
}

/* Special combat log entry */
.log-special {
    background: rgba(243, 156, 18, 0.2);
    color: #f39c12;
    border-left: 3px solid #f39c12;
}
