/* 
 * Стили для калькулятора загрузки меланжера
 * Адаптивный дизайн с поддержкой всех устройств
 */

/* Подключение шрифта Roboto */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

/* Основной контейнер калькулятора */
.melanger-calculator {
    font-family: 'Roboto', sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--melanger-bg-color, #f0f4f8);
    color: var(--melanger-text-color, #000000);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Заголовок калькулятора */
.melanger-header {
    text-align: center;
    margin-bottom: 30px;
}

.melanger-title {
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 15px;
    line-height: 1.4;
}

/* Блок конвертации процентов в граммы */
.conversion-block {
    text-align: center;
    font-size: 32px;
    font-weight: 700;
    margin: 30px 0;
    color: #2c3e50;
}

.conversion-arrow {
    font-size: 48px;
    margin: 0 20px;
    color: #e74c3c;
}

/* Основные блоки калькулятора */
.calculator-block {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.calculator-block h3 {
    margin-top: 0;
    font-weight: 500;
    font-size: 18px;
}

/* Поле общего веса */
.total-weight-container {
    position: relative;
    margin-bottom: 20px;
}

.total-weight-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    font-family: 'Roboto', sans-serif;
    transition: border-color 0.3s ease;
}

.total-weight-input:focus {
    outline: none;
    border-color: #3498db;
}

/* Контейнер для ингредиентов */
.ingredients-container {
    margin-bottom: 20px;
}

/* === Блок .ingredient-row для десктопов === */

/* Обёртка строки ингредиента */
.ingredient-row {
  display: flex;           /* горизонтальный флекс-контейнер */
  align-items: center;     /* вертикальное центрирование */
  height: 40px;            /* фиксированная высота = диаметр кнопки */
  gap: 8px;                /* расстояние между элементами */
  flex-wrap: nowrap;       /* запрет переноса на новую строку */
  margin-bottom: 15px;
}

/* Название ингредиента */
.ingredient-name {
  flex: 1 1 auto;          /* растягивается на всё оставшееся место */
  min-width: 0;            /* позволяет сжиматься при ограничении ширины */
  padding: 0 10px;         /* внутренние отступы слева/справа */
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  border: 2px solid #ddd;
  border-radius: 6px;
  text-align: left;        /* текст по левому краю */
}

/* Поле процентов */
.ingredient-percent {
  flex: 0 0 8ch;          /* не растягивается и не сжимается */
  width: 5ch;              /* ширина под ~5 символов */
  height: 100%;            /* подстраивается под высоту строки */
  padding: 0 4px;          /* внутренние отступы */
  text-align: center;      /* центрируем цифры */
  border: 2px solid #ddd;
  border-radius: 6px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
}

/* Поле граммов */
.ingredient-grams {
  flex: 0 0 10ch;          /* фиксированная ширина */
  width: 8ch;              /* ширина под ~8 символов */
  height: 100%;            /* высота = строке */
  padding: 0 4px;          /* внутренние отступы */
  text-align: center;      /* центрируем цифры */
  background-color: #f8f9fa;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 500;
}

/* Кнопка удаления (корзина) */
.remove-ingredient {
  flex: 0 0 auto;          /* не меняет размер flex-контейнера */
  width: 40px;             /* диаметр = высота строки */
  height: 40px;            /* диаметр круга */
  border-radius: 50%;      /* делаем круглой */
  background-color: #e74c3c;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;           /* для центрирования иконки */
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.remove-ingredient:hover {
  background-color: #c0392b; /* тёмнее при наведении */
}

/* Особенности отдельных полей */
.ingredient-name {
    text-align: left;
}

.ingredient-grams {
    background-color: #f8f9fa;
    font-weight: 500;
}

.remove-ingredient {
    background-color: #e74c3c;
    color: #fff;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.remove-ingredient:hover {
    background-color: #c0392b;
}
/* === Конец изменяемого блока === */

/* Кнопка добавления ингредиента */
.add-ingredient-btn {
    width: 100%;
    padding: 15px;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-bottom: 20px;
    margin-top: 15px;
}

.add-ingredient-btn:hover {
    background-color: #229954;
}

/* Поле названия рецепта и загрузки логотипа */
.recipe-info {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.recipe-name-input {
    flex: 1;
    min-width: 200px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
}

.logo-upload-btn {
    padding: 12px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.logo-upload-btn:hover {
    background-color: #2980b9;
}

/* Скрытое поле для загрузки файла */
.logo-input {
    display: none;
}

/* Превью загруженного логотипа */
.logo-preview {
    max-width: 100px;
    max-height: 60px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* Прогресс-бар */
.progress-container {
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    border-radius: 10px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    font-size: 12px;
}

/* Памятка по загрузке меланжера */
.melanger-guide {
    margin: 20px 0;
}

.guide-toggle {
    width: 100%;
    padding: 15px;
    background-color: #34495e;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.3s ease;
}

.guide-toggle:hover {
    background-color: #2c3e50;
}

.guide-content {
    display: none;
    padding: 20px;
    background-color: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
}

.guide-content.active {
    display: block;
}

/* Рекламные блоки */
.ad-blocks {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.ad-block {
    flex: 1;
    min-width: 250px;
    height: 120px;
    background-color: white;
    border: 2px dashed #ddd;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 14px;
}

/* Боковые кнопки управления */
.side-controls {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 1000;
}

.control-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background-color: #3498db;
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: scale(1.1);
    background-color: #2980b9;
}

.control-btn.clear-all {
    background-color: #e74c3c;
}

.control-btn.clear-all:hover {
    background-color: #c0392b;
}

.control-btn.share {
    background-color: #f39c12;
}

.control-btn.share:hover {
    background-color: #e67e22;
}

.control-btn.download-pdf {
    background-color: #27ae60;
}

.control-btn.download-pdf:hover {
    background-color: #229954;
}

/* Подвал */
.calculator-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    font-size: 14px;
    color: #666;
}

.footer-logo {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-left: 5px;
}

/* === Здесь исправляем только медиа-правило для ingredient-row === */
/* Адаптивность для планшетов */
@media (max-width: 768px) {
    .melanger-calculator {
        padding: 15px;
    }
    
    .conversion-block {
        font-size: 24px;
    }
    
    .conversion-arrow {
        font-size: 32px;
        margin: 0 10px;
    }
    
    /* Изменили логику расположения только для .ingredient-row */

  .ingredient-row {
    flex-wrap: wrap;       /* разрешаем перенос на вторую «строку» */
    height: auto;          /* высота по содержимому */
    gap: 6px;              /* чуть меньше отступ */
  }

  .ingredient-name {
    flex: 0 0 100%;        /* первая «строка» во всю ширину */
    margin-bottom: 4px;    /* отступ до следующей «строки» */
  }

  .ingredient-percent,
  .ingredient-grams {
    flex: 1 1 0;        /* делят доступное место поровну */
    min-width: 0;          /* могут сжиматься */
  }

  .remove-ingredient {
    flex: 0 0 40px;        /* круглая кнопка без изменений */
     margin-left: auto;
  }
}
    
    /* Остальные старые правила в медиа без изменений */
    .recipe-info {
        flex-direction: column;
        align-items: stretch;
    }
    
    .ad-blocks {
        flex-direction: column;
    }
    
    .side-controls {
        position: static;
        transform: none;
        flex-direction: row;
        justify-content: center;
        margin: 20px 0;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }
}

/* Адаптивность для смартфонов */
@media (max-width: 480px) {
    .melanger-calculator {
        padding: 10px;
    }
    
    .calculator-block {
        padding: 15px;
    }
    
    .melanger-title {
        font-size: 20px;
    }
    
    .conversion-block {
        font-size: 18px;
    }
    
    .conversion-arrow {
        font-size: 24px;
        margin: 0 5px;
    }
    
    .total-weight-input,
    .ingredient-name,
    .ingredient-percent,
    .ingredient-grams,
    .recipe-name-input {
        padding: 8px;
        font-size: 14px;
    }
    
    .add-ingredient-btn,
    .logo-upload-btn {
        padding: 12px;
        font-size: 14px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ingredient-row {
    animation: fadeIn 0.3s ease-out;
}

/* Стили для iOS устройств */
@supports (-webkit-appearance: none) {
    .control-btn {
        -webkit-appearance: none;
    }
}

/* Стили для уведомлений */
.melanger-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    background-color: #27ae60;
    color: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    max-width: 300px;
    animation: slideIn 0.3s ease-out;
}

.melanger-notification.error {
    background-color: #e74c3c;
}

.melanger-notification.warning {
    background-color: #f39c12;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Стили для загрузки */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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