/* Dark Mode Variables */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-gradient-start: #f8fafc;
  --bg-gradient-end: #f1f5f9;
  --text-primary: #000000;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-primary: #e2e8f0;
  --border-secondary: #cbd5e1;
  --accent-primary: #3b82f6;
  --accent-secondary: #1d4ed8;
  --shadow-light: rgba(0, 0, 0, 0.05);
  --shadow-medium: rgba(0, 0, 0, 0.08);
  --shadow-heavy: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-gradient-start: #0f172a;
  --bg-gradient-end: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-primary: #334155;
  --border-secondary: #475569;
  --accent-primary: #60a5fa;
  --accent-secondary: #3b82f6;
  --shadow-light: rgba(0, 0, 0, 0.3);
  --shadow-medium: rgba(0, 0, 0, 0.4);
  --shadow-heavy: rgba(0, 0, 0, 0.6);
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-primary);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-layout {
    display: flex;
    height: 100vh;
}

.dual-sidebar {
    display: flex;
    flex-shrink: 0;
    border-right: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    box-shadow: 2px 0 10px var(--shadow-light);
}

.history-sidebar {
    width: 300px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.target-sidebar {
    width: 250px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    transition: all 0.3s ease;
    z-index: 1001;
    box-shadow: 0 4px 15px var(--shadow-medium);
}

.theme-toggle:hover {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 6px 20px var(--shadow-heavy);
}

/* Sidebar Header Styles */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.sidebar-header h3 {
    margin: 0;
    color: var(--accent-primary);
    font-size: 1.1em;
    font-weight: 600;
}

.main-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
}

.container {
    max-width: none;
    margin: 0;
    padding: 0;
}

.header {
    text-align: center;
    margin-bottom: 32px;
    padding: 32px;
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: 0 4px 25px var(--shadow-medium);
    border: 1px solid var(--border-primary);
}

.header h1 {
    margin: 0;
    font-size: 2.5em;
    font-weight: 700;
    color: var(--text-primary);
}

