/* Кнопка швидкого фільтру заміток на карті */
.map-notes-filter-btn {
    position: absolute;
    top: 180px; /* Вниз від GPS кнопки (126px + 44px GPS + 10px відступ) */
    right: 17px; /* На одній лінії з GPS кнопкою */
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #FF6B35, #F7931E);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
}

.map-notes-filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
    background: linear-gradient(135deg, #F7931E, #FF6B35);
}

.map-notes-filter-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.map-notes-filter-btn.active {
    background: linear-gradient(135deg, #198754, #20C997);
    color: white;
    box-shadow: 0 4px 12px rgba(25, 135, 84, 0.4);
}

.map-notes-filter-btn.active:hover {
    background: linear-gradient(135deg, #20C997, #198754);
    box-shadow: 0 6px 16px rgba(25, 135, 84, 0.5);
}

/* Responsive стилі для кнопки заміток */
@media (max-width: 768px) {
    .map-notes-filter-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
        top: 177px; /* Вниз від GPS кнопки (126px + 42px GPS + 9px відступ) */
        right: 16px; /* На одній лінії з GPS кнопкою */
    }
}

@media (max-width: 480px) {
    .map-notes-filter-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
        top: 175px; /* Вниз від GPS кнопки для маленьких екранів */
        right: 16px; /* На одній лінії з GPS кнопкою */
    }
}

/* Landscape орієнтація на мобільних */
@media (max-width: 768px) and (orientation: landscape) {
    .map-notes-filter-btn {
        top: 156px !important; /* Вниз від GPS кнопки в landscape (116px + 40px GPS button) */
        right: 15px !important; /* На одній лінії з GPS кнопкою */
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }
}

/* Стилі для позначення ділянок з замітками */

/* Основний стиль для ділянок з замітками */
.parcel-with-notes {
    stroke: #FF6B35 !important;
    stroke-width: 3 !important;
    stroke-dasharray: 5, 5 !important;
    animation: parcel-notes-pulse 2s infinite;
}

/* Анімація пульсування для ділянок з замітками */
@keyframes parcel-notes-pulse {
    0% {
        stroke-opacity: 0.8;
    }
    50% {
        stroke-opacity: 1;
    }
    100% {
        stroke-opacity: 0.8;
    }
}

/* Спеціальні стилі для легенди заміток */
.notes-legend-item {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    margin: 2px 0;
    background-color: rgba(255, 107, 53, 0.1);
    border-left: 4px solid #FF6B35;
    border-radius: 4px;
    font-size: 12px;
}

.notes-legend-item .notes-indicator {
    width: 16px;
    height: 3px;
    background: repeating-linear-gradient(
        to right,
        #FF6B35 0px,
        #FF6B35 5px,
        transparent 5px,
        transparent 10px
    );
    margin-right: 8px;
    border-radius: 1px;
}

/* Tooltip для ділянок з замітками */
.parcel-notes-tooltip {
    background-color: #FF6B35;
    color: white;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    position: relative;
}

.parcel-notes-tooltip::after {
    content: "";
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #FF6B35;
}

/* Стилі для індикатора заміток у попапі */
.popup-notes-indicator {
    display: inline-flex;
    align-items: center;
    margin-top: 5px;
}

.popup-notes-indicator .view-notes-btn {
    background: linear-gradient(135deg, #20c997, #198754);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(32, 201, 151, 0.2);
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    justify-content: center;
}

.popup-notes-indicator .view-notes-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(32, 201, 151, 0.3);
    background: linear-gradient(135deg, #198754, #20c997);
}

.notes-count-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 5px;
}

/* Старий стиль індикатора (залишаємо для сумісності) */
.popup-notes-indicator i {
    margin-right: 3px;
    font-size: 10px;
}

/* Стилі для модального вікна перегляду заміток */
#parcelNotesModal .modal-header {
    background: linear-gradient(135deg, #20c997, #198754);
    color: white;
    border-bottom: none;
}

#parcelNotesModal .modal-header .btn-close {
    filter: invert(1);
    width: 1.5rem;
    height: 1.5rem;
    background-size: 1rem;
    opacity: 0.8;
    font-size: 1.2rem;
}

