:root {
    --primary-color: #5e72e4;
    --primary-dark: #4c63d2;
    --secondary-color: #f5365c;
    --success-color: #2dce89;
    --warning-color: #fb6340;
    --info-color: #11cdef;
    --background: #f7f8fc;
    --surface: #ffffff;
    --text-primary: #32325d;
    --text-secondary: #8898aa;
    --border-color: #e9ecef;
    --shadow-sm: 0 2px 4px rgba(50, 50, 93, 0.1);
    --shadow-md: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 15px 35px rgba(50, 50, 93, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

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

header {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
    animation: fadeIn 0.6s ease;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 400;
}

.language-selector {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    animation: fadeIn 0.8s ease;
}

.lang-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

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

main {
    animation: slideUp 0.6s ease;
}

.input-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

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

.section-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.format-selector {
    display: flex;
    gap: 0.5rem;
}

.format-btn {
    padding: 0.5rem 1rem;
    background: var(--background);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

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

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

#inputText {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#inputText:focus {
    outline: none;
    border-color: var(--primary-color);
}

.input-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

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

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.primary-btn, .secondary-btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

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

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

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

.results-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.6s ease;
}

.results-section.hidden {
    display: none;
}

.results-section h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.algorithms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.algorithm-card {
    background: var(--background);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.algorithm-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.algorithm-card.best {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-color: var(--primary-color);
}

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

.algorithm-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
}

.best-badge {
    background: var(--success-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.algorithm-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

.stat-value.highlight {
    color: var(--success-color);
    font-size: 1.1rem;
}

.algorithm-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    flex: 1;
    padding: 0.5rem;
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.visualization-section {
    margin: 2rem 0;
}

.visualization-section h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.chart-container {
    background: var(--background);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.chart-bar {
    margin-bottom: 1rem;
}

.bar-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.bar-container {
    background: white;
    border-radius: 20px;
    height: 36px;
    position: relative;
    overflow: hidden;
}

.bar {
    height: 100%;
    border-radius: 20px;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    transition: width 0.6s ease;
    position: relative;
}

.bar.original {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bar.compressed {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.bar.compressed.best {
    background: linear-gradient(135deg, #2dce89 0%, #20bf6b 100%);
}

.bar-value {
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.best-algorithm {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.best-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--success-color);
    font-weight: 600;
}

.best-badge svg {
    width: 24px;
    height: 24px;
}

#bestAlgorithmInfo {
    flex: 1;
    color: var(--text-primary);
}

footer {
    text-align: center;
    color: white;
    margin-top: 3rem;
    padding: 1rem;
    opacity: 0.9;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .algorithms-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .language-selector {
        flex-wrap: wrap;
    }
}