/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
    padding: 20px;
}

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

/* Главная обертка для размещения калькулятора и списка материалов рядом */
.main-wrapper {
    display: flex;
    margin-bottom: 20px;
    position: relative;
    min-height: 0;
}

/* Левая и правая колонки */
.left-column {
    flex: 1;
}

.right-column {
    width: 300px;
    margin-left: 20px;
    display: flex;
    flex-direction: column;
}

/* Стили для блока калькулятора */
.glaze-card {
    width: 100%;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: auto;
    padding: 20px;
    height: auto;
}

/* Стили для блока материалов */
.materials-card {
    width: 100%;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    padding: 0;
    margin-bottom: 20px;
}

.materials-card .table-header {
    padding: 12px;
    text-align: center;
    background-color: #4285F4;
    color: white;
    font-size: 14px;
    margin-bottom: 10px;
}

.materials-list {
    padding: 0 10px;
    margin-bottom: 15px;
    height: auto;
}

.materials-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 0 10px 15px;
}

#select_all_materials, #deselect_all_materials {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
}

#select_all_materials:hover, #deselect_all_materials:hover {
    background-color: #e0e0e0;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 1180px) {
    .main-wrapper {
        flex-direction: column;
    }
    
    .left-column, .right-column {
        width: 100%;
        margin-left: 0;
    }
    
    .glaze-card, .materials-card, .settings-card {
        width: 100%;
        margin-bottom: 20px;
    }
}

/* Header */
.header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.logo-icon {
    margin-right: 12px;
    display: flex;
    align-items: center;
}

.header h1 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.lock-icon svg {
    width: 24px;
    height: 24px;
}

/* Обертка для калькулятора и материалов - горизонтальное размещение */
.calculator-materials-wrapper {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.composition-grid {
    flex: 2;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(220px, 1fr);
    gap: 15px;
}

.materials-container {
    flex: 1;
    min-width: 220px;
    max-width: 300px;
    max-height: none;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
    background-color: #f9f9f9;
}

/* Composition Grid */
.composition-table {
    border: 1px solid #e1e1e1;
    border-radius: 5px;
    overflow: hidden;
}

.table-header {
    background-color: #4285F4;
    color: white;
    padding: 8px 10px;
    font-size: 14px;
    text-align: center;
}

.table-header.other {
    margin-top: 10px;
    background-color: #4285F4;
}

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

.composition-table td {
    padding: 8px 10px;
    font-size: 14px;
    border-bottom: none;
}

.composition-table td:first-child {
    border-right: none;
    width: 40%;
}

.composition-table td:nth-child(2) {
    text-align: right;
    color: #4285F4;
    width: 50%;
}

.composition-table td:nth-child(3) {
    width: 10%;
    text-align: center;
}

/* Oxide Input */
.oxide-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #e1e1e1;
    border-radius: 3px;
    font-size: 15px;
    color: #4285F4;
    text-align: right;
    background-color: #f9f9f9;
}

.oxide-input:focus {
    outline: none;
    border-color: #4285F4;
    background-color: #fff;
}

/* Oxide Select */
.oxide-select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #e1e1e1;
    border-radius: 3px;
    font-size: 14px;
    background-color: #f9f9f9;
}

.oxide-select:focus {
    outline: none;
    border-color: #4285F4;
    background-color: #fff;
}

/* Add/Delete Oxide Buttons */
.add-oxide-btn {
    display: block;
    width: 80%;
    padding: 8px;
    margin-top: 8px;
    margin-bottom: 10px;
    margin-left: auto;
    margin-right: auto;
    background-color: #f1f8ff;
    border: 1px solid #c8e1ff;
    border-radius: 5px;
    color: #4285F4;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.add-oxide-btn:hover {
    background-color: #dbedff;
    border-color: #4285F4;
}

