/* Reset & Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors - Light Mode */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #818cf8;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --danger: #ef4444;

    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;

    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --transition: all 0.2s ease;
}

/* Dark Mode */
body.dark-mode {
    --bg-primary: #0a0f1e;
    --bg-secondary: #111827;
    --bg-tertiary: #1f2937;
    --bg-card: #1a2332;

    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;

    --border-light: #374151;
    --border-medium: #4b5563;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.7);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.8);

    --success-light: rgba(16, 185, 129, 0.15);
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --primary-light: #a78bfa;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.text-tertiary {
    color: var(--text-tertiary);
}

/* Header */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 0;
    transition: var(--transition);
    position: relative;
}

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

.nav-link.active {
    color: var(--primary);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-light);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    padding: 0;
}

.theme-toggle:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.theme-toggle .moon-icon {
    display: none;
}

body.dark-mode .theme-toggle .sun-icon {
    display: none;
}

body.dark-mode .theme-toggle .moon-icon {
    display: block;
}

/* Main Container */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Profile Section */
.profile-section {
    margin-bottom: 2rem;
}

.profile-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.profile-search {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.handle-input {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 2px solid var(--border-light);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.handle-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
}

.btn-primary {
    padding: 0.875rem 1.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:active {
    transform: translateY(0);
}

.profile-info {
    display: flex;
    gap: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
    align-items: center;
}

.profile-info.hidden {
    display: none;
}

.user-info-section {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-width: 280px;
}

.user-avatar {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    position: relative;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    object-fit: cover;
    border: 3px solid var(--primary);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.user-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-rank {
    font-size: 0.95rem;
    color: var(--primary);
    font-weight: 600;
    text-transform: capitalize;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    flex: 1;
}

.stat-item {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
    border: 2px solid transparent;
    border-radius: 14px;
    padding: 1.25rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.05) 0%, rgba(155, 89, 182, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 12px;
}

.stat-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(52, 152, 219, 0.15);
    border-color: var(--primary);
}

.stat-item:hover::before {
    opacity: 1;
}

.stat-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
    z-index: 1;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    z-index: 1;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    line-height: 1;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

/* Sheet Selector */
.sheet-selector {
    margin-bottom: 2rem;
}

.selector-header {
    margin-bottom: 1rem;
}

.selector-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.selector-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.sheet-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.sheet-tab {
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
    color: var(--text-primary);
}

.sheet-tab:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.sheet-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.tab-label {
    font-weight: 600;
    font-size: 1rem;
}

.tab-difficulty {
    font-size: 0.875rem;
    opacity: 0.8;
    color: var(--text-secondary);
}

.sheet-tab.active .tab-difficulty,
.sheet-tab.active .tab-count {
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.9);
}

.tab-count {
    font-size: 0.8rem;
    opacity: 0.6;
    color: var(--text-tertiary);
}

.sheet-tab.active .tab-label,
.sheet-tab.active .tab-difficulty,
.sheet-tab.active .tab-count {
    color: white;
}

.toggle-tags-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-tags-btn:hover {
    background: var(--bg-card);
    border-color: var(--primary);
    color: var(--primary);
}

/* Filters Section */
.filters-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

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

.filter-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-light);
    background: var(--bg-card);
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

.search-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    transition: var(--transition);
    color: var(--text-tertiary);
}

.search-box:focus-within {
    border-color: var(--primary);
    color: var(--primary);
}

.search-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-primary);
    width: 250px;
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

/* Problems Section */
.problems-section {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.problems-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.problems-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.problem-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.table-wrapper {
    overflow-x: auto;
}

.problems-table {
    width: 100%;
    border-collapse: collapse;
}

.problems-table thead {
    background: var(--bg-secondary);
    border-radius: 8px;
}

.problems-table th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.problems-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.problems-table tbody tr:hover {
    background: var(--bg-secondary);
}

.problems-table td {
    padding: 1rem;
    color: var(--text-primary);
}

.col-number {
    width: 60px;
    text-align: center;
}

.col-code {
    width: 140px;
}

.col-category {
    width: 120px;
}

.col-status {
    width: 100px;
    text-align: center;
}

.col-action {
    width: 100px;
    text-align: center;
}

.problem-name {
    font-weight: 500;
    color: var(--text-primary);
}

.problem-code {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

.problem-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-solved {
    background: var(--success-light);
    color: var(--success);
}

.status-unsolved {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
}

.btn-solve {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Loading & Empty States */
.loading-spinner,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1rem;
}

.loading-spinner.hidden,
.empty-state.hidden {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.empty-state svg {
    color: var(--text-tertiary);
}

.empty-state p,
.loading-spinner p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Problem Tags */
.problem-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

.tag:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.toast.hidden {
    display: none;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .profile-search {
        flex-direction: column;
    }

    .profile-info {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .user-details {
        align-items: center;
    }

    .sheet-tabs {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .filters-section {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-buttons {
        flex-wrap: wrap;
    }

    .search-input {
        width: 100%;
    }

    .problems-table {
        font-size: 0.875rem;
    }

    .col-category,
    .col-code {
        display: none;
    }
}

/* About Page Styles */
.about-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 0;
}

.about-hero {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.about-hero h2 {
    font-size: 2.5rem;
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin: 0;
}

.about-section {
    margin-bottom: 2.5rem;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.about-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.about-section p {
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.about-section.highlight {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.05) 0%, rgba(155, 89, 182, 0.05) 100%);
    border: 2px solid var(--primary-color);
}

.credit-card {
    margin-top: 1rem;
}

.credit-card h4 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin: 0 0 1rem 0;
}

.links {
    margin-top: 1.5rem;
}

.btn-link {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-link:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.feature-item {
    padding: 1.5rem;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.feature-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.feature-item h4 {
    margin: 0.5rem 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.feature-item p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.tech-badge {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.stat-card {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Analytics Page Styles */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.analytics-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.analytics-card.wide {
    grid-column: 1 / -1;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.chart-container {
    position: relative;
    height: 300px;
}

.analytics-card.wide .chart-container {
    height: 200px;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 500px;
    overflow-y: auto;
}

.activity-item {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.activity-problem {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.problem-link {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.problem-link:hover {
    color: var(--primary);
}

.activity-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.verdict-badge {
    padding: 0.25rem 0.625rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.verdict-badge.success {
    background: var(--success-light);
    color: var(--success);
}

.verdict-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.activity-time {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.activity-lang {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Responsive Analytics */
@media (max-width: 768px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .activity-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-container {
        height: 250px;
    }
}