/* ================================== */
/* ПАНЕЛИ ВЫБОРА ФАЙЛОВ (СКРЕПКА)    */
/* Десктопная и мобильная реализации  */
/* ================================== */

/* -------------------------------- */
/* 1. ОБЩИЕ СТИЛИ ДЛЯ ВКЛАДОК И КНОПКИ */
/* -------------------------------- */
.attach-desktop-tabs {
    display: flex;
    gap: 24px;
}

.attach-desktop-tab {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.attach-desktop-tab:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.attach-desktop-tab.active {
    color: var(--primary);
    background: var(--primary-glow);
}

/* Панель действий – относительное позиционирование */
.attach-desktop-action {
    position: relative;
    margin-top: 16px;
    margin-bottom: 4px;
    min-height: 52px;
}

/* Общий стиль для обеих кнопок */
.attach-desktop-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: none;
    color: var(--primary);
    font-size: 24px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.attach-desktop-action-btn:hover {
    background: var(--primary);
    color: white;
    transform: none;
    box-shadow: var(--shadow-md);
}

/* Кнопка "+" всегда по центру */
.attach-desktop-action .attach-plus-btn {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-base);
}

.attach-desktop-action .attach-plus-btn:hover {
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
}

/* Кнопка "Отправить" – справа */
.attach-desktop-action .attach-send-btn {
    position: absolute;
    right: 0;
    top: 0;
    width: auto;
    min-width: 100px;
    border-radius: var(--radius-full);
    background: var(--success);
    color: white;
    font-size: 14px;
    padding: 0 20px;
    gap: 8px;
}

.attach-desktop-action .attach-send-btn i {
    margin-right: 6px;
    font-size: 16px;
}

.attach-desktop-action .attach-send-btn:hover {
    background: var(--success-dark);
    transform: none;
    box-shadow: var(--shadow-md);
}

/* Светлая тема (уже через переменные, но оставляем для переопределения, если нужно) */
body.light-theme .attach-desktop-tab:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.light-theme .attach-desktop-action-btn {
    background: rgba(0, 0, 0, 0.06);
}

body.light-theme .attach-desktop-action-btn:hover {
    background: var(--primary);
    color: white;
}

/* -------------------------------- */
/* 2. МОБИЛЬНАЯ ПАНЕЛЬ (нижний дровер) */
/* -------------------------------- */
.attach-mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    animation: fadeIn var(--animation-duration) ease;
}

.attach-mobile-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    backdrop-filter: blur(24px);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-lg);
    z-index: calc(var(--z-modal) + 1);
    animation: slideUp 0.25s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    padding: 16px 20px 30px;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.attach-mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 16px;
}

.attach-mobile-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition-fast);
}

.attach-mobile-close:hover {
    color: var(--primary);
}

.attach-mobile-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    max-height: 60vh;
}

/* Сетка для медиа (3 колонки) */
.attach-media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

/* Стили для элементов медиа и файлов (общие) */
.attach-media-item,
.attach-file-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.attach-media-item {
    aspect-ratio: 1 / 1;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
}

.attach-media-item img,
.attach-media-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attach-video-thumb {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attach-video-thumb i {
    position: absolute;
    font-size: 32px;
    color: white;
    text-shadow: 0 0 4px black;
}

/* Список файлов */
.attach-files-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.attach-file-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 12px;
}

.attach-file-info {
    flex: 1;
}

.attach-file-name {
    font-weight: 500;
}

.attach-file-size,
.attach-file-caption {
    font-size: 12px;
    color: var(--text-secondary);
}

.attach-mobile-loading,
.attach-mobile-empty {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
}

/* Светлая тема для мобильной панели (уже через переменные) */
body.light-theme .attach-mobile-drawer {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
}

