/**
 * ============================================================================
 * V2 MODAL DOCUMENTS — Модальные окна для юридических документов
 * ============================================================================
 * 
 * Универсальный компонент для отображения правил, политики конфиденциальности
 * и оферты в красивом модальном окне
 * 
 * Использование: см. web/js/v2/modal-documents.js
 */

/* ═══════════════════════════════════════════════════════════════════
   Overlay — затемнённый фон
   ═══════════════════════════════════════════════════════════════════ */

.v2-modal-document-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.v2-modal-document-overlay.active {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   Modal — само модальное окно
   ═══════════════════════════════════════════════════════════════════ */

.v2-modal-document {
    background: var(--v2-card-bg);
    border-radius: 20px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    position: relative;
    overflow: hidden;
}

.v2-modal-document-overlay.active .v2-modal-document {
    transform: scale(1);
}

/* ═══════════════════════════════════════════════════════════════════
   Header — шапка модального окна
   ═══════════════════════════════════════════════════════════════════ */

.v2-modal-document__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    border-bottom: 2px solid var(--v2-border);
    background: var(--v2-bg-hover);
    flex-shrink: 0;
}

.v2-modal-document__title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--v2-text);
    display: flex;
    align-items: center;
    gap: 12px;
}

.v2-modal-document__icon {
    font-size: 28px;
    line-height: 1;
}

.v2-modal-document__close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--v2-text-muted);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.v2-modal-document__close:hover {
    background: var(--v2-bg-hover);
    color: var(--v2-text);
    transform: rotate(90deg);
}

/* ═══════════════════════════════════════════════════════════════════
   Body — тело модального окна с контентом
   ═══════════════════════════════════════════════════════════════════ */

.v2-modal-document__body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
    position: relative;
}

/* Кастомный скроллбар */
.v2-modal-document__body::-webkit-scrollbar {
    width: 8px;
}

.v2-modal-document__body::-webkit-scrollbar-track {
    background: var(--v2-bg-hover);
    border-radius: 8px;
}

.v2-modal-document__body::-webkit-scrollbar-thumb {
    background: var(--v2-primary);
    border-radius: 8px;
}

.v2-modal-document__body::-webkit-scrollbar-thumb:hover {
    background: var(--v2-primary-hover);
}

/* ═══════════════════════════════════════════════════════════════════
   Document Content — стили для загруженного контента
   ═══════════════════════════════════════════════════════════════════ */

.v2-document-content {
    color: var(--v2-text);
    line-height: 1.8;
}

/* ═══════════════════════════════════════════════════════════════════
   Iframe Mode — iframe для обхода CORS
   ═══════════════════════════════════════════════════════════════════ */

.v2-document-iframe-wrapper {
    width: 100%;
    height: calc(90vh - 200px);
    min-height: 400px;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    border: 2px solid var(--v2-border);
}

.v2-document-iframe {
    width: 100%;
    height: 100%;
    display: block;
    border: none;
}

.v2-document-iframe-hint {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--v2-bg-hover);
    border-radius: 8px;
    text-align: center;
}

