/**
 * Стили для информационных вставок
 * Django Info Snippets
 */

/* Контейнер для inline вставки */
.info-snippet-inline {
    display: inline-flex;
    align-items: center;
    margin: 0 4px;
    vertical-align: middle;
}

/* Иконка информационной вставки */
.info-snippet-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
    color: white;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.info-snippet-icon:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}

/* Типы вставок - цвета */
.info-snippet--important {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.info-snippet--explanation {
    background: linear-gradient(135deg, #0d6efd 0%, #0056b3 100%);
}

.info-snippet--info {
    background: linear-gradient(135deg, #198754 0%, #0f5132 100%);
}

/* Контейнер вставки */
.info-snippet-container {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

/* Надпись рядом со значком */
.info-snippet-label {
    margin-left: 6px;
    font-size: 13px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}

.info-snippet-label:hover {
    transform: translateY(-1px);
}

/* Цвета надписи по типам */
.info-snippet-label--important {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.info-snippet-label--important:hover {
    background: rgba(220, 53, 69, 0.15);
}

.info-snippet-label--explanation {
    background: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
    border: 1px solid rgba(13, 110, 253, 0.2);
}

.info-snippet-label--explanation:hover {
    background: rgba(13, 110, 253, 0.15);
}

.info-snippet-label--info {
    background: rgba(25, 135, 84, 0.1);
    color: #198754;
    border: 1px solid rgba(25, 135, 84, 0.2);
}

.info-snippet-label--info:hover {
    background: rgba(25, 135, 84, 0.15);
}

/* Кнопка редактирования для админов */
.info-snippet-edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    background: #6c757d;
    color: white;
    transition: background 0.2s ease;
}

.info-snippet-edit-btn:hover {
    background: #495057;
}

/* Оверлей для модального окна */
.info-snippet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.info-snippet-overlay.active {
    display: flex;
    opacity: 1;
}

/* Модальное окно */
.info-snippet-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 300px;
    width: 1200px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    margin: 20px;
    /* Разрешаем изменение размеров */
    resize: both;
    position: relative;
}

/* Модальное окно редактирования — широкое */
.info-snippet-modal.edit-mode {
    width: min(840px, 88vw);
    min-width: 480px;
    height: min(85vh, 900px);
    max-height: 90vh;
}

.info-snippet-overlay.active .info-snippet-modal {
    transform: scale(1);
}

/* Подсказка о возможности изменить размер */
.info-snippet-modal::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: se-resize;
    background: linear-gradient(135deg,
        transparent 40%,
        rgba(0,0,0,0.15) 40%,
        rgba(0,0,0,0.15) 55%,
        transparent 55%,
        transparent 65%,
        rgba(0,0,0,0.15) 65%,
        rgba(0,0,0,0.15) 80%,
        transparent 80%
    );
    border-bottom-right-radius: 12px;
    pointer-events: none;
}

/* Заголовок модального окна */
.info-snippet-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    color: white;
    position: relative;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.info-snippet-modal-header.important {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.info-snippet-modal-header.explanation {
    background: linear-gradient(135deg, #0d6efd 0%, #0056b3 100%);
}

.info-snippet-modal-header.info {
    background: linear-gradient(135deg, #198754 0%, #0f5132 100%);
}

.info-snippet-modal-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-snippet-modal-title .icon {
    font-size: 20px;
}

.info-snippet-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.info-snippet-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Содержимое модального окна */
.info-snippet-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    line-height: 1.6;
    color: #333;
    min-height: 0;
}

/* Тело модального окна в режиме редактирования — flex, без прокрутки */
.info-snippet-modal.edit-mode .info-snippet-modal-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 14px 16px 10px;
}

/* Стили для Markdown контента */
.info-snippet-modal-body h1 {
    font-size: 1.5em;
    margin: 0 0 0.8em 0;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #eaecef;
}

.info-snippet-modal-body h2 {
    font-size: 1.3em;
    margin: 1em 0 0.6em 0;
}

.info-snippet-modal-body h3 {
    font-size: 1.1em;
    margin: 0.8em 0 0.4em 0;
}

.info-snippet-modal-body p {
    margin: 0 0 1em 0;
}

.info-snippet-modal-body ul,
.info-snippet-modal-body ol {
    margin: 0 0 1em 0;
    padding-left: 2em;
}

.info-snippet-modal-body li {
    margin: 0.3em 0;
}

.info-snippet-modal-body code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: #e83e8c;
}

.info-snippet-modal-body pre {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 0 0 1em 0;
}

.info-snippet-modal-body pre code {
    background: transparent;
    padding: 0;
    color: #333;
}

.info-snippet-modal-body blockquote {
    margin: 0 0 1em 0;
    padding: 10px 20px;
    border-left: 4px solid #dee2e6;
    background: #f8f9fa;
    color: #6c757d;
}

.info-snippet-modal-body a {
    color: #0d6efd;
    text-decoration: none;
}

.info-snippet-modal-body a:hover {
    text-decoration: underline;
}

.info-snippet-modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 1em 0;
}

.info-snippet-modal-body th,
.info-snippet-modal-body td {
    border: 1px solid #dee2e6;
    padding: 8px 12px;
    text-align: left;
}

.info-snippet-modal-body th {
    background: #f8f9fa;
    font-weight: 600;
}

.info-snippet-modal-body tr:nth-child(even) {
    background: #f8f9fa;
}

.info-snippet-modal-body img {
    max-width: 100%;
    border-radius: 6px;
}

.info-snippet-modal-body hr {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 1.5em 0;
}

/* Footer модального окна */
.info-snippet-modal-footer {
    padding: 12px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.info-snippet-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
}

.info-snippet-btn-primary {
    background: #0d6efd;
    color: white;
}

.info-snippet-btn-primary:hover {
    background: #0056b3;
}

.info-snippet-btn-secondary {
    background: #6c757d;
    color: white;
}

.info-snippet-btn-secondary:hover {
    background: #5a6268;
}

/* Форма быстрого редактирования */
.info-snippet-quick-edit {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 10px;
}

/* Верхняя строка с полями */
.quick-edit-top-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

.quick-edit-field {
    display: flex;
    flex-direction: column;
    flex: 1 1 140px;
    min-width: 120px;
}

.quick-edit-field--wide {
    flex: 2 1 200px;
}

.quick-edit-field--narrow {
    flex: 1 1 130px;
    min-width: 120px;
}

.quick-edit-field--checkbox {
    flex: 0 0 auto;
    min-width: 0;
}

.quick-edit-field label,
.quick-edit-content-row > label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 12px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-edit-field input[type="text"],
.quick-edit-field select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.quick-edit-field input[type="text"]:focus,
.quick-edit-field select:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

/* Чекбокс */
.quick-edit-field--checkbox .checkbox-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 0;
    white-space: nowrap;
}

