/* Стили для модуля анализа сетки */

/* Модальное окно анализа сетки */
.grid-analysis-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.grid-analysis-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.grid-analysis-modal .modal-content {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    width: 1200px;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.grid-analysis-modal .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.grid-analysis-modal .modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.grid-analysis-modal .modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.grid-analysis-modal .modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.grid-analysis-modal .modal-body {
    padding: 24px;
    max-height: calc(90vh - 120px);
    overflow-y: auto;
}

/* Статистика анализа */
.grid-analysis-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 1px solid #dee2e6;
}

.grid-analysis-stats .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grid-analysis-stats .stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.grid-analysis-stats .stat-label {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 500;
}

.grid-analysis-stats .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
}

.grid-analysis-stats .stat-value.aligned {
    color: #38a169;
}

.grid-analysis-stats .stat-value.misaligned {
    color: #e53e3e;
}

/* Визуализация сетки */
.grid-analysis-visualization {
    margin-bottom: 32px;
}

.grid-analysis-visualization h4 {
    margin: 0 0 16px 0;
    font-size: 1.25rem;
    color: #2c3e50;
    font-weight: 600;
}

.layout-preview {
    position: relative;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    overflow: auto;
    max-height: 500px;
}

.grid-analysis-results .svg-container {
    position: relative;
    display: inline-block;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.grid-analysis-results .svg-container svg {
    display: block;
    max-width: 100%;
    height: auto;
}

.grid-analysis-results .grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10;
}

/* Список нарушений */
.grid-violations-list {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
}

.grid-violations-list h4 {
    margin: 0 0 16px 0;
    font-size: 1.25rem;
    color: #2c3e50;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grid-violations-list h4::before {
    content: '⚠️';
    font-size: 1.1rem;
}

.no-violations {
    text-align: center;
    padding: 32px;
    color: #38a169;
    font-size: 1.1rem;
    font-weight: 500;
    background: #f0fff4;
    border-radius: 8px;
    border: 1px solid #c6f6d5;
}

.violations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.violation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.violation-item:hover {
    background: #fed7d7;
}

.violation-item .element-id {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: #2d3748;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.875rem;
}

.violation-item .violation-type {
    color: #c53030;
    font-weight: 500;
    font-size: 0.875rem;
}

/* Уведомления ТОЛЬКО внутри модалки анализа сетки */
.grid-analysis-modal .notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    max-width: min(400px, calc(100vw - 40px));
    z-index: 10001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    border-left: 4px solid #667eea;
}

.grid-analysis-modal .notification.show {
    transform: translateX(0);
}

.grid-analysis-modal .notification h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
}

.grid-analysis-modal .notification p {
    margin: 0;
    font-size: 0.875rem;
    color: #6c757d;
    line-height: 1.4;
}

.grid-analysis-modal .notification.notification-success {
    border-left-color: #38a169;
}

.grid-analysis-modal .notification.notification-warning {
    border-left-color: #d69e2e;
}

.grid-analysis-modal .notification.notification-error {
    border-left-color: #e53e3e;
}

/* Кнопка анализа сетки */
.grid-analysis-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.grid-analysis-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.grid-analysis-btn:active {
    transform: translateY(0);
}

.grid-analysis-btn i {
    font-size: 0.75rem;
}

/* Адаптивность */
@media (max-width: 768px) {
    .grid-analysis-modal .modal-content {
        width: 95vw;
        max-height: 95vh;
    }
    
    .grid-analysis-modal .modal-body {
        padding: 16px;
    }
    
    .grid-analysis-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .layout-preview {
        padding: 12px;
        max-height: 300px;
    }
    
    .violation-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* Анимации для элементов сетки */
.grid-analysis-results .grid-overlay svg line {
    animation: gridLineAppear 0.5s ease-out;
}

@keyframes gridLineAppear {
    from {
        opacity: 0;
        stroke-dashoffset: 20;
    }
    to {
        opacity: 1;
        stroke-dashoffset: 0;
    }
}

/* Стили для выделенных нарушающих элементов */
.grid-analysis-results .svg-container svg rect[style*="stroke: #e53e3e"],
.grid-analysis-results .svg-container svg path[style*="stroke: #e53e3e"],
.grid-analysis-results .svg-container svg circle[style*="stroke: #e53e3e"],
.grid-analysis-results .svg-container svg ellipse[style*="stroke: #e53e3e"],
.grid-analysis-results .svg-container svg polygon[style*="stroke: #e53e3e"] {
    animation: violationHighlight 2s ease-in-out infinite;
}

@keyframes violationHighlight {
    0%, 100% {
        stroke-opacity: 0.8;
        stroke-width: 2;
    }
    50% {
        stroke-opacity: 1;
        stroke-width: 3;
    }
}

/* Улучшенные стили для SVG контейнера */
.grid-analysis-results .svg-container {
    position: relative;
    display: inline-block;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.grid-analysis-results .svg-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 49%, rgba(102, 126, 234, 0.05) 50%, transparent 51%);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 1;
}

/* Стили для загрузки */
.grid-analysis-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6c757d;
}

.grid-analysis-loading .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e9ecef;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Стили для кнопок зума */
.zoom-btn {
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    background: #f3f4f6 !important;
    border-color: #9ca3af !important;
}

.zoom-btn:active {
    background: #e5e7eb !important;
    transform: scale(0.95);
}

.grid-analysis-results .svg-container {
    transition: transform 0.1s ease;
    user-select: none;
}

.grid-analysis-results .svg-container:active {
    cursor: grabbing !important;
}

.grid-analysis-results .grid-overlay {
    transition: transform 0.1s ease;
}