/* -------------------------------- */
/* 3. ДЕСКТОПНАЯ ПАНЕЛЬ (выпадающий блок) */
/* -------------------------------- */
.attach-desktop-drawer {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    width: 440px;
    max-width: calc(100vw - 32px);
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: var(--z-popover);
    overflow: hidden;
    animation: fadeSlideUp var(--animation-duration) ease;
    display: flex;
    flex-direction: column;
}

.attach-desktop-drawer .attach-mobile-header {
    padding: 12px 16px;
    margin-bottom: 0;
}

.attach-desktop-drawer .attach-mobile-content {
    padding: 12px 16px 16px;
    max-height: 460px;
}

/* Сетка на десктопе – 4 колонки */
.attach-desktop-drawer .attach-media-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}

.attach-desktop-drawer .attach-files-list {
    gap: 10px;
    margin-bottom: 18px;
}

.attach-desktop-drawer .attach-file-item {
    padding: 10px 12px;
}

/* Светлая тема для десктопной панели */
body.light-theme .attach-desktop-drawer {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: var(--shadow-lg);
}

/* -------------------------------- */
/* 4. УВЕЛИЧЕНИЕ ИКОНОК НА МОБИЛЬНЫХ */
/* -------------------------------- */
@media (max-width: 768px) {
    .attach-mobile-drawer .attach-desktop-tab {
        font-size: 28px;
        width: 48px;
        height: 48px;
        padding: 8px;
    }
    .attach-mobile-drawer .attach-desktop-action-btn {
        width: 56px;
        height: 56px;
        font-size: 32px;
    }
    .attach-mobile-drawer .attach-desktop-action {
        margin-top: 24px;
        margin-bottom: 8px;
    }
    .attach-desktop-action .attach-send-btn {
        min-width: 120px;
        font-size: 16px;
        padding: 0 24px;
    }
}

/* -------------------------------- */
/* 5. ВЫДЕЛЕНИЕ И ПАНЕЛЬ ДЕЙСТВИЙ, ЧЕКБОКСЫ */
/* -------------------------------- */
.attach-selection-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.attach-selection-count {
    font-size: 14px;
    font-weight: 500;
}

.attach-selection-buttons {
    display: flex;
    gap: 12px;
}

.attach-action-btn {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.attach-action-btn:hover {
    background: var(--bg-hover);
}

.attach-delete-btn:hover {
    color: var(--danger);
}

/* Чекбокс (круглый) – общие стили */
.attach-selection-checkbox {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    border: 1.5px solid rgba(255, 255, 255, 0.8);
    transition: all var(--transition-fast);
    cursor: pointer;
    z-index: 15;
}

.attach-selection-checkbox i {
    opacity: 0;
    transition: opacity var(--transition-fast);
    font-size: 12px;
}

.attach-selection-checkbox i.fa-check-circle {
    opacity: 1;
    color: var(--primary);
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.attach-selection-checkbox:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: var(--primary);
    transform: scale(1.05);
}

/* Подсветка выделенного элемента */
.attach-media-item.selected,
.attach-file-item.selected {
    box-shadow: 0 0 0 2px var(--primary);
    filter: brightness(0.9);
}

/* Светлая тема для чекбоксов и панели действий */
body.light-theme .attach-selection-checkbox {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.4);
}

body.light-theme .attach-selection-checkbox i.fa-check-circle {
    color: var(--primary);
}

body.light-theme .attach-selection-actions {
    background: rgba(0, 0, 0, 0.05);
}

body.light-theme .attach-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* -------------------------------- */
/* 6. УВАЖЕНИЕ PREFERS-REDUCED-MOTION */
/* -------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .attach-mobile-overlay,
    .attach-mobile-drawer,
    .attach-desktop-drawer,
    .attach-selection-checkbox,
    .attach-action-btn {
        animation: none;
        transition: none;
    }
    .attach-mobile-drawer {
        animation: none;
        transform: translateY(0);
    }
    .attach-desktop-drawer {
        animation: none;
    }
    .attach-selection-checkbox:hover {
        transform: none;
    }
}