/* Уведомление об обновлении */
#update-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #00c853;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 10000;
    display: none;
    align-items: center;
    gap: 15px;
    font-weight: bold;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 90%;
}
#update-banner button {
    background: white;
    color: #00c853;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
#update-banner button.dismiss-btn {
    background: transparent;
    color: white;
    border: 1px solid white;
}
.update-warning {
    width: 100%;
    text-align: center;
    font-size: 12px;
    font-weight: normal;
    margin-top: 5px;
    opacity: 0.9;
}

/* БЛОКИРОВКА ГОРИЗОНТАЛЬНОГО СКРОЛЛА И ЗУМА */
html {
    /* Запрещаем прокрутку вбок на корню */
    overflow-x: hidden;
    /* Запрещаем "резиновый" отскок (bounce эффект) в веб-приложении */
    overscroll-behavior-x: none;
    width: 100%;
    height: 100%;
}

/* Применяем правила ко всем элементам для предотвращения распирания */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ОСНОВНОЙ ВИЗУАЛ */
body { 
    font-family: 'Segoe UI', sans-serif; 
    margin: 0; 
    padding: 0; 
    background-color: #eceff1; 
    min-height: 100vh; 
    display: flex;
    flex-direction: column;
    overflow-y: auto; 
    overflow-x: hidden; 
    touch-action: manipulation; 
    position: relative;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* Принудительно ограничиваем все крупные блоки */
.master-container, #master-sticky, .nav-container, .main-wrapper {
    max-width: 100vw;
    overflow-x: hidden;
}

/* ШАПКА И НАВИГАЦИЯ */
.header-nav { 
    background-color: #00aaff; 
    padding: calc(4px + env(safe-area-inset-top, 0px)) 8px 4px 8px; 
    display: grid; 
    grid-template-columns: 1fr auto 1fr; 
    align-items: center; 
    gap: 10px; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.3); 
    z-index: 1000; 
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    height: auto;
    min-height: 40px; 
    overflow-x: auto; 
    white-space: nowrap; 
    scrollbar-width: none; 
    touch-action: pan-x;
    overscroll-behavior-x: contain;
}
.header-nav::-webkit-scrollbar { display: none; }

/* КНОПКИ УПРАВЛЕНИЯ */
.clear-btn { background-color: #b71c1c; color: white; border: none; width: 30px; height: 30px; border-radius: 4px; cursor: pointer; font-weight: bold; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pin-btn { background-color: #546e7a; color: white; border: none; width: 30px; height: 30px; border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pin-btn.active { background-color: #0288d1; }
.nav-btn { background-color: #455a64; color: #cfd8dc; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 13px; text-transform: uppercase; white-space: nowrap; }
.nav-btn.active { background-color: #00c853; color: #fff; }

/* КОНТЕЙНЕРЫ */
.main-wrapper { 
    display: flex; 
    width: 100%; 
    padding: 5px; 
    padding-right: 20px; 
    margin-top: calc(43px + env(safe-area-inset-top, 0px)); 
    gap: 10px; 
    box-sizing: border-box; 
    align-items: flex-start;
}
    
.form-side { 
    flex: 0 0 55%; 
    background: white; 
    border-radius: 4px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.2); 
    padding: 5px; 
    box-sizing: border-box; 
    position: relative; 
}

.result-side { 
    flex: 0 0 45%; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    position: relative; 
}

/* ЛИПКАЯ ЗАЯВКА */
.sticky-header { 
    background: white; 
    padding: 3px 5px; 
    border-bottom: 2px solid #eee; 
    position: fixed; 
    top: calc(48px + env(safe-area-inset-top, 0px)); 
    left: 5px; 
    width: calc(55% - 14px); 
    z-index: 999; 
    box-sizing: border-box; 
    border-radius: 4px 4px 0 0; 
    box-shadow: 0 4px 6px -2px rgba(0,0,0,0.1); 
}
.sticky-header.unpinned { position: static !important; width: 100% !important; padding: 0 0 8px 0; margin-bottom: 10px; box-shadow: none; }

/* ЭЛЕМЕНТЫ ВВОДА */
#z_text {
    width: 100%;
    min-height: 75px;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #cfd8dc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 16px;
    resize: vertical; 
    line-height: 1.4em; 
}

#z_fixed { 
    display: none; 
    background: #f1f8e9; 
    padding: 5px; 
    border-radius: 6px; 
    border: 1px solid #c8e6c9; 
    line-height: 1.4em; 
    font-size: 12px; 
    color: #1b5e20; 
    white-space: normal; 
}

