/* ==========================================
   КРАТКОЕ ОГЛАВЛЕНИЕ
   ==========================================

   ФАЙЛ: context-menu.css
   НАЗНАЧЕНИЕ: Стили для контекстного меню иконок (правый клик)

   СОДЕРЖАНИЕ:
   1. Контейнер меню (.context-menu)
   2. Пункты меню (.context-menu__item)
   3. Разделители (.context-menu__divider)
   4. Подменю (.context-menu__submenu)
   5. Состояния (hover, active, disabled)
   6. Адаптивные стили

   ========================================== */

/* ========================================== */
/* КОНТЕЙНЕР МЕНЮ                             */
/* ========================================== */

.context-menu {
    position: fixed;
    z-index: 100000;
    min-width: 200px;
    max-width: 280px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
    padding: 4px 0;
    display: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.context-menu.visible {
    display: block;
    animation: contextMenuFadeIn 0.15s ease-out;
}

@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========================================== */
/* ПУНКТЫ МЕНЮ                                */
/* ========================================== */

.context-menu__item {
    display: flex;
    align-items: center;
    padding: 5px 12px;
    cursor: pointer;
    transition: background-color 0.1s ease;
    position: relative;
    gap: 8px;
    white-space: nowrap;
}

.context-menu__item:hover {
    background-color: rgba(26, 107, 109, 0.1);
}

.context-menu__item:active {
    background-color: rgba(26, 107, 109, 0.2);
}

/* Иконка пункта меню */
.context-menu__icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    color: inherit;
}

/* Синяя иконка для воспроизведения */
.context-menu__item[data-action="play-audio"] .context-menu__icon {
    color: #2196F3;
}

/* Текст пункта меню */
.context-menu__text {
    flex: 1;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
}

