/* RewardScope Dashboard Styles - Dark Theme with Sidebar */

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0f0f0f;
    color: #e0e0e0;
}

body {
    display: flex;
    overflow: hidden;
}

/* Sidebar Styles */
.sidebar {
    position: relative;
    width: 250px;
    flex-shrink: 0;
    background: #1a1a1a;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    transition: width 0.3s ease;
    z-index: 100;
}

.sidebar.collapsed {
    width: 50px;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: #999;
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-title {
    opacity: 0;
    pointer-events: none;
}

.mobile-close {
    display: none;
    background: none;
    border: none;
    color: #999;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

.mobile-close:hover {
    color: #e0e0e0;
}

.sidebar-search {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    transition: opacity 0.2s ease, padding 0.3s ease;
}

.sidebar.collapsed .sidebar-search {
    opacity: 0;
    padding: 0;
    height: 0;
    overflow: hidden;
}

.sidebar-search input {
    width: 100%;
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    color: #e0e0e0;
    font-size: 0.875rem;
}

.sidebar-search input:focus {
    outline: none;
    border-color: #4ade80;
}

.sidebar-search input::placeholder {
    color: #666;
}

.sidebar-runs {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-runs::-webkit-scrollbar {
    width: 6px;
}

.sidebar-runs::-webkit-scrollbar-track {
    background: #0f0f0f;
}

.sidebar-runs::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.sidebar-runs::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Run Cards */
.run-card {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #222;
    transition: background 0.2s ease;
    align-items: flex-start;
}

.run-card:hover {
    background: #222;
}

.run-card.active {
    background: #2a2a2a;
    border-left: 3px solid #4ade80;
}

.sidebar.collapsed .run-card {
    justify-content: center;
    padding: 0.75rem 0.5rem;
    border-left: none;
}

.run-indicator {
    display: flex;
    align-items: flex-start;
    padding-top: 0.25rem;
    flex-shrink: 0;
}

.run-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid #666;
    background: transparent;
    transition: all 0.2s ease;
}

.run-dot.active {
    background: #4ade80;
    border-color: #4ade80;
}

.run-info {
    flex: 1;
    min-width: 0;
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .run-info {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.run-name {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    font-weight: 500;
    color: #e0e0e0;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.run-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 0.125rem;
}

.run-episodes, .run-score {
    white-space: nowrap;
}

.run-date {
    font-size: 0.7rem;
    color: #666;
}

.sidebar-loading,
.sidebar-error,
.sidebar-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: #666;
    font-size: 0.875rem;
}

.sidebar-error {
    color: #ef4444;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: absolute;
    right: -12px;
    bottom: 2rem;
    width: 24px;
    height: 24px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #999;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    z-index: 10;
}

.sidebar-toggle:hover {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #444;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.sidebar.collapsed .toggle-icon {
    transform: rotate(180deg);
}

/* App Container */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

/* Header */
header {
    padding: 1rem 2rem;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    margin-right: 0.5rem;
}

.mobile-menu-btn:hover {
    color: #4ade80;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: #333;
    color: #999;
}

.status.connected {
    background: #1a4d1a;
    color: #4ade80;
}

main {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    max-width: 2000px;
    margin: 0 auto;
}

.card {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid #333;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: #444;
}

.card h2 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chart-card {
    min-height: 300px;
}

.card canvas {
    width: 100% !important;
    height: 250px !important;
}

/* Stats Card */
.stats .stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #333;
}

.stats .stat:last-child {
    border-bottom: none;
}

.stats .label {
    color: #999;
    font-size: 0.875rem;
}

.stats .value {
    font-family: 'Courier New', monospace;
    font-size: 1.25rem;
    font-weight: 600;
    color: #4ade80;
}

/* Alerts Panel */
.alerts {
    max-height: 400px;
    overflow-y: auto;
}

.alerts::-webkit-scrollbar {
    width: 8px;
}

.alerts::-webkit-scrollbar-track {
    background: #0f0f0f;
}

.alerts::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

.alerts::-webkit-scrollbar-thumb:hover {
    background: #444;
}

.alert-item {
    background: #2a1a1a;
    border-left: 3px solid #ef4444;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0 4px 4px 0;
}

.alert-item.warning {
    border-color: #f59e0b;
    background: #2a2a1a;
}

.alert-item.info {
    border-color: #3b82f6;
    background: #1a1a2a;
}

.alert-item .type {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.alert-item .description {
    font-size: 0.75rem;
    color: #999;
}

.alert-item .episode {
    font-size: 0.7rem;
    color: #666;
    margin-top: 0.25rem;
}

.no-alerts {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

/* Grouped Alerts */
.alert-group {
    cursor: pointer;
    transition: all 0.2s ease;
}

.alert-group.expanded {
    margin-bottom: 1rem;
}

.alert-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-header:hover {
    opacity: 0.9;
}

.alert-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.count-badge {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.alert-item.warning .count-badge {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

.alert-item.info .count-badge {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

.alert-item .count-badge {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.alert-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.7rem;
    color: #666;
    flex-wrap: wrap;
}

.episode-info,
.severity-info {
    color: #888;
}

.chevron {
    font-size: 0.6rem;
    color: #999;
    margin-left: auto;
    transition: transform 0.2s ease;
    user-select: none;
}

.alert-group.expanded .chevron {
    transform: rotate(180deg);
}

.alert-details {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.occurrences-container {
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.occurrences-container::-webkit-scrollbar {
    width: 6px;
}

.occurrences-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.occurrences-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.occurrences-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.occurrences-note {
    font-size: 0.75rem;
    color: #aaa;
    margin: 0.5rem 0;
}

.occurrences-info {
    font-size: 0.7rem;
    color: #666;
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.occurrences-info em {
    font-style: italic;
    color: #888;
}

/* Sidebar Overlay (for mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }
}

@media (max-width: 768px) {
    /* Mobile: Sidebar becomes slide-out drawer */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        z-index: 1000;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }

    .mobile-close {
        display: block;
    }

    .sidebar-toggle {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }

    header {
        padding: 1rem;
    }

    .header-content {
        gap: 0.5rem;
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    main {
        padding: 1rem;
    }
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

