/**
 * admin-messages.css - Стили для административных сообщений (колокольчик)
 * Версия: 4.0 - Исправлено позиционирование, полная адаптивность
 */

/* ================================================================ */
/* ОСНОВНОЙ КОНТЕЙНЕР                                              */
/* ================================================================ */

.admin-messages-module {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    z-index: 9999;
    margin: 0 4px;
}


/* ================================================================ */
/* КНОПКА КОЛОКОЛЬЧИКА                                              */
/* ================================================================ */

.admin-bell-btn {
    position: relative;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(212, 175, 55, 0.4);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.admin-bell-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: #d4af37;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.admin-bell-btn:active {
    transform: scale(0.95);
}

.admin-bell-btn .bell-icon {
    font-size: 22px;
    line-height: 1;
    transition: transform 0.3s ease;
}

.admin-bell-btn.has-unread .bell-icon {
    animation: bellRing 0.5s ease 2;
}

@keyframes bellRing {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    50% { transform: rotate(15deg); }
    75% { transform: rotate(-10deg); }
    100% { transform: rotate(0deg); }
}


/* ================================================================ */
/* БЕЙДЖ С КОЛИЧЕСТВОМ                                              */
/* ================================================================ */

.bell-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #003366;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
    font-family: 'Montserrat', sans-serif;
    animation: badgePop 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.bell-badge.pulse {
    animation: badgePulse 1s ease 2;
}

@keyframes badgePop {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes badgePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}


/* ================================================================ */
/* ВЫПАДАЮЩЕЕ МЕНЮ - ПОЯВЛЯЕТСЯ СВЕРХУ С ЦЕНТРИРОВАНИЕМ           */
/* ================================================================ */

.admin-dropdown {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 520px;
    max-width: 92vw;
    background: linear-gradient(145deg, #0f1724, #1a2a3a);
    border-radius: 20px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    animation: dropdownSlideDown 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    z-index: 100000;
}

@keyframes dropdownSlideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}


/* ================================================================ */
/* ШАПКА ДРОПДАУНА                                                  */
/* ================================================================ */

.dropdown-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.dropdown-title {
    color: #d4af37;
    font-size: 16px;
    font-weight: 700;
    font-family: 'Russo One', sans-serif;
    letter-spacing: 0.5px;
}

.dropdown-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.dropdown-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.2);
    color: #d4af37;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Montserrat', sans-serif;
    white-space: nowrap;
}

.dropdown-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: #d4af37;
}

.dropdown-btn:active {
    transform: scale(0.95);
}

.close-dropdown-btn {
    font-size: 18px;
    padding: 4px 12px;
}


/* ================================================================ */
/* ТЕЛО ДРОПДАУНА                                                  */
/* ================================================================ */

.dropdown-body {
    padding: 14px 18px;
    overflow-y: auto;
    flex: 1;
    max-height: 440px;
    min-height: 100px;
}

.dropdown-body::-webkit-scrollbar {
    width: 4px;
}

.dropdown-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.dropdown-body::-webkit-scrollbar-thumb {
    background: #d4af37;
    border-radius: 4px;
}


/* ================================================================ */
/* СООБЩЕНИЯ                                                        */
/* ================================================================ */

.message-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    border-left: 3px solid rgba(212, 175, 55, 0.3);
    transition: all 0.2s ease;
    cursor: pointer;
    word-break: break-word;
}

.message-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(3px);
}

.message-item.unread {
    border-left-color: #d4af37;
    background: rgba(212, 175, 55, 0.08);
}

.message-item.unread .message-title {
    color: #ffd700;
}

