/* styles.css - ПОЛНАЯ ВЕРСИЯ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e6e6e6;
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(30, 30, 46, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

header {
    background: linear-gradient(90deg, #0f3460 0%, #533483 100%);
    padding: 25px 40px;
    border-bottom: 2px solid #00adb5;
    position: relative;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.subtitle {
    color: #8ac6d1;
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.version {
    color: #b19cd9;
    font-size: 0.9rem;
    font-style: italic;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 30px;
    min-height: 600px;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

.input-section, .output-section {
    background: rgba(40, 40, 60, 0.8);
    border-radius: 10px;
    padding: 25px;
    border: 1px solid #393e46;
}

h2 {
    color: #00adb5;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
}

h3 {
    color: #8ac6d1;
    margin: 15px 0 10px 0;
    font-size: 1.2rem;
}

.description-box {
    position: relative;
    margin-bottom: 25px;
}

textarea {
    width: 100%;
    height: 200px;
    padding: 15px;
    background: #1e1e2e;
    border: 2px solid #393e46;
    border-radius: 8px;
    color: #e6e6e6;
    font-size: 1rem;
    line-height: 1.5;
    resize: vertical;
    font-family: 'Consolas', 'Monaco', monospace;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #00adb5;
}

.char-count {
    position: absolute;
    bottom: 10px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9rem;
    color: #8ac6d1;
}

.examples {
    margin-bottom: 25px;
    background: rgba(15, 52, 96, 0.2);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #00adb5;
}

.example-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.example-tag {
    background: rgba(83, 52, 131, 0.7);
    border: 1px solid #8a2be2;
    color: #d8bfd8;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.example-tag:hover {
    background: #8a2be2;
    color: white;
    transform: translateY(-2px);
}

.generation-options {
    margin: 20px 0;
    padding: 15px;
    background: rgba(30, 30, 46, 0.7);
    border-radius: 8px;
    border: 1px solid #393e46;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.option label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #8ac6d1;
}

.option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.generate-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(90deg, #00adb5 0%, #0097a7 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    margin-top: 20px;
}

.generate-btn:hover {
    background: linear-gradient(90deg, #0097a7 0%, #00838f 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 173, 181, 0.4);
}

.stage-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    gap: 5px;
}

.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stage-number {
    width: 40px;
    height: 40px;
    background: #393e46;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #8ac6d1;
    transition: all 0.3s;
}

.stage.active .stage-number {
    background: #00adb5;
    color: white;
    box-shadow: 0 0 10px rgba(0, 173, 181, 0.5);
}

.stage-name {
    font-size: 0.8rem;
    color: #8ac6d1;
}

.stage-connector {
    width: 40px;
    height: 2px;
    background: #393e46;
    margin: 0 5px;
}

.output-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid #393e46;
    padding-bottom: 10px;
}

.tab-btn {
    padding: 10px 20px;
    background: rgba(40, 40, 60, 0.7);
    border: 1px solid #393e46;
    border-bottom: none;
    color: #8ac6d1;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: rgba(0, 173, 181, 0.2);
    color: #00adb5;
    border-color: #00adb5;
    margin-bottom: -1px;
}

.tab-btn:hover:not(.active) {
    background: rgba(83, 52, 131, 0.3);
    color: #d8bfd8;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.output-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 10px 15px;
    background: rgba(83, 52, 131, 0.7);
    border: 1px solid #8a2be2;
    color: #d8bfd8;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.action-btn:hover {
    background: #8a2be2;
    color: white;
    transform: translateY(-2px);
}

.output-box, .analysis-box, .components-box, .analogues-box {
    background: #1e1e2e;
    border: 2px solid #393e46;
    border-radius: 8px;
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

#output, #analysisOutput, #componentsOutput {
    color: #8ac6d1;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(15, 52, 96, 0.3);
    border: 1px solid #00adb5;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    font-size: 2.5rem;
    color: #00adb5;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: white;
}

.stat-label {
    font-size: 0.9rem;
    color: #8ac6d1;
}

.component-types {
    background: rgba(30, 30, 46, 0.7);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #393e46;
}

.types-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.type-badge {
    background: rgba(83, 52, 131, 0.7);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #d8bfd8;
    border: 1px solid #8a2be2;
}

.info-section {
    padding: 25px 30px;
    background: rgba(40, 40, 60, 0.5);
    border-top: 1px solid #393e46;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.info-card {
    background: rgba(30, 30, 46, 0.7);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #00adb5;
    transition: transform 0.3s;
}

.info-card:hover {
    transform: translateY(-5px);
}

.info-card h4 {
    color: #8ac6d1;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

footer {
    background: rgba(15, 52, 96, 0.5);
    padding: 20px 30px;
    text-align: center;
    border-top: 1px solid #393e46;
}

.status {
    margin-top: 10px;
    color: #8ac6d1;
    font-style: italic;
}

.debug-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    font-size: 0.8rem;
    color: #8ac6d1;
}

/* Loading overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.loading-content {
    background: #1a1a2e;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    border: 2px solid #00adb5;
    max-width: 500px;
    width: 90%;
}

.spinner {
    border: 5px solid rgba(0, 173, 181, 0.3);
    border-top: 5px solid #00adb5;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.stage-info {
    margin: 15px 0;
    color: #00adb5;
    font-weight: bold;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(0, 173, 181, 0.3);
    border-radius: 5px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00adb5, #0097a7);
    width: 33%;
    transition: width 0.3s;
}

.loading-time {
    margin-top: 15px;
    color: #8ac6d1;
    font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1001;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #1a1a2e;
    border-radius: 15px;
    border: 2px solid #00adb5;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(90deg, #0f3460 0%, #533483 100%);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #00adb5;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 20px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

/* JSON highlighting */
.json-key { color: #8ac6d1; }
.json-string { color: #98c379; }
.json-number { color: #d19a66; }
.json-boolean { color: #c678dd; }
.json-null { color: #e06c75; }
.json-colon { color: #abb2bf; }
.json-bracket { color: #abb2bf; }
.json-comma { color: #abb2bf; }

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 15px;
    }
    
    .input-section, .output-section {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .output-controls {
        justify-content: center;
    }
    
    .action-btn {
        flex: 1;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== ДОПОЛНИТЕЛЬНЫЕ СТИЛИ ДЛЯ ФУНКЦИОНАЛА АНАЛОГОВ ===== */

.component-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    margin-bottom: 8px;
    background: rgba(30, 30, 46, 0.8);
    border: 1px solid #393e46;
    border-radius: 6px;
    transition: all 0.3s;
}

.component-item:hover {
    background: rgba(40, 40, 60, 0.9);
    border-color: #00adb5;
}

.component-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.component-badge {
    background: #533483;
    color: #d8bfd8;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
    min-width: 40px;
    text-align: center;
}

.component-text {
    color: #8ac6d1;
    font-size: 0.95rem;
}

.analogue-btn {
    background: rgba(0, 173, 181, 0.2);
    border: 1px solid #00adb5;
    color: #00adb5;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
}

.analogue-btn:hover {
    background: #00adb5;
    color: white;
}

.component-with-analogues {
    background: rgba(30, 30, 46, 0.8);
    border: 1px solid #393e46;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.component-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.component-model {
    background: rgba(83, 52, 131, 0.5);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #d8bfd8;
}

.analogue-badge {
    background: rgba(0, 173, 181, 0.2);
    color: #00adb5;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    border: 1px solid #00adb5;
}

.analogue-card {
    background: rgba(40, 40, 60, 0.8);
    border: 1px solid #393e46;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s;
}

.analogue-card:hover {
    border-color: #8a2be2;
    transform: translateY(-2px);
}

.analogue-card.selected {
    border-color: #00adb5;
    background: rgba(0, 173, 181, 0.1);
}

.analogue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.analogue-header h5 {
    color: #8ac6d1;
    margin: 0;
}

.manufacturer {
    background: rgba(83, 52, 131, 0.5);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #d8bfd8;
}

.analogue-body {
    margin-bottom: 15px;
}

.description {
    color: #e6e6e6;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.differences {
    color: #d19a66;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.compatibility {
    color: #8ac6d1;
    font-size: 0.85rem;
}

.compatibility-badge {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
    margin-left: 5px;
}

.compatibility-badge.high {
    background: rgba(152, 195, 121, 0.2);
    color: #98c379;
}

.compatibility-badge.medium {
    background: rgba(209, 154, 102, 0.2);
    color: #d19a66;
}

.compatibility-badge.low {
    background: rgba(224, 108, 117, 0.2);
    color: #e06c75;
}

.compatibility-badge.unknown {
    background: rgba(171, 178, 191, 0.2);
    color: #abb2bf;
}

.select-analogue-btn {
    width: 100%;
    background: rgba(0, 173, 181, 0.2);
    border: 1px solid #00adb5;
    color: #00adb5;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.select-analogue-btn:hover {
    background: #00adb5;
    color: white;
}

.analogue-card.selected .select-analogue-btn {
    background: #00adb5;
    color: white;
}

.loading-analogues {
    text-align: center;
    padding: 30px;
    color: #8ac6d1;
}

.no-analogues {
    text-align: center;
    padding: 30px;
    color: #d19a66;
}

.analogues-modal {
    max-width: 600px;
}

.original-component {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #393e46;
}

.component-card {
    background: rgba(30, 30, 46, 0.8);
    border: 1px solid #393e46;
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
}

.component-card h5 {
    color: #00adb5;
    margin-bottom: 10px;
}

.analogue-selection {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid #393e46;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.analogue-selection label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8ac6d1;
    cursor: pointer;
}

.apply-btn {
    background: linear-gradient(90deg, #00adb5 0%, #0097a7 100%);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.apply-btn:hover:not(:disabled) {
    background: linear-gradient(90deg, #0097a7 0%, #00838f 100%);
    transform: translateY(-2px);
}

.apply-btn:disabled {
    background: #393e46;
    color: #8ac6d1;
    cursor: not-allowed;
    opacity: 0.6;
}

.modified-components {
    background: rgba(30, 30, 46, 0.7);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    border: 1px solid #00adb5;
}

.modified-components ul {
    list-style-type: none;
    padding: 0;
}

.modified-components li {
    padding: 8px 0;
    border-bottom: 1px solid #393e46;
    color: #8ac6d1;
}

.modified-components li:last-child {
    border-bottom: none;
}

.new-model {
    color: #98c379;
    font-weight: bold;
}

.analogues-info {
    color: #8ac6d1;
    font-size: 0.9rem;
    margin-bottom: 15px;
    font-style: italic;
}

/* Анимации */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.loading-analogues i {
    animation: pulse 1.5s infinite;
}

/* Responsive для модального окна аналогов */
@media (max-width: 768px) {
    .analogues-modal {
        width: 95%;
        max-height: 90vh;
    }
    
    .component-with-analogues {
        flex-direction: column;
        gap: 10px;
    }
    
    .analogue-card {
        padding: 10px;
    }
}