/**
 * ACE PK Leaderboard Styles
 * Bootstrap 5 compatible with dark/light theme support
 */

/* ===== Theme Variables ===== */
:root {
    --pk-primary: var(--bs-danger);
    --pk-secondary: var(--bs-warning);
    --pk-success: var(--bs-success);
    --pk-card-bg: var(--bs-body-bg);
    --pk-text: var(--bs-body-color);
    --pk-text-muted: var(--bs-secondary-color);
    --pk-border: var(--bs-border-color);
}

[data-bs-theme="dark"] {
    --pk-card-bg: var(--bs-dark);
    --pk-hover-bg: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="light"] {
    --pk-card-bg: var(--bs-white);
    --pk-hover-bg: rgba(0, 0, 0, 0.02);
}

/* ===== Global Text Color (Theme Aware) ===== */
.content {
    color: var(--bs-body-color);
}

.content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
    color: var(--bs-body-color);
}

.content p, .content span, .content div {
    color: inherit;
}

/* Dark theme overrides */
[data-bs-theme="dark"] .content {
    color: var(--bs-light);
}

[data-bs-theme="dark"] .content h1,
[data-bs-theme="dark"] .content h2,
[data-bs-theme="dark"] .content h3,
[data-bs-theme="dark"] .content h4,
[data-bs-theme="dark"] .content h5,
[data-bs-theme="dark"] .content h6 {
    color: var(--bs-light);
}

/* ===== Hero Section ===== */
.pk-hero {
    padding: 2rem 0;
}

.pk-hero h1 {
    color: var(--bs-body-color);
}

.pk-hero .lead {
    color: var(--bs-secondary-color);
}

.pk-hero h1 i {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== Stat Cards ===== */
.stat-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: var(--pk-card-bg);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.stat-icon i {
    transition: transform 0.2s ease;
}

.stat-card:hover .stat-icon i {
    transform: scale(1.1);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: inherit;
}

/* Ensure stat-card headings are visible on both themes */
.stat-card h3,
.stat-card h4 {
    color: inherit;
}

/* Force proper text color in stat cards */
.stat-card .card-body {
    color: var(--bs-body-color, #212529);
}

[data-bs-theme="dark"] .stat-card .card-body {
    color: var(--bs-body-color, #dee2e6);
}

.stat-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== Stat Box (Character Profile) ===== */
.stat-box {
    transition: transform 0.2s ease;
}

.stat-box:hover {
    transform: translateY(-2px);
}

.stat-box h3, .stat-box h4, .stat-box h5 {
    margin-bottom: 0.25rem;
    color: var(--bs-body-color);
}

/* Ensure colored text classes override the default */
.stat-box .text-primary { color: var(--bs-primary) !important; }
.stat-box .text-secondary { color: var(--bs-secondary) !important; }
.stat-box .text-success { color: var(--bs-success) !important; }
.stat-box .text-danger { color: var(--bs-danger) !important; }
.stat-box .text-warning { color: var(--bs-warning) !important; }
.stat-box .text-info { color: var(--bs-info) !important; }

/* ===== Rank Badges ===== */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    background: var(--bs-secondary-bg);
    color: var(--pk-text);
}

.rank-badge.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: #000;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

.rank-badge.rank-2 {
    background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
    color: #000;
    box-shadow: 0 2px 8px rgba(192, 192, 192, 0.4);
}

.rank-badge.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #b87333);
    color: #fff;
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.4);
}

/* ===== Warrior Row ===== */
.warrior-row {
    transition: background-color 0.2s ease;
}

.warrior-row:hover {
    background-color: var(--pk-hover-bg);
}

.warrior-name {
    color: inherit;
    font-size: 1rem;
}

/* Ensure table text inherits theme colors */
.table {
    color: var(--bs-body-color);
}

.table td,
.table th {
    color: inherit;
}

/* ===== Table Styling ===== */
.table {
    --bs-table-bg: transparent;
}

.table thead th {
    border-bottom-width: 2px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: inherit;
    opacity: 0.7;
}

.table tbody tr {
    border-color: var(--pk-border);
}

/* ===== Cards ===== */
.card {
    background: var(--pk-card-bg);
    color: var(--bs-body-color);
}

.card-body {
    color: inherit;
}

