/* ============================================================
   МОДАЛЬНОЕ ОКНО - ПОЛНЫЕ СТИЛИ
   ============================================================ */

/* ============================================================
   OVERLAY (фон)
   ============================================================ */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 9997 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    opacity: 1 !important;
    visibility: visible !important;
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================================
   КОНТЕЙНЕР МОДАЛКИ
   ============================================================ */
.modal-container {
    background: #ffffff !important;
    border-radius: 12px !important;
    width: 100% !important;
    max-width: 900px !important;
    height: 85vh !important;
    max-height: 800px !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2) !important;
    opacity: 1 !important;
    visibility: visible !important;
    animation: modalSlideUp 0.25s ease;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================================
   ХЕДЕР МОДАЛКИ
   ============================================================ */
.modal-header {
    padding: 16px 20px !important;
    border-bottom: 1px solid #e5e7eb !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    flex-shrink: 0 !important;
    background: #ffffff !important;
    min-height: 56px !important;
    flex-wrap: wrap !important;
}

.modal-header-content {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    min-width: 0 !important;
    flex: 1 !important;
}

.modal-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 8px !important;
    background: #f3f4f6 !important;
    color: #4b5563 !important;
    flex-shrink: 0 !important;
}

.modal-title {
    margin: 0 !important;
    font-size: 17px !important;
    font-weight: 600 !important;
    color: #111827 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    line-height: 1.4 !important;
}

.modal-close-btn {
    background: #f3f4f6 !important;
    border: none !important;
    cursor: pointer !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #6b7280 !important;
    transition: all 0.15s ease !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
}

.modal-close-btn:hover {
    background: #e5e7eb !important;
    color: #111827 !important;
}

.modal-close-btn:active {
    background: #d1d5db !important;
    transform: scale(0.95) !important;
}

/* ============================================================
   ШАПКА КАРТОЧКИ В МОДАЛКЕ (автор + кнопки)
   ============================================================ */
.modal-card-header {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px 16px !important;
    border-bottom: 1px solid #e5e7eb !important;
    background: #fafafa !important;
    flex-shrink: 0 !important;
    flex-wrap: wrap !important;
}

.card-header-left {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 1 !important;
    min-width: 0 !important;
}

.card-avatar {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
    cursor: pointer !important;
}

.card-avatar img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

.card-author {
    min-width: 0 !important;
}

.author-top {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: wrap !important;
}

.author-name {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #111827 !important;
    cursor: pointer !important;
}

.role-badge {
    font-size: 11px !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 2px !important;
}

.card-header-right {
    flex-shrink: 0 !important;
    position: relative !important;
}

/* ============================================================
   КНОПКИ ДЕЙСТВИЙ В МОДАЛКЕ
   ============================================================ */
.modal-actions {
    display: flex !important;
    gap: 4px !important;
    padding: 8px 16px !important;
    border-top: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    flex-shrink: 0 !important;
}

.modal-actions .fb-action-btn {
    flex: 1 !important;
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 13px !important;
    color: #6b7280 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 6px !important;
}

.modal-actions .fb-action-btn:hover {
    color: #111827 !important;
}

/* ============================================================
   КОНТЕНТ МОДАЛКИ
   ============================================================ */
.modal-content {
    flex: 1 !important;
    overflow: hidden !important;
    position: relative !important;
    background: #ffffff !important;
}

.modal-iframe {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    display: block !important;
    background: #ffffff !important;
}

/* ============================================================
   МОБИЛЬНАЯ ВЕРСИЯ — FULLSCREEN
   ============================================================ */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0 !important;
        background: rgba(0, 0, 0, 0.6) !important;
    }

    .modal-container {
        border-radius: 0 !important;
        height: 100% !important;
        max-height: 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        box-shadow: none !important;
    }

    .modal-header {
        padding: 12px 16px !important;
        min-height: 52px !important;
    }

    .modal-close-btn {
        width: 44px !important;
        height: 44px !important;
    }

    .modal-card-header {
        padding: 8px 12px !important;
    }

    .modal-actions {
        padding: 6px 12px !important;
    }
}

/* ============================================================
   МАЛЕНЬКИЕ ТЕЛЕФОНЫ
   ============================================================ */
@media (max-width: 480px) {
    .modal-header {
        padding: 10px 12px !important;
        gap: 6px !important;
    }

    .modal-icon {
        width: 30px !important;
        height: 30px !important;
    }

    .modal-title {
        font-size: 14px !important;
    }

    .modal-close-btn {
        width: 40px !important;
        height: 40px !important;
    }

    .card-avatar {
        width: 32px !important;
        height: 32px !important;
    }

    .author-name {
        font-size: 13px !important;
    }

    .modal-actions .fb-action-btn {
        font-size: 12px !important;
        padding: 4px !important;
    }
}

/* ============================================================
   БОЛЬШИЕ ЭКРАНЫ
   ============================================================ */
@media (min-width: 1025px) {
    .modal-container {
        max-width: 900px !important;
        height: 80vh !important;
        max-height: 700px !important;
    }
}

/* ============================================================
   SAFE AREA (iPhone с вырезами)
   ============================================================ */
@supports (padding: max(0px)) {
    .modal-header {
        padding-top: max(16px, env(safe-area-inset-top)) !important;
    }
}

/* ============================================================
   PREFERS-REDUCED-MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .modal-overlay,
    .modal-container {
        animation: none !important;
    }
}