/* =================== Bottom Navigation Bar =================== */

.bottom-nav {
    display: none;
}

/* "Добавить поле" — вне media query, чтобы !important не перебивался viewport-изменениями */
.fields-add-btn {
    background-color: #009521 !important;
    color: #fff !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    -webkit-tap-highlight-color: transparent !important;
}
.fields-add-btn:hover,
.fields-add-btn:active,
.fields-add-btn:focus,
.fields-add-btn:focus-visible,
.fields-add-btn:focus-within {
    background-color: #009521 !important;
    color: #fff !important;
    outline: none !important;
    box-shadow: none !important;
}

@media (max-width: 1024px) {

    /* ---- Сама панель ---- */
    .bottom-nav {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        bottom: calc(8px + env(safe-area-inset-bottom));
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 32px);
        max-width: 362px;
        height: 48px;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid #E4ECE7;
        border-radius: 58px;
        padding: 0 10px;
        box-sizing: border-box;
        z-index: 1100;
    }

    /* ---- Кнопки: только горизонтальный flex, позиция relative для ::after ---- */
    .bottom-nav-btn {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        align-self: center;
        width: 44px;
        height: 44px;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        line-height: 1;
        font-size: 0;
        vertical-align: middle;
        background: none;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        color: rgba(255, 255, 255, 0.75);
        text-decoration: none;
        flex-shrink: 0;
        transition: color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .bottom-nav-btn:hover,
    .bottom-nav-btn:active,
    .bottom-nav-btn:focus {
        color: #ffffff;
        background: none;
    }

    .bottom-nav-btn.active {
        color: #009521;
        background: none;
    }

    /* Зелёная полоска под активной иконкой — absolute, не влияет на layout */
    .bottom-nav-btn.active::after {
        content: '';
        position: absolute;
        bottom: 5px;
        left: 50%;
        transform: translateX(-50%);
        width: 20px;
        height: 2px;
        background: #009521;
        border-radius: 1px;
    }

    .bottom-nav-btn.disabled {
        color: rgba(255, 255, 255, 0.25);
        cursor: default;
        pointer-events: none;
    }

    /* ---- SVG иконки через mask-image ---- */
    .nav-icon {
        display: block;
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        background-color: currentColor;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
        -webkit-mask-size: contain;
        mask-size: contain;
        flex-shrink: 0;
    }

    .nav-icon-globe  { -webkit-mask-image: url(../icons/icon-globe.svg);  mask-image: url(../icons/icon-globe.svg);  }
    .nav-icon-note   { -webkit-mask-image: url(../icons/icon-note.svg);   mask-image: url(../icons/icon-note.svg);   }
    .nav-icon-farm   { -webkit-mask-image: url(../icons/icon-farm.svg);   mask-image: url(../icons/icon-farm.svg);   }
    .nav-icon-openai { -webkit-mask-image: url(../icons/icon-openai.svg); mask-image: url(../icons/icon-openai.svg); }
    .nav-icon-user   { -webkit-mask-image: url(../icons/icon-user.svg);   mask-image: url(../icons/icon-user.svg);   }

    /* ---- Скрываем бургер и боковое меню ---- */
    .menu-toggle-label,
    .menu-toggle-checkbox {
        display: none !important;
    }
    #sidebar {
        display: none !important;
    }
    #main-content {
        left: 0 !important;
        width: 100% !important;
    }

    /* ---- Скрываем плавающий Telegram ---- */
    .telegram-link-container {
        display: none !important;
    }

    /* =================== Поисковая строка =================== */

    /* Контейнер: pill слева, справа — 56px для MapPin */
    .mobile-search-container {
        position: fixed !important;
        top: 8px !important;
        left: 16px !important;
        right: 64px !important;   /* оставляем место под MapPin */
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        z-index: 1001 !important;
    }

    /* Инпут: pill, иконка поиска слева */
    #mobileSearchBox {
        width: 100% !important;
        height: 40px !important;
        background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 256 256'%3E%3Cpath d='M229.66%2C218.34l-50.07-50.07a88.11%2C88.11%2C0%2C1%2C0-11.31%2C11.31l50.06%2C50.07a8%2C8%2C0%2C0%2C0%2C11.32-11.31ZM40%2C112a72%2C72%2C0%2C1%2C1%2C72%2C72A72.08%2C72.08%2C0%2C0%2C1%2C40%2C112Z' fill='%23000000'%2F%3E%3C%2Fsvg%3E") no-repeat 12px center !important;
        padding: 0 14px 0 34px !important;
        border: 1px solid #E4ECE7 !important;
        border-radius: 58px !important;
        font-size: 16px !important;
        color: #000 !important;
        box-sizing: border-box !important;
        outline: none !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
    }

    #mobileSearchBox::placeholder {
        color: #aaa !important;
        font-size: 13px !important;
    }

    /* Прячем старую кнопку поиска */
    .mobile-search-button {
        display: none !important;
    }

    /* ---- MapPin: отдельный fixed элемент справа от поиска ---- */
    .my-location-button {
        position: fixed !important;
        top: 8px !important;
        right: 16px !important;
        width: 40px !important;
        height: 40px !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        transform: none !important;
        z-index: 1002 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .my-location-button button {
        width: 40px !important;
        height: 40px !important;
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
    }

    /* Скрываем оригинальный SVG геолокации */
    .my-location-button svg {
        display: none !important;
    }

    /* Рисуем MapPin из дизайна через mask */
    .my-location-button button::after {
        content: '';
        display: block;
        width: 28px;
        height: 28px;
        background-color: white;
        filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
        -webkit-mask-image: url(../icons/icon-mappin.svg);
        mask-image: url(../icons/icon-mappin.svg);
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
        -webkit-mask-size: contain;
        mask-size: contain;
    }

    /* ---- Превью-лента: только поднимаем над bottom nav ---- */
    #imagePreviewContainer {
        bottom: calc(64px + env(safe-area-inset-bottom)) !important;
        left: 0 !important;
        width: 100% !important;
    }

    /* ---- Compare: фикс responsive.css который задаёт 35x35 ---- */
    .compare-menu-toggle {
        width: 28px !important;
        height: 28px !important;
        top: 11px !important;
        background: white !important;
        overflow: hidden !important;
        box-shadow: 0 1px 4px rgba(0,0,0,0.25) !important;
        padding: 0 !important;
    }

    .calendar-toggle {
        width: 28px !important;
        height: 28px !important;
        background: white !important;
        overflow: hidden !important;
        box-shadow: 0 1px 4px rgba(0,0,0,0.25) !important;
    }

    .compare-menu-toggle img,
    .calendar-toggle img {
        width: 28px !important;
        height: 28px !important;
        display: block !important;
    }

    /* ---- Calendar: дата внутри кнопки ---- */
    .calendar-toggle.has-date {
        flex-direction: column !important;
        gap: 0 !important;
    }

    .calendar-toggle.has-date img {
        display: none !important;
    }

    .cal-date-day {
        font-size: 9px;
        font-weight: 700;
        color: #000;
        line-height: 1.1;
        text-align: center;
    }

    .cal-date-month {
        font-size: 7px;
        font-weight: 500;
        color: #333;
        line-height: 1.1;
        text-align: center;
        text-transform: capitalize;
    }

    /* Скрываем отдельные date-label — дата теперь внутри кнопки */
    .date-label {
        display: none !important;
    }

    /* =================== Fields Panel =================== */

    .fields-panel {
        display: none;
        position: fixed;
        inset: 0;
        background: #f2f2f7;
        z-index: 1050;
        flex-direction: column;
        overflow: hidden;
    }

    .fields-panel.open {
        display: flex;
    }

    .fields-panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 20px;
        padding-top: calc(14px + env(safe-area-inset-top));
        background: #000;
        color: #fff;
        flex-shrink: 0;
    }

    .fields-panel-title {
        font-size: 17px;
        font-weight: 600;
        color: #fff;
        letter-spacing: -0.2px;
    }

    .fields-panel-close {
        width: 36px;
        height: 36px;
        background: none;
        border: none;
        color: rgba(255,255,255,0.8);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        border-radius: 50%;
        -webkit-tap-highlight-color: transparent;
        margin-right: -8px;
    }

    .fields-panel-body {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
        -webkit-overflow-scrolling: touch;
    }

    .fields-panel-footer {
        flex-shrink: 0;
        padding: 12px 16px;
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
        background: #f2f2f7;
    }

    .fields-add-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 177px;
        height: 46px;
        background: #009521;
        color: #fff;
        border: none;
        border-radius: 40px;
        font-size: 12px;
        font-weight: 600;
        cursor: pointer;
        margin: 0 auto;
        padding: 0 20px;
        -webkit-tap-highlight-color: transparent;
        -webkit-appearance: none;
        appearance: none;
        outline: none;
        flex-shrink: 0;
    }

    .fields-agrigpt-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        flex: 1;
        max-width: 130px;
        height: 46px;
        background: #006CF8;
        color: #fff;
        border: none;
        border-radius: 40px;
        font-size: 12px;
        font-weight: 600;
        cursor: pointer;
        padding: 0 16px;
        -webkit-tap-highlight-color: transparent;
        -webkit-appearance: none;
        appearance: none;
        outline: none;
        flex-shrink: 0;
    }

    .fields-agrigpt-btn:active,
    .fields-agrigpt-btn:focus,
    .fields-agrigpt-btn:focus-visible {
        background: #006CF8 !important;
        outline: none !important;
        box-shadow: none !important;
    }

    .fields-add-btn:active,
    .fields-add-btn:focus,
    .fields-add-btn:focus-visible {
        background: #009521 !important;
        outline: none !important;
        box-shadow: none !important;
    }

    .fields-panel-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .field-card {
        display: flex;
        align-items: center;
        gap: 14px;
        background: #fff;
        border-radius: 16px;
        padding: 12px 14px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .field-card:active {
        background: #f8f8f8;
    }

    .field-card-thumb {
        width: 56px;
        height: 56px;
        border-radius: 10px;
        flex-shrink: 0;
        overflow: hidden;
        background: #4b5563;
    }

    .field-card-thumb canvas {
        display: block !important;
    }

    .field-card-info {
        flex: 1;
        min-width: 0;
    }

    .field-card-name {
        font-size: 16px;
        font-weight: 600;
        color: #111;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 4px;
    }

    .field-card-name--editing {
        font-size: 16px;
        font-weight: 600;
        color: #111;
        border: none;
        outline: none;
        background: #f0f0f0;
        border-radius: 6px;
        padding: 2px 6px;
        width: 100%;
        box-sizing: border-box;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 4px;
    }

    .field-card-meta {
        font-size: 13px;
        color: #888;
    }

    .field-card-actions {
        display: flex;
        align-items: center;
        gap: 2px;
        flex-shrink: 0;
    }

    .field-card-btn {
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        border-radius: 10px;
        color: #aaa;
        cursor: pointer;
        padding: 0;
        -webkit-tap-highlight-color: transparent;
    }

    .field-card-btn:active {
        background: rgba(0,0,0,0.06);
        color: #666;
    }

    .field-card-btn--delete {
        color: #e04040;
    }

    .field-card-btn--delete:active {
        color: #c03030;
    }

    .fields-panel-empty {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 48px 20px;
        gap: 14px;
        color: #bbb;
        font-size: 14px;
        text-align: center;
    }

    .fields-panel-empty svg {
        color: #ccc;
    }

    /* =================== User Panel Profile =================== */

    .user-panel-profile {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 40px 20px 20px;
        gap: 16px;
    }

    .user-panel-avatar {
        font-size: 72px;
        color: #ccc;
        line-height: 1;
    }

    .user-panel-info {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
    }

    .user-panel-email {
        font-size: 16px;
        font-weight: 500;
        color: #333;
        text-align: center;
        word-break: break-all;
    }

    /* ── Field edit modal ── */
    .field-edit-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 3000;
        display: flex;
        align-items: flex-end;
        justify-content: center;
    }

    .field-edit-modal {
        background: #fff;
        border-radius: 20px 20px 0 0;
        width: 100%;
        max-width: 480px;
        padding: 20px 20px calc(28px + env(safe-area-inset-bottom));
        box-sizing: border-box;
        max-height: 88vh;
        overflow-y: auto;
    }

    .field-edit-modal-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 22px;
    }

    .field-edit-modal-title {
        font-size: 18px;
        font-weight: 700;
        color: #111;
    }

    .field-edit-modal-close {
        width: 30px;
        height: 30px;
        background: #f2f2f2;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #555;
        font-size: 16px;
        line-height: 1;
        padding: 0;
        -webkit-tap-highlight-color: transparent;
    }

    .field-edit-group {
        margin-bottom: 14px;
    }

    .field-edit-label {
        font-size: 12px;
        font-weight: 600;
        color: #888;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        margin-bottom: 6px;
        display: block;
    }

    .field-edit-input,
    .field-edit-select {
        width: 100%;
        box-sizing: border-box;
        border: 1.5px solid #e5e5e5;
        border-radius: 10px;
        padding: 11px 13px;
        font-size: 16px;
        color: #111;
        background: #fafafa;
        outline: none;
        -webkit-appearance: none;
        appearance: none;
        font-family: inherit;
    }

    .field-edit-input:focus,
    .field-edit-select:focus {
        border-color: #22c55e;
        background: #fff;
    }

    .field-edit-dates {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .field-edit-save {
        width: 100%;
        margin-top: 22px;
        padding: 14px;
        background: #22c55e;
        color: #fff;
        border: none;
        border-radius: 12px;
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .field-edit-save:active {
        background: #16a34a;
    }

}

/* =================== Map Notes =================== */

#addNoteBtn {
    width: 177px;
}