[data-theme="dark"] .header h1 {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.battle-info {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    font-size: 1.1em;
    color: var(--text-secondary);
    font-weight: 500;
}

.battle-controls {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.end-battle-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1em;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.end-battle-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.end-battle-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.player-rankings {
    background-color: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px 32px;
    box-shadow: 0 4px 25px var(--shadow-medium);
    margin-top: 24px;
    border: 1px solid var(--border-primary);
}

.ranking-header {
    display: grid;
    grid-template-columns: 60px 1fr 200px;
    gap: 15px;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.ranking-header > div:last-child {
    text-align: right;
}

.player-bar {
    margin-bottom: 12px;
    position: relative;
    background-color: var(--bg-primary);
    border-radius: 12px;
    overflow: visible;
    height: 56px;
    transition: all 0.3s ease;
    border: 1px solid var(--border-primary);
}

.player-bar-content {
    display: grid;
    grid-template-columns: 60px 1fr 200px;
    gap: 15px;
    align-items: center;
    position: relative;
    z-index: 2;
    height: 100%;
    padding: 0 8px;
}

.player-bar:hover {
    transform: translateX(4px);
    box-shadow: 0 8px 25px var(--shadow-medium);
    border-color: var(--border-secondary);
}

.rank-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
}

.rank-number {
    background: linear-gradient(135deg, var(--text-muted), var(--text-secondary));
    color: #ffffff;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    font-weight: 700;
    box-shadow: 0 2px 8px var(--shadow-heavy);
}

.rank-1 { 
    background: linear-gradient(135deg, #fbbf24, #f59e0b); 
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.4);
}
.rank-2 { 
    background: linear-gradient(135deg, #94a3b8, #64748b); 
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(148, 163, 184, 0.4);
}
.rank-3 { 
    background: linear-gradient(135deg, #fb7185, #e11d48); 
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(251, 113, 133, 0.4);
}

.player-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transition: width 0.5s ease;
    border-radius: 12px;
    z-index: 1;
}

.player-bar-fill.top-player {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.player-bar-fill.high-dps {
    background: linear-gradient(90deg, #10b981, #059669);
}

.player-bar-fill.crit-master {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.player-name {
    font-weight: 600;
    font-size: 1em;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 16px;
    display: flex;
    align-items: center;
}

.stat-value {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-weight: 600;
    font-size: 0.95em;
    text-align: right;
    padding: 0 8px;
    color: var(--text-secondary);
}

.damage-value {
    color: var(--text-primary) !important;
}

.dps-value {
    color: var(--text-secondary);
}

.percentage-value {
    color: #f59e0b;
}

.connection-status {
    position: fixed;
    top: 64px;
    right: 64px;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    z-index: 1000;
    box-shadow: 0 4px 15px var(--shadow-medium);
}

.connected {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.disconnected {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.no-data {
    text-align: center;
    color: var(--text-muted);
    font-size: 1.2em;
    margin: 50px 0;
    font-weight: 500;
}

.updating {
    /* No animation - removed flashing effect */
}

.player-details {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-bar {
    cursor: pointer;
}

.player-bar:active {
    transform: translateX(2px);
}

.skill-breakdown {
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-top: 12px;
    padding: 20px;
    border-left: 4px solid var(--accent-primary);
    border: 1px solid var(--border-primary);
    display: none;
}

.skill-breakdown.show {
    display: block;
}

.skill-breakdown.show.animate {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
        padding-top: 20px;
        padding-bottom: 20px;
    }
}

.skill-breakdown-header {
    font-size: 1.1em;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--accent-primary);
}

.skill-item {
    margin-bottom: 10px;
    position: relative;
    background-color: var(--bg-primary);
    border-radius: 8px;
    overflow: visible;
    height: 36px;
    display: flex;
    align-items: center;
    border: 1px solid var(--border-primary);
}

.skill-item-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transition: width 0.3s ease;
    border-radius: 8px;
    position: relative;
}

.skill-item-fill.crit-heavy {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.skill-item-fill.top-skill {
    background: linear-gradient(90deg, #8b5cf6, #7c3aed);
}

.skill-item-info {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85em;
    font-weight: 600;
    z-index: 2;
    color: var(--text-primary);
    white-space: nowrap;
    max-width: calc(100% - 200px);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.skill-item-stats {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85em;
    font-weight: 600;
    color: #ffffff;
    z-index: 3;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 6px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.clear-filter-btn,
.clear-history-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.download-history-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.clear-filter-btn:hover,
.clear-history-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.download-history-btn:hover {
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.target-list,
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    overflow: visible;
    padding: 20px;
    padding-right: 12px;
    min-height: 0;
}

.target-list.scrollable,
.history-list {
    overflow-y: auto;
    overflow-x: hidden;
}

.target-item {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid var(--border-primary);
    box-shadow: 0 2px 8px var(--shadow-light);
}

.target-item:hover {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
    transform: translateX(4px);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.15);
}

.target-item.selected {
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    transform: translateX(6px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.target-name {
    font-weight: 600;
    font-size: 0.9em;
    margin-bottom: 6px;
    word-wrap: break-word;
    line-height: 1.3;
}

.target-damage {
    font-size: 0.8em;
    color: #f59e0b;
    font-weight: 700;
}

.target-item.selected .target-damage {
    color: #ffffff;
}

.no-targets,
.no-history {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9em;
    padding: 40px 20px;
    font-style: italic;
    font-weight: 500;
}

.filter-info {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 0.9em;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar,
.target-list::-webkit-scrollbar,
.history-list::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.target-list::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.target-list::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.target-list::-webkit-scrollbar-thumb:hover,
.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Battle History Styles */
.history-item {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid var(--border-primary);
    box-shadow: 0 2px 8px var(--shadow-light);
}

.history-item:hover {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
    transform: translateX(4px);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.15);
}

.history-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-time {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9em;
    white-space: nowrap;
    min-width: 0;
}

.history-duration {
    background: linear-gradient(135deg, var(--text-muted), var(--text-secondary));
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 600;
    box-shadow: 0 2px 6px var(--shadow-medium);
}

.history-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.history-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.8em;
    font-weight: 500;
}

.stat-value {
    color: #f59e0b;
    font-weight: 700;
    font-size: 0.8em;
}

.history-top-player {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(245, 158, 11, 0.1));
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 10px;
    color: #d97706;
    font-size: 0.8em;
    font-weight: 700;
    text-align: center;
}

/* Historical View Indicator Styles */
.historical-indicator {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    margin-top: 20px;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.historical-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.back-to-live-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.back-to-live-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Current Battle Item Styles */
.current-battle {
    border-color: #ef4444 !important;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(220, 38, 38, 0.1)) !important;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.2) !important;
}

.current-battle:hover {
    border-color: #dc2626 !important;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.15)) !important;
    transform: translateX(6px);
    box-shadow: 0 6px 25px rgba(239, 68, 68, 0.3) !important;
}

.current-battle-indicator {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8em;
    font-weight: 700;
    margin-bottom: 10px;
    text-align: center;
    animation: pulse 2s infinite;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

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

/* Dark theme specific adjustments */
[data-theme="dark"] .skill-item-info {
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .history-top-player {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.2));
    border-color: #fbbf24;
    color: #fbbf24;
}

[data-theme="dark"] .connection-status {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* Smooth transitions for theme switching */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