.message-item.read {
    border-left-color: rgba(212, 175, 55, 0.2);
    opacity: 0.8;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.message-title {
    font-size: 14px;
    font-weight: 700;
    color: #e0e9f0;
    flex: 1;
    word-break: break-word;
}

.message-date {
    font-size: 10px;
    color: #6a7a8e;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}

.message-content {
    font-size: 13px;
    color: #b0c0d0;
    line-height: 1.5;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.message-image {
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
}

.message-image img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid rgba(212, 175, 55, 0.15);
}

.message-link {
    display: inline-block;
    margin-top: 8px;
    color: #d4af37;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: color 0.2s;
    word-break: break-all;
}

.message-link:hover {
    color: #ffd700;
    text-decoration: underline;
}

.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.message-action-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(212, 175, 55, 0.15);
    color: #8a9bb0;
    padding: 3px 10px;
    border-radius: 16px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Montserrat', sans-serif;
}

.message-action-btn:hover {
    background: rgba(212, 175, 55, 0.1);
    color: #d4af37;
}

.message-action-btn.delete-msg-btn:hover {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
    border-color: rgba(220, 53, 69, 0.3);
}


/* ================================================================ */
/* ПУСТОЕ СОСТОЯНИЕ                                                 */
/* ================================================================ */

.messages-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6a7a8e;
}

.messages-empty .empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.messages-empty .empty-title {
    font-size: 16px;
    font-weight: 700;
    color: #d4af37;
    margin-bottom: 6px;
}

.messages-empty .empty-desc {
    font-size: 13px;
    line-height: 1.5;
}


/* ================================================================ */
/* ЗАГРУЗКА И ОШИБКИ                                               */
/* ================================================================ */

.messages-loading {
    text-align: center;
    padding: 30px 20px;
    color: #8a9bb0;
    font-size: 14px;
}

.messages-error {
    text-align: center;
    padding: 20px;
    color: #dc3545;
}

.messages-error .retry-btn {
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid #d4af37;
    color: #d4af37;
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    margin-top: 8px;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    transition: all 0.2s;
}

.messages-error .retry-btn:hover {
    background: rgba(212, 175, 55, 0.25);
}


/* ================================================================ */
/* ФУТЕР ДРОПДАУНА                                                  */
/* ================================================================ */

.dropdown-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(212, 175, 55, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    background: rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.messages-count {
    font-size: 12px;
    color: #8a9bb0;
    font-weight: 500;
}

.delete-all-btn {
    color: #dc3545 !important;
    border-color: rgba(220, 53, 69, 0.2) !important;
}

.delete-all-btn:hover {
    background: rgba(220, 53, 69, 0.15) !important;
    border-color: rgba(220, 53, 69, 0.3) !important;
}


/* ================================================================ */
/* ================================================================ */
/* АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ                            */
/* ================================================================ */
/* ================================================================ */

/* ================================================================ */
/* ПЛАНШЕТЫ (до 768px)                                             */
/* ================================================================ */

@media (max-width: 768px) {
    /* Контейнер */
    .admin-messages-module {
        margin: 0 2px;
    }
    
    /* Кнопка колокольчика */
    .admin-bell-btn {
        width: 38px;
        height: 38px;
    }
    
    .admin-bell-btn .bell-icon {
        font-size: 18px;
    }
    
    .bell-badge {
        font-size: 9px;
        min-width: 18px;
        height: 18px;
        top: -3px;
        right: -3px;
    }
    
    /* Дропдаун - центрируется правильно */
    .admin-dropdown {
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100vw - 32px);
        max-width: calc(100vw - 32px);
        max-height: 88vh;
        border-radius: 18px;
    }
    
    @keyframes dropdownSlideDown {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(-15px) scale(0.96);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0) scale(1);
        }
    }
    
    /* Шапка */
    .dropdown-header {
        padding: 12px 16px;
    }
    
    .dropdown-title {
        font-size: 14px;
    }
    
    .dropdown-btn {
        font-size: 10px;
        padding: 4px 10px;
    }
    
    /* Тело */
    .dropdown-body {
        padding: 10px 14px;
        max-height: 380px;
    }
    
    /* Сообщения */
    .message-item {
        padding: 12px 14px;
    }
    
    .message-title {
        font-size: 13px;
    }
    
    .message-content {
        font-size: 12px;
    }
    
    .message-date {
        font-size: 10px;
    }
    
    /* Футер */
    .dropdown-footer {
        padding: 10px 16px;
        font-size: 12px;
    }
}


