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

:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --accent-primary: #4CAF50;
    --accent-secondary: #2196F3;
    --admin-color: #ff4444;
    --mod-color: #ffa500;
    --member-color: #4CAF50;
    --m-builder-color: #9C27B0;
    --praetorian-color: #8E24AA;
    --system-color: #9e9e9e;
    --border-radius: 8px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Upload Section - now Chat Selection Section */
.chat-selection-section {
    margin-bottom: 2rem;
}

.selection-box {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-primary);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
}

.selection-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.selection-box h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.selection-box p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

/* Chat List */
.chat-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.chat-item {
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.chat-item:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.chat-item.selected {
    border-color: var(--accent-secondary);
    background: var(--bg-primary);
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.chat-item-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.chat-item-date {
    font-size: 0.9rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
}

.chat-item-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.chat-item-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.chat-item-stat {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.load-chat-btn {
    width: 100%;
    margin-top: 1rem;
    padding: 0.8rem;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.load-chat-btn:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

/* Error message */
.error-message {
    background: rgba(255, 68, 68, 0.1);
    border: 2px solid #ff4444;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    color: #ff6b6b;
}

.error-message p:first-child {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.error-message p:last-child {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Category System */
.category-filter {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-primary);
}

.category-filter label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.category-filter select {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1rem;
}

.category-section {
    margin-bottom: 2rem;
}

.category-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--accent-primary);
}

.category-header.crea-1 {
    border-left-color: #4CAF50;
}

.category-header.survival-1 {
    border-left-color: #FF9800;
}

.category-header.event {
    border-left-color: #9C27B0;
}

.category-header.test {
    border-left-color: #607D8B;
}

.category-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem 0;
}

.category-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.category-stats {
    margin-left: auto;
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.chat-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

/* Chat Item Category Badge */
.chat-item-category {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
    margin-bottom: 0.5rem;
}

.chat-item-category.crea-1 {
    background: #4CAF50;
}

.chat-item-category.survival-1 {
    background: #FF9800;
}

.chat-item-category.event {
    background: #9C27B0;
}

.chat-item-category.test {
    background: #607D8B;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--accent-primary);
}

.btn-secondary:hover {
    background: var(--accent-primary);
    transform: translateY(-2px);
}

/* Controls */
.controls {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.control-group {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.control-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.control-group label:hover {
    color: var(--text-primary);
}

.control-group input[type="checkbox"] {
    accent-color: var(--accent-primary);
    transform: scale(1.2);
}

/* Chat Container */
.chat-container {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.chat-header {
    background: var(--bg-tertiary);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--accent-primary);
}

.chat-header h2 {
    font-size: 1.5rem;
}

.chat-info {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.chat-content {
    max-height: 600px;
    overflow-y: auto;
    padding: 1rem;
}

/* Chat Messages */
.chat-message {
    display: flex;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.chat-message:hover {
    background: var(--bg-tertiary);
}

.chat-message.system-message {
    background: rgba(158, 158, 158, 0.1);
    font-style: italic;
}

.chat-message.join-leave {
    background: rgba(76, 175, 80, 0.1);
}

.timestamp {
    color: var(--text-muted);
    margin-right: 1rem;
    min-width: 80px;
    font-size: 0.9rem;
}

.message-content {
    flex: 1;
}

.player-info {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 0.5rem;
}

.role-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
}

.role-badge.admin {
    background: var(--admin-color);
    color: white;
}

.role-badge.mod {
    background: var(--mod-color);
    color: white;
}

.role-badge.member {
    background: var(--member-color);
    color: white;
}

.role-badge.m-builder {
    background: var(--m-builder-color);
    color: white;
}

.role-badge.praetorian {
    background: var(--praetorian-color);
    color: white;
}

.role-badge.system {
    background: var(--system-color);
    color: white;
}

.player-name {
    font-weight: 600;
    color: var(--text-primary);
}

.message-text {
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.message-separator {
    color: var(--text-muted);
    margin: 0 0.5rem;
}

/* Legend */
.legend {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
}

.legend h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-item span:last-child {
    color: var(--text-secondary);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    border-top: 1px solid var(--bg-tertiary);
    margin-top: 2rem;
}

/* Scrollbar */
.chat-content::-webkit-scrollbar {
    width: 8px;
}

.chat-content::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.chat-content::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

.chat-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group {
        justify-content: center;
    }
    
    .chat-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .chat-message {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .timestamp {
        min-width: auto;
        margin-right: 0;
    }
    
    .legend-items {
        grid-template-columns: 1fr;
    }
}

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

.chat-message {
    animation: fadeIn 0.3s ease-out;
}

/* Hide elements */
.hidden {
    display: none !important;
}

/* Loading indicator */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.loading::after {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-top: 2px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