.delete-oxide-btn {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.delete-oxide-btn:hover {
    color: #c0392b;
    background-color: #ffeceb;
}

/* Таблица оксидов */
.composition-table tr {
    transition: background-color 0.2s;
}

.composition-table tr:hover {
    background-color: #f9f9f9;
}

/* Ratio Info */
.ratio-info {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e1e1e1;
    font-size: 14px;
}

.ratio-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ratio-item span:first-child {
    color: #666;
}

.ratio-item span:last-child {
    color: #4285F4;
    font-weight: 500;
}

.ratio-buttons {
    margin-left: auto;
}

.ratio-button {
    background: none;
    border: 1px solid #4285F4;
    color: #4285F4;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.ratio-button.active {
    background-color: #4285F4;
    color: white;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 10px;
}

.primary-button {
    flex: 1;
    background-color: #4285F4;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-button:hover {
    background-color: #3367d6;
}

/* Ingredients */
.ingredients-list {
    margin-bottom: 20px;
}

.ingredient-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.ingredient-remove {
    background: none;
    border: none;
    color: #4285F4;
    cursor: pointer;
    font-size: 18px;
}

.ingredient-select {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #e1e1e1;
    border-radius: 5px;
    font-size: 14px;
    background-color: #f9f9f9;
    cursor: pointer;
}

.ingredient-amount {
    width: 80px;
    padding: 10px;
    border: 1px solid #e1e1e1;
    border-radius: 5px;
    font-size: 14px;
    text-align: right;
}

/* Total */
.ingredients-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 5px;
}

.total-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.normalize-button {
    background-color: #4285F4;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
}

.total-value {
    font-weight: 500;
    color: #4285F4;
}

/* Actions */
.ingredients-actions {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.add-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #4285F4;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Additions Toggle */
.additions-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e1e1e1;
}

.additions-toggle span {
    font-size: 14px;
    color: #666;
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #4285F4;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Actions Bar */
.actions-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.action-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.action-button svg {
    width: 24px;
    height: 24px;
}

/* Date Info */
.date-info {
    font-size: 12px;
    color: #999;
    text-align: right;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e1e1e1;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 500;
}

.close {
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #333;
}

#material_search {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #e1e1e1;
    border-radius: 5px;
    font-size: 14px;
}

.material-item {
    display: flex;
    align-items: center;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s;
    font-size: 13px;
    margin-bottom: 1px;
    cursor: default;
}

.material-item.has-tooltip {
    cursor: help;
    position: relative;
}

.material-item:hover {
    background-color: #eee;
}

.material-item input[type="checkbox"] {
    margin-right: 4px;
}

.material-item label {
    cursor: pointer;
    user-select: none;
}

/* Solutions container */
.solutions-container {
    margin-top: 20px;
    border-top: 1px solid #e1e1e1;
    padding-top: 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.solution-item {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 5px;
    background-color: #f9f9f9;
    border: 1px solid #e1e1e1;
}

.solution-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.solution-title {
    font-weight: 500;
    font-size: 16px;
}

.solution-error {
    font-size: 12px;
    font-weight: 500;
}

/* Классы для разных уровней погрешности */
.error-low {
    color: #27ae60;
}

.error-medium {
    color: #f39c12;
}

.error-high {
    color: #e74c3c;
}

.solution-recipe {
    margin-bottom: 10px;
}

.solution-recipe-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #f0f0f0;
}