.quick-edit-field--checkbox .checkbox-group label {
    margin-bottom: 0;
    font-size: 13px;
    font-weight: 400;
    color: #333;
    cursor: pointer;
}

.quick-edit-field--checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Блок с textarea — занимает всё оставшееся место */
.quick-edit-content-row {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
}

.quick-edit-content-row textarea {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 13px;
    font-family: 'Consolas', 'Monaco', monospace;
    resize: none;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    line-height: 1.5;
}

.quick-edit-content-row textarea:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

/* Tooltip стили */
.info-snippet-tooltip {
    position: fixed;
    background: #333;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 10001;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-snippet-tooltip.visible {
    opacity: 1;
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Адаптивность */
@media (max-width: 768px) {
    .info-snippet-modal,
    .info-snippet-modal.edit-mode {
        max-width: 95vw;
        width: auto !important;
        min-width: 0;
        margin: 10px;
        resize: none;
    }

    .info-snippet-modal-header {
        padding: 12px 16px;
        cursor: default;
    }

    .info-snippet-modal-body {
        padding: 16px;
    }
}

/* Скроллбар для модального окна */
.info-snippet-modal-body::-webkit-scrollbar {
    width: 8px;
}

.info-snippet-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.info-snippet-modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.info-snippet-modal-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