/* Загальні стилі для всіх модальних вікон */
.modal .modal-footer {
    padding: 0.75rem !important;
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.modal .modal-footer .btn {
    font-size: 12px !important;
    padding: 8px 12px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    flex: 1 1 auto;
    min-width: 90px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.modal .modal-footer .btn i {
    font-size: 13px !important;
    margin-right: 5px !important;
}

/* Мобільні стилі для всіх модальних вікон */
@media (max-width: 768px) {
    .modal .modal-footer {
        padding: 0.5rem !important;
        gap: 0.25rem;
        flex-direction: row;
        justify-content: space-between;
    }
    
    .modal .modal-footer .btn {
        font-size: 10px !important;
        padding: 5px 8px !important;
        flex: 1 1 30%;
        min-width: 70px;
        max-width: 32%;
    }
    
    .modal .modal-footer .btn i {
        font-size: 11px !important;
        margin-right: 3px !important;
    }
}

/* Компактні кнопки в модальному вікні заміток */
#parcelNotesModal .modal-footer {
    padding: 0.75rem !important;
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

#parcelNotesModal .modal-footer .btn {
    font-size: 11px !important;
    padding: 6px 10px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    flex: 1 1 auto;
    min-width: 80px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

#parcelNotesModal .modal-footer .btn i {
    font-size: 14px !important;
    margin-right: 5px !important;
}

/* Мобільні стилі для кнопок модального вікна */
@media (max-width: 768px) {
    #parcelNotesModal .modal-header .btn-close {
        width: 1.8rem !important;
        height: 1.8rem !important;
        background-size: 1.2rem !important;
        opacity: 0.9 !important;
        font-size: 1.4rem !important;
    }
    
    #parcelNotesModal .modal-footer {
        padding: 0.5rem !important;
        gap: 0.25rem;
        flex-direction: row;
        justify-content: space-between;
    }
    
    #parcelNotesModal .modal-footer .btn {
        font-size: 11px !important;
        padding: 6px 8px !important;
        flex: 1 1 30%;
        min-width: 70px;
        max-width: 32%;
    }
    
    #parcelNotesModal .modal-footer .btn i {
        font-size: 12px !important;
        margin-right: 3px !important;
    }
}

/* Стилі для дуже маленьких екранів */
@media (max-width: 480px) {
    #parcelNotesModal .modal-header .btn-close {
        width: 2rem !important;
        height: 2rem !important;
        background-size: 1.3rem !important;
        opacity: 1 !important;
        font-size: 1.5rem !important;
    }
    
    #parcelNotesModal .modal-footer .btn {
        font-size: 10px !important;
        padding: 5px 6px !important;
    }
    
    #parcelNotesModal .modal-footer .btn i {
        font-size: 11px !important;
        margin-right: 2px !important;
    }
    
    /* Скорочуємо текст на кнопках для мобільних */
    #parcelNotesModal .modal-footer .btn:nth-child(1) .btn-text::after {
        content: "Додати";
    }
    
    #parcelNotesModal .modal-footer .btn:nth-child(2) .btn-text::after {
        content: "Всі";
    }
    
    #parcelNotesModal .modal-footer .btn:nth-child(3) .btn-text::after {
        content: "Закрити";
    }
    
    #parcelNotesModal .modal-footer .btn .btn-text {
        font-size: 0;
    }
}

#parcelNotesModal .modal-title code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

#parcelNotesModal .note-item {
    background: #f8f9fa;
    transition: all 0.2s ease;
}

#parcelNotesModal .note-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#parcelNotesModal .note-item h6 {
    color: #495057;
    font-weight: 600;
}

#parcelNotesModal .badge {
    font-size: 0.7rem;
    font-weight: 500;
}

#parcelNotesModal .modal-footer {
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

/* Responsive стилі для модального вікна */
@media (max-width: 768px) {
    #parcelNotesModal .modal-dialog {
        margin: 0.25rem;
        max-width: calc(100vw - 0.5rem);
    }
    
    #parcelNotesModal .note-item {
        padding: 0.75rem !important;
    }
    
    #parcelNotesModal .note-item h6 {
        font-size: 0.9rem;
    }
    
    #parcelNotesModal .note-item .d-flex {
        flex-wrap: wrap;
        gap: 0.25rem !important;
    }
}