.context-menu__info-btn {
    flex-shrink: 0;
    margin-left: auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid #999;
    background: none;
    color: #777;
    font-size: 11px;
    font-weight: 600;
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.context-menu__info-btn:hover {
    border-color: #1a6b6d;
    color: #1a6b6d;
    background: rgba(26, 107, 109, 0.08);
}

/* Стрелка для подменю */
.context-menu__arrow {
    font-size: 18px;
    color: #555;
    margin-left: auto;
    line-height: 1;
}

/* Галочка для toggle-пунктов */
.context-menu__check {
    font-size: 14px;
    color: #1a6b6d;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.context-menu__item--toggle.checked .context-menu__check {
    opacity: 1;
}

/* ========================================== */
/* ОПАСНЫЕ ДЕЙСТВИЯ (удаление)                */
/* ========================================== */

.context-menu__item--danger .context-menu__text {
    color: #e74c3c;
}

.context-menu__item--danger:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

/* ========================================== */
/* РАЗДЕЛИТЕЛИ                                */
/* ========================================== */

.context-menu__divider {
    height: 1px;
    background-color: rgba(0, 0, 0, 0.08);
    margin: 3px 12px;
}

/* ========================================== */
/* ПОДМЕНЮ (для "Переместить")                */
/* ========================================== */

.context-menu__item--submenu {
    position: relative;
}

.context-menu__submenu {
    position: absolute;
    left: 100%;
    top: -6px;
    min-width: 150px;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    display: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100001; /* Выше родительского меню */
}

.context-menu__item--submenu:hover .context-menu__submenu {
    display: block;
    animation: contextMenuFadeIn 0.15s ease-out;
}

.context-menu__submenu-item {
    display: flex;
    align-items: center;
    padding: 5px 12px;
    cursor: pointer;
    transition: background-color 0.1s ease;
    gap: 8px;
}

.context-menu__submenu-item:hover {
    background-color: rgba(26, 107, 109, 0.1);
}

.context-menu__submenu-item--current {
    color: #999;
    cursor: default;
}

.context-menu__submenu-item--current:hover {
    background-color: transparent;
}

.context-menu__submenu-icon {
    font-size: 12px;
}

.context-menu__submenu-text {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.context-menu__submenu-item--current .context-menu__submenu-text {
    color: #999;
}

/* ========================================== */
/* DISABLED СОСТОЯНИЕ                         */
/* ========================================== */

.context-menu__item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ========================================== */
/* АДАПТИВНЫЕ СТИЛИ                           */
/* ========================================== */

@media (max-width: 880px), ((min-width: 881px) and (max-width: 1024px) and (pointer: coarse)) {
    .context-menu {
        min-width: 180px;
        max-width: 250px;
        padding: 2px 0;
        /* Отступ снизу чтобы не перекрывалось системными кнопками Android */
        max-height: calc(100vh - 120px);
        max-height: calc(100dvh - 120px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .context-menu__item {
        padding: 5px 13px;
        min-height: 34px; /* Компактнее, но сохраняем безопасный тап */
    }

    .context-menu__text {
        font-size: 14px;
    }

    .context-menu__divider {
        margin: 3px 12px;
    }

    /* На мобильных подменю показываем снизу основного меню */
    .context-menu__submenu {
        left: 0;
        top: 100%;
        margin-top: 4px;
        min-width: 180px;
        /* Отступ для подменю */
        max-height: calc(100vh - 120px);
        max-height: calc(100dvh - 120px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    /* Мобильный UX для "Переместить":
       раскрываем подменю в потоке пункта, чтобы скролл был по всей ширине */
    .context-menu__item--submenu.is-open {
        flex-wrap: wrap;
        align-items: center;
    }

    .context-menu__item--submenu.is-open .context-menu__submenu {
        position: static;
        left: auto;
        top: auto;
        margin-top: 5px;
        width: 100%;
        min-width: 0;
        max-height: min(58dvh, 340px);
        border-radius: 7px;
        border: 1px solid rgba(0, 0, 0, 0.08);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
        -webkit-overflow-scrolling: touch;
    }

    /* Увеличиваем пункты подменю для touch */
    .context-menu__submenu-item {
        padding: 6px 14px;
    }

    .context-menu__submenu-text {
        font-size: 14px;
    }
}

/* Второй диапазон: от 490px до 340px */
@media (max-width: 490px) {
    .context-menu {
        min-width: 160px;
        max-width: 220px;
        padding: 2px 0;
    }

    .context-menu__item {
        padding: 4px 11px;
        min-height: 32px;
    }

    .context-menu__text {
        font-size: 13px;
    }

    /* На очень узких экранах подменю ещё ниже */
    .context-menu__submenu {
        margin-top: 2px;
    }

    .context-menu__item--submenu.is-open .context-menu__submenu {
        margin-top: 4px;
        max-height: min(56dvh, 300px);
    }

    .context-menu__submenu-item {
        padding: 5px 10px;
    }

    .context-menu__submenu-text {
        font-size: 13px;
    }

    .context-menu__divider {
        margin: 2px 10px;
    }
}

/* ========================================== */
/* ТЕМНАЯ ТЕМА (опционально)                  */
/* ========================================== */

@media (prefers-color-scheme: dark) {
    /* Пока не применяем темную тему, но структура готова */
}

/* ========================================== */
/* МОДАЛ "О ФАЙЛЕ"                            */
/* ========================================== */

.file-info-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100010;
}

.file-info-modal.visible {
    display: block;
}

.file-info-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.file-info-modal__content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 420px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-info-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.file-info-modal__title {
    font-size: 16px;
    font-weight: 600;
    color: #1a6b6d;
    margin: 0;
}

.file-info-modal__close {
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s ease;
}

.file-info-modal__close:hover {
    color: #333;
}

.file-info-modal__body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.file-info-modal__row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 14px;
}

.file-info-modal__row:last-child {
    margin-bottom: 0;
}

.file-info-modal__label {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.file-info-modal__value {
    font-size: 14px;
    color: #222;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.5;
}

.file-info-modal__value--muted {
    color: #999;
    font-style: italic;
}
