:root {
    --primary-color: #4a90e2;
    --secondary-color: #7b68ee;
    --success-color: #51cf66;
    --warning-color: #ffd43b;
    --danger-color: #ff6b6b;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

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

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

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

header {
    color: white;
    margin-bottom: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-text {
    flex: 1;
}

.header-text h1 {
    font-size: 2rem;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1rem;
    opacity: 0.95;
}

.language-selector {
    flex-shrink: 0;
}

.lang-select {
    padding: 10px 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.lang-select:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.lang-select:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.7);
}

.lang-select option {
    background: var(--card-bg);
    color: var(--text-color);
}

.main-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.content-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 8px;
}

/* Input Section */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-group label {
    font-weight: 600;
    color: var(--text-color);
}

.input-group input {
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #cbd5e0;
    transform: translateY(-2px);
}

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

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.step-info {
    text-align: center;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
}

/* Visualization */
.visualization-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.vis-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Text Display */
.text-display {
    width: 100%;
}

.text-content {
    font-family: 'Courier New', monospace;
    font-size: 1.3rem;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    min-height: 60px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.text-placeholder {
    color: var(--text-secondary);
    font-style: italic;
}

.char-box {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 6px;
    border: 2px solid transparent;
    transition: all 0.3s;
    font-weight: bold;
}

.char-box.processed {
    background: #d4edda;
    border-color: #51cf66;
    color: #155724;
}

.char-box.current {
    background: #fff3cd;
    border-color: #ffd43b;
    color: #856404;
    animation: pulse 1s infinite;
}

.char-box.in-sequence {
    background: #cce5ff;
    border-color: #4a90e2;
    color: #004085;
}

.char-box.pending {
    background: #f8f9fa;
    border-color: #e2e8f0;
    color: #718096;
}

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

.legend {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #333;
}

.legend-color.processed {
    background: #d4edda;
    border-color: #51cf66;
}

.legend-color.current {
    background: #fff3cd;
    border-color: #ffd43b;
}

.legend-color.pending {
    background: #f8f9fa;
    border-color: #e2e8f0;
}

/* Current State */
.state-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.state-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
}

.state-item.full-width {
    grid-column: span 2;
}

.state-item label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.state-item .value {
    font-family: 'Courier New', monospace;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary-color);
}

.action-text {
    color: var(--secondary-color) !important;
    font-size: 1rem !important;
    line-height: 1.4;
}

/* Dictionary */
.bits-info {
    margin-bottom: 15px;
    padding: 10px;
    background: var(--warning-color);
    border-radius: 8px;
    text-align: center;
    font-size: 1rem;
}

.dictionary-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

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

.dictionary-table thead {
    position: sticky;
    top: 0;
    background: var(--primary-color);
    color: white;
    z-index: 10;
}

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

.dictionary-table td {
    font-family: 'Courier New', monospace;
}

.dictionary-table tbody tr:hover {
    background: var(--bg-color);
}

.dictionary-table tr.new-entry {
    background: #d4edda;
    animation: fadeIn 0.5s;
}

.dictionary-table tr.used-entry {
    background: #fff3cd;
}

@keyframes fadeIn {
    from {
        background: var(--success-color);
    }
    to {
        background: #d4edda;
    }
}

.empty-message {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Output */
.output-card {
    width: 100%;
}

.output-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    background: var(--bg-color);
    border-radius: 8px;
    min-height: 150px;
    max-height: 250px;
    overflow-y: auto;
}

.output-code {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    min-width: 100px;
    transition: all 0.3s;
}

.output-code:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.output-code.latest {
    background: #fff3cd;
    border-color: var(--warning-color);
    animation: slideIn 0.5s;
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.output-code .code-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.output-code .code-value {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.output-code .code-binary {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

.output-code .code-char {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-top: 5px;
    font-weight: 600;
}

/* Compression Stats */
.compression-stats {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
}

.stat-item label {
    font-weight: 600;
    color: var(--text-secondary);
}

.stat-item span {
    font-weight: bold;
    color: var(--primary-color);
}

/* Info Section */
.info-section .card {
    padding: 20px;
}

.info-section h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.info-content {
    font-size: 0.85rem;
}

.info-content p {
    margin-bottom: 10px;
}

.info-content h3 {
    margin-top: 12px;
    margin-bottom: 8px;
    color: var(--secondary-color);
    font-size: 0.95rem;
}

.info-content ol {
    margin-left: 15px;
    padding-left: 5px;
}

.info-content li {
    margin-bottom: 8px;
    line-height: 1.4;
}

/* Footer */
footer {
    text-align: center;
    color: white;
    padding: 20px;
    margin-top: 30px;
    opacity: 0.9;
}

/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 280px 1fr;
    }
    
    .sidebar {
        position: relative;
        top: 0;
        max-height: none;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: relative;
        top: 0;
        max-height: none;
    }
    
    .vis-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .header-text h1 {
        font-size: 1.5rem;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .state-grid {
        grid-template-columns: 1fr;
    }
    
    .compression-stats {
        grid-template-columns: 1fr;
    }
    
    .text-content {
        font-size: 1.2rem;
    }
}