/* Кнопка створення замітки в попапі */
.create-note-btn {
    background: linear-gradient(135deg, #FF6B35, #F7931E);
    color: white !important;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(255, 107, 53, 0.3);
    letter-spacing: 0.2px;
}

.create-note-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(255, 107, 53, 0.4);
    background: linear-gradient(135deg, #F7931E, #FF6B35);
    color: white !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.create-note-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(255, 107, 53, 0.3);
}

/* Загальні стилі для всіх кнопок дій в попапі */
.parcel-action-button {
    font-size: 12px !important;
    font-weight: 600 !important;
    padding: 6px 10px !important;
    border-radius: 6px !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
    letter-spacing: 0.1px !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.parcel-action-button:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15) !important;
}

/* Кнопка ДЗК */
.dzk-button {
    background: linear-gradient(135deg, #0d6efd, #0b5ed7) !important;
    color: white !important;
    border: 1px solid #0d6efd !important;
}

.dzk-button:hover {
    background: linear-gradient(135deg, #0b5ed7, #0d6efd) !important;
    color: white !important;
    border: 1px solid #0b5ed7 !important;
}

/* Фільтр для ділянок з замітками в панелі фільтрів */
.notes-filter-btn {
    background-color: #FF6B35;
    border-color: #FF6B35;
    color: white;
}

.notes-filter-btn:hover {
    background-color: #F7931E;
    border-color: #F7931E;
    color: white;
}

.notes-filter-btn.active {
    background-color: #D63384;
    border-color: #D63384;
    box-shadow: 0 0 0 0.2rem rgba(255, 107, 53, 0.5);
}

/* Стилі для відображення статистики заміток */
.notes-stats {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.1), rgba(247, 147, 30, 0.1));
    border: 1px solid rgba(255, 107, 53, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 4px 0;
}

.notes-stats-count {
    font-size: 18px;
    font-weight: bold;
    color: #FF6B35;
}

.notes-stats-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive стилі для мобільних пристроїв */
@media (max-width: 768px) {
    .parcel-with-notes {
        stroke-width: 2 !important;
    }
    
    .notes-legend-item {
        padding: 3px 6px;
        font-size: 11px;
    }
    
    .popup-notes-indicator {
        font-size: 10px;
        padding: 1px 4px;
    }
    
    .create-note-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    /* Стилі для універсальної кнопки заміток */
    .universal-notes-btn {
        background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
        border: 1px solid #dc3545 !important;
        color: white !important;
        border-radius: 6px;
        padding: 6px 10px;
        font-size: 12px;
        font-weight: 600;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        gap: 4px;
        box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
        min-width: fit-content;
        white-space: nowrap;
        letter-spacing: 0.2px;
    }
    
    .universal-notes-btn:hover {
        background: linear-gradient(135deg, #c82333 0%, #a02127 100%) !important;
        transform: translateY(-1px);
        box-shadow: 0 3px 6px rgba(220, 53, 69, 0.5) !important;
        color: white !important;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
    }
    
    .universal-notes-btn:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3) !important;
    }
    
    .universal-notes-btn .notes-btn-text {
        font-size: 11px;
        line-height: 1.1;
        font-weight: 600;
        letter-spacing: 0.2px;
        color: white !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    }
    
    .universal-notes-btn .notes-btn-icon {
        font-size: 12px;
        flex-shrink: 0;
        color: white !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    }
    
    .universal-notes-btn .notes-count-badge {
        background: rgba(255, 255, 255, 0.35) !important;
        color: white !important;
        border-radius: 10px;
        padding: 1px 4px;
        font-size: 10px;
        font-weight: 600;
        margin-left: 2px;
        min-width: 16px;
        text-align: center;
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    /* Приховуємо стару кнопку створення при використанні універсальної */
    .popup-content .create-note-btn {
        display: none;
    }
    
    .popup-content .universal-notes-btn {
        display: flex;
    }
    
    /* Мобільні стилі для універсальної кнопки */
    @media (max-width: 768px) {
        .universal-notes-btn {
            padding: 5px 8px;
            font-size: 11px;
            gap: 3px;
            border-radius: 5px;
        }
        
        .universal-notes-btn .notes-btn-text {
            font-size: 10px;
            font-weight: 600;
            color: white !important;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
        }
        
        .universal-notes-btn .notes-btn-icon {
            font-size: 11px;
            color: white !important;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
        }
        
        .universal-notes-btn .notes-count-badge {
            font-size: 9px;
            padding: 1px 3px;
            min-width: 14px;
        }
    }
    
    /* Виправлення модального вікна на мобільних пристроях */
    #parcelNotesModal .modal-dialog {
        margin: 0.25rem !important;
        max-width: calc(100vw - 0.5rem) !important;
        width: calc(100vw - 0.5rem) !important;
        position: relative;
        left: 0;
        right: 0;
        transform: none !important;
    }
    
    #parcelNotesModal .modal-content {
        width: 100% !important;
        max-height: 90vh;
        overflow: hidden;
        border-radius: 0.75rem;
        margin: 0 auto;
    }
    
    #parcelNotesModal .modal-body {
        max-height: 70vh !important;
        overflow-y: auto;
        padding: 0.75rem !important;
        -webkit-overflow-scrolling: touch;
    }
    
    #parcelNotesModal .modal-header {
        padding: 0.75rem !important;
        flex-shrink: 0;
    }
    
    #parcelNotesModal .modal-footer {
        padding: 0.75rem !important;
        flex-shrink: 0;
    }
    
    /* Виправлення backdrop та fade анімації на мобільних */
    #parcelNotesModal.modal {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    #parcelNotesModal .modal-dialog {
        transition: transform 0.3s ease-out;
    }
    
    #parcelNotesModal.fade .modal-dialog {
        transform: translateY(-30px);
    }
    
    #parcelNotesModal.show .modal-dialog {
        transform: translateY(0);
    }
    
    /* Спеціальний клас для мобільного модального вікна */
    #parcelNotesModal.mobile-modal .modal-dialog {
        margin: 0.25rem !important;
        max-width: calc(100vw - 0.5rem) !important;
        width: calc(100vw - 0.5rem) !important;
        height: auto !important;
        display: flex !important;
        align-items: flex-start !important;
        padding-top: 0.5rem;
    }
    
    #parcelNotesModal.mobile-modal .modal-content {
        width: 100% !important;
        max-height: calc(100vh - 1rem) !important;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    
    #parcelNotesModal.mobile-modal .modal-body {
        flex: 1;
        overflow-y: auto;
        max-height: calc(100vh - 8rem) !important;
    }
}