.btn-ok { margin-top: 6px; background: #4caf50; color: white; border: none; border-radius: 4px; padding: 10px; width: 100%; cursor: pointer; font-weight: bold; }
#survey-frame { width: 100%; height: auto; min-height: 300px; border: none; display: block; overflow: hidden !important; margin-top: 140px; }

/* ВЫДАЧА РЕЗУЛЬТАТА */
.btn-copy { 
    background-color: #278dda; 
    color: white;
    border: none; 
    padding: 12px 15px; 
    border-radius: 4px; 
    font-weight: bold;
    cursor: pointer; 
    text-transform: uppercase;
    position: fixed; 
    top: calc(48px + env(safe-area-inset-top, 0px)); 
    right: 10px; 
    width: calc(45% - 10px); 
    z-index: 1001; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.2); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

#output { 
    width: calc(45% - 10px); 
    position: fixed;
    top: calc(95px + env(safe-area-inset-top, 0px)); 
    right: 10px;
    bottom: 5px; 
    height: auto; 
    max-height: none; 
    overflow-y: auto; 
    box-sizing: border-box; 
    background: white; 
    padding: 5px; 
    border-radius: 4px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.2); 
    border: none; 
    font-family: 'Segoe UI', sans-serif; 
    font-size: 13px; 
    white-space: pre-wrap; 
    color: #263238; 
    line-height: 1.3; 
    scrollbar-width: none; 
    -ms-overflow-style: none; 
}

#output::-webkit-scrollbar { display: none; }

.res-row { margin-bottom: 2px; display: block; transition: background-color 0.3s ease; border-left: 3px solid transparent; }
.res-label { font-weight: 800; color: #1565c0; text-transform: uppercase; font-size: 11px; margin-right: 4px; }
.res-value { 
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; 
    color: #000; 
    font-size: 13px; 
    font-weight: 500;
}

.res-row.active-focus {
    background-color: #fff9c4;
    border-left: 3px solid #00c853;
    padding-left: 4px;
}

@media (max-width: 900px) { 
    .main-wrapper { 
        flex-direction: column; 
        padding: 3px; 
        margin-top: calc(50px + env(safe-area-inset-top, 0px)); 
        overflow-x: hidden; 
    } 

    .form-side { 
        padding: 4px !important; 
        flex: 0 0 100%; 
        width: 100%; 
        position: static; 
        box-shadow: none; 
    }

    .result-side { 
        flex: 0 0 100%; 
        width: 100%; 
        position: static; 
        padding: 4px; 
    } 

    .sticky-header { 
        position: static !important; 
        width: 100% !important; 
        padding: 0 0 8px 0; 
    } 

    #survey-frame { margin-top: 0 !important; } 

    .btn-copy { 
        position: static; 
        width: 100%; 
        margin-bottom: 8px; 
        box-sizing: border-box; 
    } 

    #output { 
        position: static; 
        width: 100%; 
        margin-top: 0; 
        transform: none !important; 
        max-height: none; 
    }

    #master-pin-btn { display: none !important; }
}

/* ЭКРАН ЗАГРУЗКИ (Loader) */
#loader-wrapper {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: #37474f;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.loader {
    width: 45px; height: 45px;
    border: 4px solid #cfd8dc;
    border-top: 4px solid #00c853;
    border-radius: 50%;
    animation: loader-spin 1s linear infinite;
}
.loader-text {
    margin-top: 15px;
    color: white;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding-top: env(safe-area-inset-top, 0px);
}
@keyframes loader-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.loader-hidden { opacity: 0; visibility: hidden; }

