/* Base Styles */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --sidebar-bg: #1e293b;
    --sidebar-text: #e2e8f0;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Layout */
.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.sidebar-header .subtitle {
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.nav-icon {
    font-size: 1.2rem;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    color: var(--secondary-color);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 32px;
    max-width: 1200px;
}

/* Page Header */
.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--text-muted);
}

/* Content Card */
.content-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.content-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-color);
}

.content-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 24px 0 12px;
}

.content-card p {
    margin-bottom: 12px;
    color: var(--text-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-large {
    padding: 14px 32px;
    font-size: 1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 24px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.upload-hint {
    color: var(--text-muted);
    margin: 12px 0;
}

.file-name {
    margin-top: 16px;
    font-weight: 500;
    color: var(--primary-color);
}

/* Progress Bar */
.upload-progress {
    margin-bottom: 24px;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* Submit Result */
.submit-result {
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.submit-result.success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.submit-result.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.submit-result.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.result-icon {
    font-size: 1.25rem;
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
}

.form-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Tables */
.submissions-table-container {
    overflow-x: auto;
}

.submissions-table,
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.submissions-table th,
.submissions-table td,
.leaderboard-table th,
.leaderboard-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.submissions-table th,
.leaderboard-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.submissions-table tbody tr:hover,
.leaderboard-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.02);
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 32px;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-pending {
    background: rgba(100, 116, 139, 0.15);
    color: var(--secondary-color);
}

.status-processing {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-color);
}

.status-completed {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success-color);
}

.status-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error-color);
}

.status-overlimit {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning-color);
}

/* Leaderboard Specific */
.leaderboard-table .rank-col {
    width: 80px;
    text-align: center;
}

.leaderboard-table .team-col {
    text-align: left;
}

.leaderboard-table .score-col {
    width: 150px;
    text-align: right;
}

.leaderboard-table .time-col {
    width: 200px;
    text-align: right;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1rem;
    background: var(--border-color);
    color: var(--text-muted);
}

.rank-gold {
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: #7a5c00;
}

.rank-silver {
    background: linear-gradient(135deg, #e0e0e0, #bdbdbd);
    color: #616161;
}

.rank-bronze {
    background: linear-gradient(135deg, #cd7f32, #a0522d);
    color: white;
}

.score-cell .score-value {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.rank-gold .score-value {
    color: #7a5c00;
}

/* Loading State */
.loading-cell {
    text-align: center;
    padding: 32px;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.empty-state h3 {
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Code Blocks */
pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.5;
}

code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

p code,
li code {
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--primary-color);
}

/* Rules List */
.rules-list {
    list-style: none;
    padding: 0;
}

.rules-list li {
    padding: 8px 0;
    padding-left: 24px;
    position: relative;
}

.rules-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
}

/* Info Box */
.info-box {
    background: rgba(99, 102, 241, 0.08);
    border-left: 4px solid var(--primary-color);
    padding: 16px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin: 24px 0;
}

.info-box h4 {
    margin-bottom: 8px;
    color: var(--primary-color);
}

/* Timeline Table */
.timeline-table {
    width: 100%;
    border-collapse: collapse;
}

.timeline-table td {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.timeline-table td:first-child {
    font-weight: 500;
    width: 200px;
}

/* CTA Section */
.cta-section {
    text-align: center;
    padding: 32px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 32px;
}

.cta-section p {
    color: var(--text-muted);
    margin-bottom: 16px;
}

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .container {
        flex-direction: column;
    }

    .upload-area {
        padding: 32px 16px;
    }
}