/* ================================================================ */
/* ТЕЛЕФОНЫ (до 480px)                                             */
/* ================================================================ */

@media (max-width: 480px) {
    /* Кнопка колокольчика */
    .admin-bell-btn {
        width: 34px;
        height: 34px;
    }
    
    .admin-bell-btn .bell-icon {
        font-size: 16px;
    }
    
    .bell-badge {
        font-size: 8px;
        min-width: 16px;
        height: 16px;
        top: -2px;
        right: -2px;
    }
    
    /* Дропдаун - центрируется правильно, на всю ширину */
    .admin-dropdown {
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        max-height: 92vh;
        border-radius: 16px;
    }
    
    @keyframes dropdownSlideDown {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(-12px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0) scale(1);
        }
    }
    
    /* Шапка */
    .dropdown-header {
        padding: 10px 14px;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    
    .dropdown-title {
        font-size: 13px;
        text-align: center;
    }
    
    .dropdown-actions {
        width: 100%;
        justify-content: center;
        gap: 4px;
    }
    
    .dropdown-btn {
        font-size: 9px;
        padding: 4px 8px;
        flex: 1;
        text-align: center;
        min-height: 28px;
        white-space: normal;
        word-break: break-word;
    }
    
    .close-dropdown-btn {
        flex: 0.3;
        font-size: 16px;
        padding: 4px 8px;
    }
    
    /* Тело */
    .dropdown-body {
        padding: 8px 12px;
        max-height: 320px;
    }
    
    /* Сообщения */
    .message-item {
        padding: 10px 12px;
        border-radius: 12px;
        border-left-width: 3px;
    }
    
    .message-title {
        font-size: 12px;
    }
    
    .message-content {
        font-size: 11px;
        line-height: 1.4;
        -webkit-line-clamp: 3;
    }
    
    .message-date {
        font-size: 9px;
    }
    
    .message-image img {
        max-height: 150px;
    }
    
    .message-link {
        font-size: 11px;
    }
    
    .message-actions {
        gap: 4px;
    }
    
    .message-action-btn {
        font-size: 9px;
        padding: 3px 8px;
        white-space: normal;
        word-break: break-word;
    }
    
    /* Футер */
    .dropdown-footer {
        padding: 8px 14px;
        flex-direction: column;
        gap: 6px;
        align-items: stretch;
    }
    
    .dropdown-footer .messages-count {
        text-align: center;
        font-size: 11px;
    }
    
    .delete-all-btn {
        text-align: center;
        font-size: 10px;
        padding: 4px 10px;
    }
    
    /* Пустое состояние */
    .messages-empty {
        padding: 30px 16px;
    }
    
    .messages-empty .empty-icon {
        font-size: 40px;
    }
    
    .messages-empty .empty-title {
        font-size: 14px;
    }
    
    .messages-empty .empty-desc {
        font-size: 12px;
    }
    
    .messages-loading {
        font-size: 13px;
        padding: 25px 16px;
    }
    
    .messages-error {
        font-size: 13px;
        padding: 20px 16px;
    }
    
    .messages-error .retry-btn {
        font-size: 11px;
        padding: 5px 12px;
    }
}


/* ================================================================ */
/* МАЛЕНЬКИЕ ТЕЛЕФОНЫ (до 380px)                                   */
/* ================================================================ */