.solution-recipe-action {
    flex: 0 0 15px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.disable-material-btn {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 10px;
    font-weight: 100;
    cursor: pointer;
    padding: 0px 2px;
    border-radius: 2px;
    transition: all 0.2s;
    opacity: 0.5;
    line-height: 1;
}

.disable-material-btn:hover {
    background-color: #ffeceb;
    color: #e74c3c;
    opacity: 1;
}

.solution-recipe-name {
    flex: 1;
    font-size: 14px;
    margin-left: 0;
}

.solution-recipe-amount {
    flex: 0 0 60px;
    font-size: 14px;
    font-weight: 500;
    color: #4285F4;
    text-align: right;
}

/* UMF Container */
.solution-umf {
    margin-top: 15px;
    border-top: 1px solid #ddd;
    padding-top: 10px;
}

.solution-umf-title {
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

/* Стили для групп UMF */
.solution-umf-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.solution-umf-group {
    flex: 1;
    min-width: 120px;
}

.solution-umf-group-title {
    font-weight: bold;
    font-size: 0.9em;
    margin-bottom: 8px;
    color: #666;
    text-align: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.solution-umf-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.solution-umf-grid.single-column {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
}

.solution-umf-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}

.solution-umf-name {
    font-size: 0.9em;
}

.solution-umf-value {
    font-weight: bold;
    font-size: 0.9em;
}

.solution-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.solution-button {
    background-color: #4285F4;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
}

/* Status message */
.status-message {
    text-align: center;
    padding: 15px;
    color: #666;
    font-style: italic;
}

.loading-status {
    text-align: center;
    padding: 15px;
    color: #4285F4;
}

/* Стили для элемента индикации расчета */
.calculation-status {
    display: none;
    align-items: center;
    margin-left: 15px;
    font-size: 14px;
    color: #666;
}

.calculation-status.visible {
    display: flex;
}

/* Стили для спиннера */
.loader {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    margin-right: 8px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 600px) {
    .composition-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .ratio-info {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .ratio-buttons {
        margin-left: 0;
        margin-top: 10px;
    }
    
    .solution-umf-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .composition-table td:first-child {
        width: 55%;
    }
    
    .composition-table td:nth-child(2) {
        width: 35%;
    }
    
    .solutions-container {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 601px) and (max-width: 800px) {
    .composition-grid {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .solution-umf-groups {
        flex-direction: column;
    }
}

/* Стили для сравнения UMF */
.solution-umf-value.diff-high {
    color: #e74c3c;
    font-weight: bold;
}

.solution-umf-value.diff-medium {
    color: #f39c12;
    font-weight: bold;
}

.solution-umf-value.diff-low {
    color: #27ae60;
}

.solution-umf-value.diff-missing {
    color: #8e44ad;
    font-weight: bold;
}

.umf-comparison-legend {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #eee;
    font-size: 11px;
    color: #777;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.legend-title {
    font-weight: bold;
    margin-right: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.legend-color.diff-high {
    background-color: #e74c3c;
}

.legend-color.diff-medium {
    background-color: #f39c12;
}

.legend-color.diff-low {
    background-color: #27ae60;
}

/* Стили для материалов */
.materials-checklist {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    height: auto;
}

.material-item {
    display: flex;
    align-items: center;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s;
    font-size: 13px;
    margin-bottom: 1px;
}

.material-item:hover {
    background-color: #eee;
}

.material-item input[type="checkbox"] {
    margin-right: 4px;
}

.material-item label {
    cursor: pointer;
    user-select: none;
}

.loading-message, .error-message, .empty-message {
    padding: 10px;
    text-align: center;
    color: #666;
}

.error-message {
    color: #e74c3c;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .calculator-materials-wrapper {
        flex-direction: column;
    }
    
    .materials-container {
        max-width: none;
        width: 100%;
    }
}

/* Стили для секции настроек */
.control-section {
    margin: 10px 0 20px 0;
    padding: 10px;
    background-color: #f8f8f8;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.control-section h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    color: #333;
}

.control-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

/* Стилизация чекбоксов */
.control-checkbox {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 20px;
    margin-right: 15px;
    cursor: pointer;
    font-size: 13px;
    user-select: none;
}

.control-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    left: 0;
    top: 0;
    height: 14px;
    width: 14px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.control-checkbox:hover input ~ .checkmark {
    background-color: #f0f0f0;
}

.control-checkbox input:checked ~ .checkmark {
    background-color: #2196F3;
    border-color: #2196F3;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.control-checkbox input:checked ~ .checkmark:after {
    display: block;
}

.control-checkbox .checkmark:after {
    left: 5px;
    top: 2px;
    width: 3px;
    height: 7px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label {
    font-size: 13px;
    color: #333;
}

/* Стили для блока настроек */
.settings-card {
    width: 100%;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    padding: 0;
}

.settings-content {
    padding: 15px;
}

.settings-content .control-checkbox {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 13px;
    user-select: none;
}

/* Стиль для разделителя между R2O и RO оксидами */
.r2o-ro-divider {
    border-bottom: 1px solid rgba(0, 0, 0, 0.4) !important;
}

/* Применяем стиль разделителя к строкам таблицы */
tr.r2o-ro-divider {
    border-bottom: 1px solid rgba(0, 0, 0, 0.4) !important;
}

tr.r2o-ro-divider td {
    padding-bottom: 10px;
    margin-bottom: 8px;
}

tr.r2o-ro-divider + tr td {
    padding-top: 10px;
} 