/* ===== Form Labels ===== */
.form-label {
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .form-label {
    color: var(--bs-light);
}

/* ===== Character Avatar ===== */
.character-avatar {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-primary-bg-subtle);
    border-radius: 50%;
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 768px) {
    .pk-hero h1 {
        font-size: 1.75rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .rank-badge {
        min-width: 40px;
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

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

.warrior-row {
    animation: fadeIn 0.3s ease forwards;
}

.warrior-row:nth-child(1) { animation-delay: 0.05s; }
.warrior-row:nth-child(2) { animation-delay: 0.1s; }
.warrior-row:nth-child(3) { animation-delay: 0.15s; }
.warrior-row:nth-child(4) { animation-delay: 0.2s; }
.warrior-row:nth-child(5) { animation-delay: 0.25s; }
.warrior-row:nth-child(6) { animation-delay: 0.3s; }
.warrior-row:nth-child(7) { animation-delay: 0.35s; }
.warrior-row:nth-child(8) { animation-delay: 0.4s; }
.warrior-row:nth-child(9) { animation-delay: 0.45s; }
.warrior-row:nth-child(10) { animation-delay: 0.5s; }

/* ===== Online Status Badge ===== */
.badge.bg-success {
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(25, 135, 84, 0.5); }
    50% { box-shadow: 0 0 10px rgba(25, 135, 84, 0.8); }
}

/* ===== Kill Feed Styles ===== */
.pk-kill-feed {
    max-height: 400px;
    overflow-y: auto;
}

.pk-kill-feed-compact {
    max-height: 300px;
    overflow-y: auto;
}

.pk-kill-feed-full .kill-event-row {
    transition: background-color 0.2s ease;
}

.pk-kill-feed-full .kill-event-row:hover {
    background-color: var(--pk-hover-bg);
}

.kill-event {
    padding: 0.75rem;
    border-bottom: 1px solid var(--pk-border);
    transition: background-color 0.2s ease;
}

.kill-event:last-child {
    border-bottom: none;
}

.kill-event:hover {
    background-color: var(--pk-hover-bg);
}

.kill-event-new {
    animation: slideIn 0.3s ease;
}

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

.kill-event-compact {
    transition: background-color 0.2s ease;
}

.kill-event-compact:hover {
    background-color: var(--pk-hover-bg);
}

.kill-icon {
    font-size: 1.1rem;
}

.killer-link, .victim-link {
    text-decoration: none;
}

.killer-link:hover, .victim-link:hover {
    text-decoration: underline;
}

/* ===== Streak Widget Styles ===== */
.pk-streak-widget .streak-entry {
    padding: 0.5rem 0;
    transition: background-color 0.2s ease;
}

.streak-entry:hover {
    background-color: var(--pk-hover-bg);
}

.streak-entry-compact {
    transition: background-color 0.2s ease;
}

.streak-entry-compact:hover {
    background-color: var(--pk-hover-bg);
}

.streak-hot {
    background: linear-gradient(90deg, rgba(220, 53, 69, 0.1), transparent);
    border-left: 3px solid var(--bs-danger);
    padding-left: 0.75rem;
}

.streak-hot-badge {
    animation: pulse 1.5s ease-in-out infinite;
}

.streak-value {
    font-variant-numeric: tabular-nums;
}

/* ===== Rivalry Card Styles ===== */
.pk-rivalry-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pk-rivalry-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.rivalry-highlight {
    border: 2px solid var(--bs-warning);
}

.rivalry-player-large .character-avatar {
    background: var(--bs-primary-bg-subtle);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rivalry-vs-large .progress {
    border-radius: 0.5rem;
    overflow: hidden;
}

.rivalry-event {
    transition: background-color 0.2s ease;
}

.rivalry-mini, .rivalry-entry {
    transition: background-color 0.2s ease;
}

.rivalry-mini:hover, .rivalry-entry:hover {
    background-color: var(--pk-hover-bg);
}

/* ===== Activity Chart Styles ===== */
.pk-activity-chart {
    min-height: 250px;
}

.activity-bars {
    border-bottom: 2px solid var(--pk-border);
    padding-bottom: 0.5rem;
}

.activity-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.activity-bar {
    width: 80%;
    min-width: 20px;
    transition: height 0.5s ease, transform 0.2s ease;
    cursor: pointer;
}

.activity-bar:hover {
    transform: scaleX(1.1);
}

.activity-bar-value small {
    font-size: 0.7rem;
}

.activity-bar-label small {
    font-size: 0.65rem;
}

/* ===== Hotspot Styles ===== */
.hotspot-entry {
    transition: background-color 0.2s ease;
}

.hotspot-entry:hover {
    background-color: var(--pk-hover-bg);
}

/* ===== History Event Styles ===== */
.history-event {
    transition: background-color 0.2s ease;
}

.history-event:hover {
    background-color: var(--pk-hover-bg);
}

/* ===== Rival Entry Styles ===== */
.rival-entry {
    transition: background-color 0.2s ease;
}

.rival-entry:hover {
    background-color: var(--pk-hover-bg);
}

/* ===== Tab Styles ===== */
.nav-tabs .nav-link {
    color: var(--bs-body-color);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.75rem 1rem;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.nav-tabs .nav-link:hover {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

.nav-tabs .nav-link.active {
    background: transparent;
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

/* ===== Quick Navigation Buttons ===== */
.btn-outline-danger:hover i,
.btn-outline-warning:hover i,
.btn-outline-primary:hover i {
    animation: bounce 0.3s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* ===== Leaderboard Pills ===== */
.nav-pills .nav-link {
    transition: all 0.2s ease;
}

.nav-pills .nav-link:not(.active):hover {
    background: var(--pk-hover-bg);
}

/* ===== Responsive Adjustments for New Components ===== */
@media (max-width: 768px) {
    .pk-kill-feed, .pk-kill-feed-compact {
        max-height: 250px;
    }
    
    .activity-bar-wrapper {
        padding: 0 2px;
    }
    
    .activity-bar-label small {
        font-size: 0.55rem;
    }
    
    .rivalry-player-large h2 {
        font-size: 1.25rem;
    }
    
    .rivalry-vs-large .display-3 {
        font-size: 2rem;
    }
}
