/* CSS переменные для темной темы Telegram */
:root {
    /* Светлая тема по умолчанию */
    --tg-theme-bg-color: #ffffff;
    --tg-theme-text-color: #000000;
    --tg-theme-hint-color: #999999;
    --tg-theme-link-color: #2481cc;
    --tg-theme-button-color: #2481cc;
    --tg-theme-button-text-color: #ffffff;
    --tg-theme-secondary-bg-color: #f4f4f5;
    
    /* Дополнительные переменные */
    --bg-color: var(--tg-theme-bg-color);
    --text-color: var(--tg-theme-text-color);
    --secondary-bg: var(--tg-theme-secondary-bg-color);
    --border-color: rgba(0, 0, 0, 0.1);
    --card-bg: rgba(255, 255, 255, 0.95);
    --shadow-color: rgba(0, 0, 0, 0.1);
}

/* Темная тема */
.dark-theme {
    --bg-color: var(--tg-theme-bg-color);
    --text-color: var(--tg-theme-text-color);
    --secondary-bg: var(--tg-theme-secondary-bg-color);
    --border-color: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(30, 30, 30, 0.95);
    --shadow-color: rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 100%;
    min-height: 100vh;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.page {
    display: none;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    flex: 1;
    width: 100%;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 20px var(--shadow-color);
    backdrop-filter: blur(10px);
    margin: 0 auto;
}

.page.active {
    display: block;
    opacity: 1;
    transform: translateX(0);
}

/* Заголовки */
h2 {
    color: var(--text-color);
    margin-bottom: 24px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.3;
}

h3 {
    color: var(--text-color);
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
}

/* Формы */
.form-group {
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 500;
    font-size: 16px;
    opacity: 0.9;
}

input, select, textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    background: var(--secondary-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--tg-theme-button-color);
    box-shadow: 0 0 0 3px rgba(var(--tg-theme-button-color-rgb, 36, 129, 204), 0.1);
}

textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

/* Информационные блоки */
.weight-info, .selected-info, .file-upload-info {
    background: var(--secondary-bg);
    padding: 12px;
    border-radius: 10px;
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.8;
    border-left: 3px solid var(--tg-theme-link-color);
}

/* Кнопки */
.btn-primary, .btn-secondary {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn-primary:active, .btn-secondary:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-secondary {
    background: var(--secondary-bg);
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

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

/* Навигационные кнопки */
.navigation-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    position: sticky;
    bottom: 0;
    padding: 16px 0;
    background: var(--bg-color);
    border-radius: 20px;
}

.navigation-buttons .btn-primary,
.navigation-buttons .btn-secondary {
    flex: 1;
    margin: 0;
    min-height: 52px;
}

/* Начинки */
.filling-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.filling-option {
    border: 2px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--secondary-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.filling-option:active {
    transform: scale(0.95);
}

.filling-option.selected {
    border-color: var(--tg-theme-button-color);
    background: rgba(var(--tg-theme-button-color-rgb, 36, 129, 204), 0.1);
    box-shadow: 0 4px 12px rgba(var(--tg-theme-button-color-rgb, 36, 129, 204), 0.2);
}

.filling-option.selected-multiple {
    border-color: #f39c12;
    background: rgba(243, 156, 18, 0.1);
}

.filling-icon {
    font-size: 32px;
    margin-bottom: 8px;
    line-height: 1;
}

.filling-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
    font-size: 14px;
    text-align: center;
}

.filling-price {
    font-size: 14px;
    color: var(--tg-theme-link-color);
    font-weight: 500;
}

/* Карточка подтверждения */
.summary-card {
    background: var(--secondary-bg);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
}

.summary-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.summary-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.summary-section.total {
    background: var(--card-bg);
    padding: 16px;
    border-radius: 12px;
    margin-top: 16px;
    border: 2px solid var(--tg-theme-button-color);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 8px 0;
    align-items: flex-start;
}

.summary-item:last-child {
    margin-bottom: 0;
}

.summary-item .label {
    color: var(--text-color);
    opacity: 0.7;
    font-weight: 500;
    flex-shrink: 0;
    margin-right: 12px;
}

.summary-item .value {
    color: var(--text-color);
    font-weight: 600;
    text-align: right;
    flex: 1;
    word-break: break-word;
}

.total-price {
    color: var(--tg-theme-button-color) !important;
    font-size: 20px;
}

/* Сообщение об успехе */
.success-message {
    text-align: center;
    padding: 40px 20px;
    background: var(--secondary-bg);
    border-radius: 20px;
    margin-top: 24px;
    border: 2px solid #2ecc71;
    animation: fadeIn 0.5s ease;
}

.success-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: bounce 1s ease infinite;
}

.success-text {
    font-size: 22px;
    font-weight: 700;
    color: #27ae60;
    margin-bottom: 12px;
}

.success-subtext {
    color: var(--text-color);
    opacity: 0.8;
    font-size: 16px;
    line-height: 1.4;
}

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

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Загрузка файлов */
.file-upload {
    margin-top: 12px;
}

.file-upload input[type="file"] {
    display: none;
}

/* Кастомные стили для select */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23000' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px;
    padding-right: 40px;
}

.dark-theme select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23fff' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--secondary-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--tg-theme-link-color);
}

/* Адаптивность для очень маленьких экранов */
@media (max-width: 360px) {
    .container {
        padding: 12px;
    }
    
    .page {
        padding: 16px;
        border-radius: 16px;
    }
    
    h2 {
        font-size: 22px;
        margin-bottom: 20px;
    }
    
    .filling-options {
        grid-template-columns: 1fr;
    }
    
    .filling-option {
        min-height: 100px;
    }
    
    .navigation-buttons {
        flex-direction: column;
    }
}

/* Для больших экранов */
@media (min-width: 768px) {
    .container {
        max-width: 500px;
        margin: 0 auto;
        padding: 20px;
    }
    
    .filling-options {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Поддержка hover для десктопа */
@media (hover: hover) {
    .btn-primary:hover, .btn-secondary:hover {
        transform: translateY(-2px);
    }
    
    .filling-option:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 12px var(--shadow-color);
    }
    
    .filling-option:active {
        transform: scale(0.95);
    }
}

/* Улучшенная доступность для сенсорных устройств */
@media (pointer: coarse) {
    input, select, textarea, button {
        min-height: 44px;
    }
    
    .filling-option {
        min-height: 100px;
    }
}

/* iOS специфичные стили */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-font-smoothing: antialiased;
    }
    
    input, select, textarea {
        font-size: 16px; /* Предотвращает увеличение в iOS */
    }
}
