/* ============================================
   Калькулятор торта PRO+ — Стили
   ============================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #fff5f7 0%, #ffffff 50%, #fff8f0 100%);
    min-height: 100vh;
    color: #333;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
}

/* Контейнер */
.app {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 15px 40px;
    position: relative;
}

/* Водяной знак */
.watermark {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    opacity: 0.015;
}

.watermark span {
    position: absolute;
    font-size: 14px;
    font-weight: bold;
    color: #ff4d94;
    white-space: nowrap;
    transform: rotate(-30deg);
}

/* Заголовок */
.header {
    text-align: center;
    margin-bottom: 25px;
    position: relative;
    z-index: 1;
}

.header h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ff4d94, #ff7eb3, #ffa64d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
}

.header p {
    color: #aaa;
    font-size: 0.9rem;
}

/* Сетка форм */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

@media (max-width: 600px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

/* Блок формы */
.box {
    background: #fff;
    padding: 18px;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    border: 1px solid #f0f0f0;
}

.box h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #555;
    margin-bottom: 12px;
}

/* Поля ввода и селекты */
select,
input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #eee;
    border-radius: 12px;
    font-size: 1rem;
    background: #fff;
    color: #333;
    outline: none;
    transition: all 0.2s ease;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

input[type="text"]:focus,
select:focus {
    border-color: #ff7eb3;
    box-shadow: 0 0 0 4px rgba(255, 77, 148, 0.1);
}

.fields {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Ошибка в поле */
input.error,
textarea.error {
    border-color: #ff4d4d !important;
    animation: shake 0.4s ease, glow 1s ease-in-out 3;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

@keyframes glow {
    50% { box-shadow: 0 0 15px rgba(255, 0, 0, 0.4); }
}

/* Кнопки */
.btn {
    width: 100%;
    padding: 16px 20px;
    border: none;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #ff7eb3 0%, #ff4d94 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 77, 148, 0.3);
    margin-bottom: 15px;
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(255, 77, 148, 0.4);
    background: linear-gradient(135deg, #ff6ba3 0%, #ff3d84 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, #ffa64d 0%, #ff7eb3 50%, #ff4d94 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 126, 179, 0.3);
    margin-top: 15px;
}

.btn-secondary:hover {
    box-shadow: 0 6px 20px rgba(255, 126, 179, 0.4);
}

/* Кнопки действий */
.btn-outline {
    background: transparent;
    border: 2px solid;
    padding: 14px 16px;
}

.btn-pink {
    color: #ff4d94;
    border-color: #ffcce0;
    background: #fff5f8;
}

.btn-pink:hover {
    background: #ffebf2;
}

.btn-orange {
    color: #e67300;
    border-color: #ffd9b3;
    background: #fff8f0;
}

.btn-orange:hover {
    background: #fff0e0;
}

.btn-gray {
    color: #666;
    border-color: #ddd;
    background: #f9f9f9;
}

.btn-gray:hover {
    background: #f0f0f0;
}

/* Коэффициент */
.coef-box {
    background: #fff;
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    border: 1px solid #f0f0f0;
    position: relative;
    z-index: 1;
}

.coef-label {
    display: block;
    font-size: 0.85rem;
    color: #999;
    margin-bottom: 5px;
}

.coef-value {
    font-size: 2rem;
    font-weight: 800;
    color: #ddd;
    transition: color 0.3s ease;
}

.coef-value.active {
    background: linear-gradient(135deg, #ff4d94, #ffa64d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Секция ингредиентов */
.ingredients-section {
    margin-top: 20px;
    position: relative;
    z-index: 1;
}

.ingredients-section label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
}

textarea {
    width: 100%;
    height: 200px;
    padding: 15px;
    border: 2px solid #eee;
    border-radius: 16px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: all 0.2s ease;
    background: #fff;
    line-height: 1.6;
}

textarea:focus {
    border-color: #ff7eb3;
    box-shadow: 0 0 0 4px rgba(255, 77, 148, 0.1);
}

textarea::placeholder {
    color: #ccc;
}

/* Результат */
.result-section {
    margin-top: 20px;
    background: #fff;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    border: 1px solid #f0f0f0;
    position: relative;
    z-index: 1;
}

.result-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #555;
    margin-bottom: 12px;
}

.result-section pre {
    background: linear-gradient(135deg, #fafafa 0%, #fff5f8 100%);
    padding: 18px;
    border-radius: 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.8;
    border: 1px solid #ffebf2;
    color: #333;
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
}

/* Кнопки действий */
.actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
    position: relative;
    z-index: 1;
}

@media (max-width: 500px) {
    .actions {
        grid-template-columns: 1fr;
    }
}

/* Скрытие элементов */
.hidden {
    display: none !important;
}

/* Футер */
.footer {
    text-align: center;
    margin-top: 40px;
    font-size: 0.75rem;
    color: #ccc;
    position: relative;
    z-index: 1;
}

/* Toast уведомления */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(40, 40, 40, 0.95);
    color: #fff;
    padding: 18px 30px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    text-align: center;
    max-width: 90%;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Заблокированный UI при загрузке */
.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* Анимация загрузки в кнопке */
.btn.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 10px;
    border: 2px solid transparent;
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