.note-placing-hint {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    background: rgba(0,0,0,0.75);
    color: white;
    border-radius: 20px;
    padding: 10px 18px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.note-placing-hint button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    border-radius: 12px;
    padding: 4px 12px;
    font-size: 13px;
    cursor: pointer;
    width: auto;
    margin: 0;
}

.note-modal-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
}

.note-modal {
    background: white;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    padding: 0 0 env(safe-area-inset-bottom, 16px);
    animation: noteSlideUp 0.25s ease;
    pointer-events: all;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
}

@keyframes noteSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.note-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 12px;
    font-size: 17px;
    font-weight: 700;
    color: #111;
    border-bottom: 1px solid #f0f0f0;
}

.note-modal-close {
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

.note-modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.note-modal-label {
    font-size: 11px;
    font-weight: 700;
    color: #888;
    letter-spacing: 0.06em;
    margin-top: 4px;
}

.note-modal-input {
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid #e5e5e5;
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 16px;
    color: #111;
    background: #fafafa;
    outline: none;
    font-family: inherit;
    resize: vertical;
}

.note-modal-input:focus { border-color: #22c55e; background: #fff; }

.note-color-picker {
    display: flex;
    gap: 10px;
    margin: 4px 0 8px;
}

.note-color-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

.note-color-btn.selected {
    border-color: #111;
    transform: scale(1.15);
}

.note-modal-footer {
    display: flex;
    gap: 10px;
    padding: 0 20px 16px;
}

.note-modal-save {
    flex: 1;
    background: #22c55e;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin: 0;
    transition: background 0.2s;
}

.note-modal-save:hover { background: #16a34a; }

.note-modal-delete {
    background: #fee2e2;
    color: #ef4444;
    border: none;
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin: 0;
    width: auto;
    transition: background 0.2s;
}

.note-modal-delete:hover { background: #fecaca; }