.v2-document-iframe-hint small {
    color: var(--v2-text-muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.v2-document-open-external {
    color: var(--v2-primary);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.v2-document-open-external:hover {
    text-decoration: underline;
    transform: translateX(2px);
}

/* Light Theme для iframe */
.light-theme .v2-document-iframe-wrapper {
    background: #ffffff;
    border-color: #e0e6ed;
}

.light-theme .v2-document-iframe-hint {
    background: #f8f9fa;
}

.light-theme .v2-document-iframe-hint small {
    color: rgba(26, 35, 50, 0.6);
}

/* Адаптивность iframe */
@media (max-width: 768px) {
    .v2-document-iframe-wrapper {
        height: calc(95vh - 180px);
        min-height: 300px;
    }
    
    .v2-document-iframe-hint small {
        font-size: 12px;
        flex-direction: column;
        gap: 8px;
    }
}

.v2-document-content h1,
.v2-document-content h2,
.v2-document-content h3,
.v2-document-content h4 {
    color: var(--v2-text);
    margin-top: 32px;
    margin-bottom: 16px;
    font-weight: 700;
}

.v2-document-content h1 {
    font-size: 32px;
    margin-top: 0;
}

.v2-document-content h2 {
    font-size: 24px;
}

.v2-document-content h3 {
    font-size: 20px;
}

.v2-document-content p {
    margin-bottom: 16px;
    color: var(--v2-text);
}

.v2-document-content ul,
.v2-document-content ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.v2-document-content li {
    margin-bottom: 8px;
}

.v2-document-content a {
    color: var(--v2-primary);
    text-decoration: underline;
}

.v2-document-content a:hover {
    text-decoration: none;
}

.v2-document-content strong {
    font-weight: 600;
    color: var(--v2-text);
}

.v2-document-content em {
    font-style: italic;
}

.v2-document-content code {
    background: var(--v2-bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.v2-document-content blockquote {
    margin: 20px 0;
    padding: 16px 20px;
    border-left: 4px solid var(--v2-primary);
    background: var(--v2-bg-hover);
    border-radius: 8px;
}

/* ═══════════════════════════════════════════════════════════════════
   Loading — индикатор загрузки
   ═══════════════════════════════════════════════════════════════════ */

.v2-modal-document__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.v2-modal-document__loading p {
    margin-top: 20px;
    color: var(--v2-text-muted);
    font-size: 16px;
}

.v2-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--v2-border);
    border-top-color: var(--v2-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════
   Error — ошибка загрузки
   ═══════════════════════════════════════════════════════════════════ */

.v2-modal-document__error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.v2-modal-document__error-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.v2-modal-document__error p {
    color: var(--v2-text);
    font-size: 16px;
    line-height: 1.6;
}

.v2-modal-document__error a {
    color: var(--v2-primary);
    text-decoration: underline;
}

.v2-modal-document__error a:hover {
    text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════════════
   Light Theme — светлая тема
   ═══════════════════════════════════════════════════════════════════ */

.light-theme .v2-modal-document-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.light-theme .v2-modal-document {
    background: #ffffff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.light-theme .v2-modal-document__header {
    background: #f8f9fa;
    border-bottom-color: #e0e6ed;
}

.light-theme .v2-modal-document__title {
    color: #1a2332;
}

.light-theme .v2-modal-document__close {
    color: rgba(26, 35, 50, 0.6);
}

.light-theme .v2-modal-document__close:hover {
    background: #e0e6ed;
    color: #1a2332;
}

.light-theme .v2-document-content {
    color: #1a2332;
}

.light-theme .v2-document-content h1,
.light-theme .v2-document-content h2,
.light-theme .v2-document-content h3,
.light-theme .v2-document-content h4 {
    color: #1a2332;
}

.light-theme .v2-document-content p {
    color: rgba(26, 35, 50, 0.9);
}

.light-theme .v2-document-content code {
    background: #f8f9fa;
}

.light-theme .v2-document-content blockquote {
    background: #f8f9fa;
}

.light-theme .v2-spinner {
    border-color: #e0e6ed;
    border-top-color: var(--v2-primary);
}

/* ═══════════════════════════════════════════════════════════════════
   Responsive — адаптивность
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .v2-modal-document-overlay {
        padding: 10px;
    }
    
    .v2-modal-document {
        max-height: 95vh;
        border-radius: 16px;
    }
    
    .v2-modal-document__header {
        padding: 20px;
    }
    
    .v2-modal-document__title {
        font-size: 18px;
    }
    
    .v2-modal-document__icon {
        font-size: 24px;
    }
    
    .v2-modal-document__close {
        width: 36px;
        height: 36px;
    }
    
    .v2-modal-document__body {
        padding: 20px;
    }
    
    .v2-document-content h1 {
        font-size: 24px;
    }
    
    .v2-document-content h2 {
        font-size: 20px;
    }
    
    .v2-document-content h3 {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .v2-modal-document-overlay {
        padding: 0;
    }
    
    .v2-modal-document {
        max-height: 100vh;
        border-radius: 0;
    }
    
    .v2-modal-document__header {
        padding: 16px;
    }
    
    .v2-modal-document__body {
        padding: 16px;
    }
}

.clb-scroll-top {
    display: none;
}