:root {
    /* Светлая тема */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --accent: #4CAF50;
    --accent-hover: #45a049;
    --border: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.1);
    --input-bg: #ffffff;
    --danger: #f44336;
}

[data-theme="dark"] {
    /* Тёмная тема */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-card: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --accent: #66bb6a;
    --accent-hover: #81c784;
    --border: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
    --input-bg: #333333;
    --danger: #ef5350;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-top: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Шапка */
header {
    background-color: var(--bg-secondary);
    padding: 20px 0;
    box-shadow: 0 2px 10px var(--shadow);
    margin-bottom: 30px;
    border-radius: 10px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

h1 {
    font-size: 2rem;
    color: var(--accent);
}

.theme-toggle {
    background: none;
    border: 2px solid var(--border);
    border-radius: 50px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background-color: var(--accent);
    border-color: var(--accent);
}

[data-theme="dark"] .sun {
    display: none;
}

[data-theme="light"] .moon {
    display: none;
}

/* Основной контент */
main {
    flex: 1;
}

section {
    background-color: var(--bg-card);
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px var(--shadow);
}

h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.5rem;
}

/* Форма */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="text"],
input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus,
input[type="file"]:focus {
    outline: none;
    border-color: var(--accent);
}

.file-info {
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Кнопки */
.analyze-btn,
.save-btn,
.clear-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.analyze-btn {
    background-color: var(--accent);
    color: white;
    width: 100%;
}

.analyze-btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.save-btn {
    background-color: var(--accent);
    color: white;
}

.clear-btn {
    background-color: var(--danger);
    color: white;
}

.save-btn:hover,
.clear-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

/* Сетка результатов */
.results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 30px;
    padding: 10px 0;
}

.result-card {
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    padding: 25px 20px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 160px;
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.result-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 20px var(--shadow);
}

.result-card:hover::before {
    transform: scaleX(1);
}

.result-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.9;
}

.result-value {
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 8px;
    line-height: 1.2;
}

.result-label {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
}

/* Соотношение кода - центрированный блок */
.ratio-section {
    margin: 30px 0;
    display: flex;
    justify-content: center;
}

.ratio-container {
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
    width: 100%;
    max-width: 700px;
    box-shadow: 0 2px 10px var(--shadow);
    transition: all 0.3s ease;
}

.ratio-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow);
}

.ratio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.ratio-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.ratio-warning {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    animation: pulse 2s infinite;
}

.ratio-warning.warning {
    background-color: #ff9800;
    color: white;
}

.ratio-warning.critical {
    background-color: #f44336;
    color: white;
}

.ratio-warning.good {
    background-color: #4CAF50;
    color: white;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.code-ratio {
    margin-top: 10px;
}

.ratio-bar {
    width: 100%;
    height: 40px;
    background-color: var(--bg-primary);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
}

.ratio-code {
    background: linear-gradient(90deg, #4CAF50, #66BB6A);
    height: 100%;
    transition: width 1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
}

.ratio-comment {
    background: linear-gradient(90deg, #2196F3, #42A5F5);
    height: 100%;
    transition: width 1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
}

.ratio-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
}

.ratio-label {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.ratio-label::before {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 6px;
    display: inline-block;
}

.code-label::before {
    background: linear-gradient(90deg, #4CAF50, #66BB6A);
}

.comment-label::before {
    background: linear-gradient(90deg, #2196F3, #42A5F5);
}

.code-label {
    color: var(--text-primary);
    font-weight: 600;
}

.comment-label {
    color: var(--text-primary);
    font-weight: 600;
}

/* Дополнительная статистика */
.additional-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 30px;
}

.stat-block {
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

.stat-block:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px var(--shadow);
}

.stat-icon {
    font-size: 3rem;
    opacity: 0.9;
}

.stat-content {
    flex: 1;
}

.stat-title {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 5px;
    font-weight: 500;
}

.stat-value {
    color: var(--accent);
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 3px;
    word-break: break-word;
}

.stat-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Типы файлов */
.file-types {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.file-type-badge {
    background-color: var(--accent);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    transition: all 0.3s ease;
}

.file-type-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px var(--shadow);
}

/* История */
.history-list {
    display: grid;
    gap: 15px;
}

.history-item {
    background-color: var(--bg-primary);
    padding: 20px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px var(--shadow);
    background-color: var(--bg-secondary);
}

.history-info h4 {
    color: var(--accent);
    margin-bottom: 5px;
    font-size: 1.1rem;
}

.history-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.history-stats {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
    align-items: center;
}

.history-stat {
    text-align: center;
    padding: 5px 10px;
    background-color: var(--bg-card);
    border-radius: 8px;
    min-width: 60px;
}

.history-stat-value {
    font-weight: bold;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.history-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Кнопка очистки истории */
.history-actions {
    display: flex;
    justify-content: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.clear-history-btn {
    background-color: var(--danger);
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-history-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
    background-color: #d32f2f;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: var(--bg-card);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
    transition: all 0.3s ease;
}

.close:hover {
    color: var(--danger);
    transform: rotate(90deg);
}

#modalTitle {
    margin-bottom: 20px;
    color: var(--accent);
    font-size: 1.5rem;
}

#modalMessage {
    line-height: 1.8;
    color: var(--text-primary);
}

/* Футер */
footer {
    background-color: var(--bg-secondary);
    padding: 20px 0;
    text-align: center;
    color: var(--text-secondary);
    margin-top: auto;
    border-radius: 10px;
    margin-bottom: 20px;
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Адаптивность */
@media (max-width: 968px) {
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 768px) {
    body {
        padding-top: 10px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .result-card {
        min-height: 140px;
    }
    
    .history-item {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .history-stats {
        justify-content: center;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
        max-height: 90vh;
    }
    
    .actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .save-btn,
    .clear-btn {
        width: 100%;
        margin-right: 0;
    }
    
    .additional-stats {
        grid-template-columns: 1fr;
    }
	
    .ratio-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .ratio-bar {
        height: 35px;
    }
    
    .ratio-labels {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
	
    .stat-block {
        padding: 15px;
    }
    
    .stat-icon {
        font-size: 2.5rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .file-types {
        justify-content: center;
    }
    
    .file-type-badge {
        font-size: 0.85rem;
        padding: 5px 10px;
    }
}

@media (max-width: 480px) {
    .result-icon {
        font-size: 2rem;
    }
    
    .result-value {
        font-size: 1.8rem;
    }
    
    .result-label {
        font-size: 0.85rem;
    }
    
    section {
        padding: 20px;
    }
    
    .stat-block {
        flex-direction: column;
        text-align: center;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
}

@media (max-width: 968px) {
    .additional-stats {
        grid-template-columns: 1fr;
    }
    
    .ratio-container {
        padding: 20px;
    }
}

@media (min-width: 1400px) {
    .container {
        max-width: 1300px;
    }
    
    .results-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 30px;
    }
    
    .result-card {
        min-height: 180px;
    }
}