/* Додаткові стилі для дуже маленьких екранів */
@media (max-width: 480px) {
    #parcelNotesModal .modal-dialog {
        margin: 0.125rem !important;
        max-width: calc(100vw - 0.25rem) !important;
        width: calc(100vw - 0.25rem) !important;
    }
    
    #parcelNotesModal .modal-content {
        max-height: 95vh;
        border-radius: 0.5rem;
    }
    
    #parcelNotesModal .modal-body {
        max-height: 75vh !important;
        padding: 0.5rem !important;
    }
    
    #parcelNotesModal .modal-header,
    #parcelNotesModal .modal-footer {
        padding: 0.5rem !important;
    }
    
    #parcelNotesModal .modal-title {
        font-size: 0.9rem !important;
    }
    
    #parcelNotesModal .note-item {
        padding: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    #parcelNotesModal .note-item h6 {
        font-size: 0.85rem !important;
    }
    
    #parcelNotesModal .note-content {
        font-size: 0.8rem !important;
        line-height: 1.4;
    }
}

/* Стилі для темної теми (якщо потрібно) */
@media (prefers-color-scheme: dark) {
    .notes-legend-item {
        background-color: rgba(255, 107, 53, 0.2);
        color: white;
    }
    
    .notes-stats {
        background: linear-gradient(135deg, rgba(255, 107, 53, 0.2), rgba(247, 147, 30, 0.2));
        border-color: rgba(255, 107, 53, 0.3);
    }
    
    .notes-stats-label {
        color: #ccc;
    }
}

/* Запобігання горизонтального скролу на мобільних */
@media (max-width: 768px) {
    body.modal-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
    }
    
    .modal {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    .modal-backdrop {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
    }
}
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Додаткові поліпшення для модального вікна */
#parcelNotesModal .modal-body {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

#parcelNotesModal .note-content {
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#parcelNotesModal .note-tags .badge {
    font-size: 0.7rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

/* Анімації для модального вікна */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: scale(0.9);
}

.modal.show .modal-dialog {
    transform: scale(1);
}

.modal-shown .modal-content {
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Поліпшення фокусування */
.modal .btn-close:focus,
.modal .btn:focus {
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
    outline: none;
}

.note-item:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}
