:root {
    --primary: #2563eb;
    --background: #f8fafc;
    --text: #1e293b;
    --card: #ffffff;
    --border: #e2e8f0;
    --easy: #4ade80;
    --medium: #fbbf24;
    --hard: #ef4444;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.5;
    margin: 0;
    padding: 20px;
}

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

.header {
    margin-bottom: 2rem;
    text-align: center;
}

.filters {
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--card);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-x: hidden;
}

select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card);
    color: var(--text);
    font-size: 1rem;
}

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

.problem-card {
    background: var(--card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.problem-card:hover {
    transform: translateY(-2px);
}

.problem-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.topic {
    font-size: 0.875rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.tag {
    background: #f1f5f9;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    color: #64748b;
}

.company-tag-card {
    background: #e2e8f0;
    color: #475569;
}

.solved-checkbox {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.solved-checkbox label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.solved-checkbox label:hover {
    background: var(--background);
}

.solved-checkbox input[type="checkbox"] {
    appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border);
    border-radius: 4px;
    margin: 0;
    display: grid;
    place-content: center;
}

.solved-checkbox input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.solved-checkbox input[type="checkbox"]:checked::before {
    content: "✓";
    color: white;
    font-size: 0.875rem;
}

.loading {
    text-align: center;
    padding: 2rem;
    font-size: 1.25rem;
    color: var(--text);
}

.spoiler {
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.spoiler-button {
    background: none;
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
    margin-bottom: 0.5rem;
}

.spoiler-button:hover {
    background: var(--background);
}

.spoiler-content {
    display: none;
    padding: 1rem;
    background: var(--background);
    border-radius: 4px;
    margin-top: 0.5rem;
}

.spoiler-content.visible {
    display: block;
}

.pagination-container {
    margin: 2rem 0;
    padding: 1rem;
    background: var(--card);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding: 1rem;
}

.page-button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card);
    cursor: pointer;
    transition: all 0.2s;
}

.page-button:hover {
    background: var(--background);
}

.page-button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.ellipsis {
    padding: 0.5rem;
    color: var(--text);
}

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

.problem-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.problem-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
    white-space: nowrap;
}

.problem-link:hover {
    text-decoration: underline;
}

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

.problem-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0.5rem 0;
}

.problem-task {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.tags-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 1rem;
}

.tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .problems {
        grid-template-columns: repeat(2, 1fr); /* 2 columns for tablets */
    }
    
    .filters {
        flex-direction: row;
        align-items: flex-start;
        gap: 2rem;
    }
}

@media (min-width: 1200px) {
    .problems {
        grid-template-columns: repeat(3, 1fr); /* 3 columns for desktop */
    }
}

@media (max-width: 640px) {
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .page-button {
        padding: 0.5rem;
        min-width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.875rem;
    }

    .pagination .page-button:not(.active):not(:first-child):not(:last-child):not(.mobile-visible) {
        display: none;
    }
}

.filter-group {
    margin-bottom: 1rem;
    width: 100%;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.companies-select {
    min-width: 200px;
    max-width: 100%;
    min-height: 100px;
}

.companies-container {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem;
    margin-top: 0.5rem;
    width: 100%;
    overflow: hidden; /* Changed from overflow-x */
}

.companies-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem;
    width: calc(100% - 1rem); /* Added to ensure proper width calculation */
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar styling */
.companies-scroll::-webkit-scrollbar {
    height: 4px;
}

.companies-scroll::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 2px;
}

.companies-scroll::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 2px;
}

.company-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.remove-company {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    font-size: 1rem;
    line-height: 1;
}

.company-tag:not(.active) .remove-company {
    background: rgba(0, 0, 0, 0.1);
}

.difficulties-container {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem;
    margin-top: 0.5rem;
    overflow: hidden;
    width: 100%;
}

.difficulties-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.difficulties-scroll::-webkit-scrollbar {
    height: 4px;
}

.difficulties-scroll::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 2px;
}

.difficulties-scroll::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 2px;
}

.difficulty-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.difficulty-tag[data-difficulty="easy"] {
    color: var(--easy);
    border-color: var(--easy);
}

.difficulty-tag[data-difficulty="medium"] {
    color: var(--medium);
    border-color: var(--medium);
}

.difficulty-tag[data-difficulty="hard"] {
    color: var(--hard);
    border-color: var(--hard);
}

.difficulty-tag[data-difficulty="easy"].active {
    background: var(--easy);
    color: white;
}

.difficulty-tag[data-difficulty="medium"].active {
    background: var(--medium);
    color: white;
}

.difficulty-tag[data-difficulty="hard"].active {
    background: var(--hard);
    color: white;
}

.difficulty.easy { color: var(--easy); }
.difficulty.medium { color: var(--medium); }
.difficulty.hard { color: var(--hard); }

.solved-counter {
    background: transparent;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin: 0;
    width: 300px;
}

.solved-stats {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.stat-item {
    font-size: 0.875rem;
}

.stat-item:not(:last-child)::after {
    content: '|';
    margin-left: 1rem;
    color: var(--border);
}
.stat-item:has(.easy) { color: var(--easy); }
.stat-item:has(.medium) { color: var(--medium); }
.stat-item:has(.hard) { color: var(--hard); }

.stat-item {
    &:contains("Easy") { color: var(--easy); }
    &:contains("Medium") { color: var(--medium); }
    &:contains("Hard") { color: var(--hard); }
}

.solved-filter-container {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem;
    margin-top: 0.5rem;
    overflow: hidden;
    width: 100%;
}

.solved-filter-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
}

.solved-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

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

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.filter-row {
    display: flex;
    gap: 1rem;
    width: 100%;
}

.filter-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

.difficulties-container,
.solved-filter-container,
.companies-container,
.solved-counter {
    min-height: 50px;
    display: flex;
    flex-direction: column;
}

@media (max-width: 768px) {
    .filter-row {
        flex-direction: column;
    }
    
    .solved-counter {
        width: 100%;
    }
}

.filter-controls {
    display: flex;
    gap: 1rem;
    width: 100%;
}

.difficulties-container,
.solved-filter-container,
.solved-counter {
    flex: 1;
    min-height: 50px;
}

.company-search-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.15rem 0.5rem;
    border-bottom: 1px solid var(--border);
    height: 30px; /* Reduced height */
}

.search-toggle {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text);
    transition: color 0.2s;
    height: 28px;
    width: 28px;
}

.search-toggle:hover {
    color: var(--primary);
}

.company-search {
    display: none;
    width: 200px;
}

.company-search.visible {
    display: block;
}

.company-search-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
    outline: none;
}

.company-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .filter-controls {
        flex-direction: column;
    }

    .difficulties-container,
    .solved-filter-container,
    .solved-counter {
        width: 100%;
    }

    .company-search {
        width: 100%;
    }
}