@media (max-width: 380px) {
    /* Кнопка колокольчика */
    .admin-bell-btn {
        width: 30px;
        height: 30px;
    }
    
    .admin-bell-btn .bell-icon {
        font-size: 14px;
    }
    
    .bell-badge {
        font-size: 7px;
        min-width: 14px;
        height: 14px;
        top: -2px;
        right: -2px;
        border-width: 1.5px;
    }
    
    /* Дропдаун */
    .admin-dropdown {
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        border-radius: 14px;
        max-height: 94vh;
    }
    
    /* Шапка */
    .dropdown-header {
        padding: 8px 12px;
    }
    
    .dropdown-title {
        font-size: 12px;
    }
    
    .dropdown-btn {
        font-size: 8px;
        padding: 3px 6px;
        min-height: 24px;
    }
    
    .close-dropdown-btn {
        font-size: 14px;
        padding: 3px 6px;
    }
    
    /* Тело */
    .dropdown-body {
        padding: 6px 10px;
        max-height: 260px;
    }
    
    /* Сообщения */
    .message-item {
        padding: 8px 10px;
        border-radius: 10px;
        margin-bottom: 6px;
        border-left-width: 2px;
    }
    
    .message-title {
        font-size: 11px;
    }
    
    .message-content {
        font-size: 10px;
        -webkit-line-clamp: 2;
        line-height: 1.3;
    }
    
    .message-date {
        font-size: 8px;
    }
    
    .message-image img {
        max-height: 100px;
    }
    
    .message-link {
        font-size: 10px;
        margin-top: 4px;
    }
    
    .message-actions {
        gap: 4px;
        margin-top: 4px;
    }
    
    .message-action-btn {
        font-size: 8px;
        padding: 2px 6px;
        min-height: 20px;
    }
    
    /* Футер */
    .dropdown-footer {
        padding: 6px 12px;
    }
    
    .dropdown-footer .messages-count {
        font-size: 10px;
    }
    
    .delete-all-btn {
        font-size: 9px;
        padding: 3px 8px;
    }
    
    /* Пустое состояние */
    .messages-empty {
        padding: 20px 12px;
    }
    
    .messages-empty .empty-icon {
        font-size: 32px;
        margin-bottom: 8px;
    }
    
    .messages-empty .empty-title {
        font-size: 13px;
        margin-bottom: 4px;
    }
    
    .messages-empty .empty-desc {
        font-size: 11px;
    }
    
    .messages-loading {
        font-size: 12px;
        padding: 20px 12px;
    }
    
    .messages-error {
        font-size: 12px;
        padding: 16px 12px;
    }
    
    .messages-error .retry-btn {
        font-size: 10px;
        padding: 4px 10px;
    }
}


/* ================================================================ */
/* ДОПОЛНИТЕЛЬНЫЕ УЛУЧШЕНИЯ                                        */
/* ================================================================ */

/* Плавный скролл на мобильных */
.dropdown-body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Отключаем выделение при клике */
.admin-bell-btn,
.dropdown-btn,
.message-action-btn,
.message-item {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Увеличиваем область нажатия на мобильных */
@media (max-width: 768px) {
    .admin-bell-btn {
        padding: 4px;
    }
}

/* Адаптация для top-bar */
.top-bar .admin-messages-module {
    margin-left: 12px;
}

@media (max-width: 480px) {
    .top-bar .admin-messages-module {
        margin-left: 6px;
    }
}

@media (max-width: 380px) {
    .top-bar .admin-messages-module {
        margin-left: 4px;
    }
}

/* Плавное появление/исчезновение дропдауна */
.admin-dropdown {
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.admin-dropdown[style*="display: none"] {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.admin-dropdown[style*="display: flex"] {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Затемнение фона при открытом дропдауне на мобильных */
@media (max-width: 768px) {
    .admin-dropdown::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: -1;
        animation: overlayFade 0.3s ease;
    }
    
    @keyframes overlayFade {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

/* Безопасная зона для iPhone с вырезом */
@supports (padding: max(0px)) {
    .admin-dropdown {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

@media (max-width: 480px) {
    @supports (padding: max(0px)) {
        .admin-dropdown {
            padding-top: max(8px, env(safe-area-inset-top));
            padding-left: max(8px, env(safe-area-inset-left));
            padding-right: max(8px, env(safe-area-inset-right));
            padding-bottom: max(8px, env(safe-area-inset-bottom));
        }
    }
}

/* Исправление для изображений - чтобы не обрезались */
.message-image img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid rgba(212, 175, 55, 0.15);
}

@media (max-width: 480px) {
    .message-image img {
        max-height: 150px;
        object-fit: contain;
    }
}

@media (max-width: 380px) {
    .message-image img {
        max-height: 100px;
        object-fit: contain;
    }
}