:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    animation: fadeInDown 0.6s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo i {
    font-size: 3rem;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 8px;
}

/* Upload Section */
.upload-section {
    animation: fadeInUp 0.6s ease-out;
    /* Измените расположение формы здесь: */
    /* margin: 0 auto; - центрирование */
    /* max-width: 800px; - ограничение ширины */
    /* margin-left: 0; - слева */
    /* margin-right: auto; - справа */
    /* position: relative; - для абсолютного позиционирования */
}

.upload-card {
    background: var(--card-background);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    /* Измените расположение карточки здесь: */
    /* margin: 0 auto; - центрирование */
    /* max-width: 600px; - ограничение ширины */
    /* margin-left: 50px; - отступ слева */
    /* margin-right: 50px; - отступ справа */
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.upload-card h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.upload-description {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 15px;
    padding: 60px 40px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #f8fafc;
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background: #eef2ff;
    transform: scale(1.02);
}

.upload-content i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.upload-content p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.browse-link {
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
}

.browse-link:hover {
    text-decoration: underline;
}

/* File Info */
.file-info {
    background: #f8fafc;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.file-details {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-details i {
    font-size: 2rem;
    color: var(--primary-color);
}

.file-name-size {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.file-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.file-size {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-remove:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-action {
    border: none;
    border-radius: 12px;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.btn-action {
    background: #f8fafc;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 12px 30px;
}

.btn-action:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* Progress Section */
.progress-section {
    animation: fadeInUp 0.6s ease-out;
}

.progress-card {
    background: var(--card-background);
    border-radius: 20px;
    padding: 60px 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.progress-icon {
    margin-bottom: 30px;
}

.spinner {
    width: 80px;
    height: 80px;
    border: 6px solid #e2e8f0;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.progress-card h3 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.progress-text {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.progress-bar {
    background: #e2e8f0;
    border-radius: 50px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    height: 100%;
    border-radius: 50px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-percentage {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Results Section */
.results-section {
    animation: fadeInUp 0.6s ease-out;
}

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

.results-header h2 {
    color: white;
    font-size: 2rem;
    display: flex;
    align-items: center;
    gap: 15px;
}

.success-icon {
    color: var(--secondary-color);
}

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

.result-card {
    background: var(--card-background);
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.result-card.full-width {
    grid-column: 1 / -1;
}

.result-card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
}

.result-card-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.result-card-body {
    padding: 25px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.info-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

/* Table */
.table-container {
    overflow-x: auto;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table th {
    background: #f8fafc;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

.items-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.items-table tr:hover {
    background: #f8fafc;
}

.items-table tr:last-child td {
    border-bottom: none;
}

/* Actions Section */
.actions-section {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* JSON Viewer */
.json-viewer {
    background: var(--card-background);
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.json-viewer-header {
    background: #1e293b;
    color: white;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.json-viewer-header h4 {
    margin: 0;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
}

.btn-toggle {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.btn-toggle.active {
    transform: rotate(180deg);
}

.json-content {
    background: #1e293b;
    color: #94a3b8;
    padding: 25px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

/* Error Section */
.error-section {
    animation: fadeInUp 0.6s ease-out;
}

.error-card {
    background: var(--card-background);
    border-radius: 20px;
    padding: 60px 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.error-card i {
    font-size: 4rem;
    color: var(--danger-color);
    margin-bottom: 20px;
}

.error-card h3 {
    font-size: 1.8rem;
    margin-bottom: 15px;
}

.error-card p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.error-card p a {
    color: var(--primary-color);
    text-decoration: underline;
    word-break: break-all;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-background);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: slideInUp 0.3s ease;
}

.modal-header {
    padding: 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 25px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Переключатель режима авторизации */
.auth-mode-switcher {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
}

.mode-btn {
    flex: 1;
    padding: 10px 15px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mode-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.mode-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mode-btn i {
    font-size: 1rem;
}

/* Контент режима авторизации */
.auth-mode-content {
    animation: fadeIn 0.3s ease;
}

/* Поле ввода с иконкой */
.input-with-icon {
    position: relative;
}

.input-with-icon input {
    padding-right: 45px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.toggle-password:hover {
    color: var(--primary-color);
}

/* Сообщения авторизации */
.auth-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
}

.auth-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.auth-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.auth-message i {
    font-size: 1.1rem;
}

/* Ссылка на регистрацию */
.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 8px 0;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.3s ease;
    width: 100%;
    justify-content: center;
}

.btn-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.btn-link i {
    font-size: 0.85rem;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Settings Button */
.btn-settings {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white;
    color: var(--primary-color);
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    z-index: 100;
}

.btn-settings:hover {
    transform: scale(1.1) rotate(90deg);
    background: var(--primary-color);
    color: white;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Editable Data Section */
.editable-section {
    margin-bottom: 30px;
    grid-column: 1 / -1;
}

.editable-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 20px;
    margin-bottom: 25px;
    align-items: start;
}

.editable-group {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    background: #f8fafc;
}

.editable-group-title {
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.editable-field {
    margin-bottom: 15px;
}

.editable-field:last-child {
    margin-bottom: 0;
}

.editable-label {
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.editable-input,
.editable-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
}

.editable-input:focus,
.editable-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.editable-textarea {
    min-height: 80px;
    resize: vertical;
}

.editable-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    table-layout: auto; /* Автоматическая раскладка для гибкости */
}

.editable-items-table th {
    background: var(--primary-color);
    color: white;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
}

.editable-items-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* Колонки с цифрами - минимальная ширина, только для цифр */
.editable-items-table th.col-numeric,
.editable-items-table td.col-numeric {
    width: 1%; /* Минимальная ширина */
    min-width: 70px;
    max-width: 120px;
    white-space: nowrap;
    text-align: right; /* Выравнивание цифр по правому краю */
}

.editable-items-table th.col-numeric {
    text-align: center; /* Заголовки по центру */
}

/* Колонка с товаром - занимает все оставшееся место, многострочный текст */
.editable-items-table th.col-product,
.editable-items-table td.col-product {
    width: auto; /* Автоматическая ширина, занимает оставшееся место */
    min-width: 250px;
    white-space: normal; /* Разрешаем перенос строк */
    word-wrap: break-word; /* Перенос длинных слов */
    word-break: break-word; /* Перенос слов при необходимости */
}

/* Остальные колонки - средняя ширина */
.editable-items-table th.col-default,
.editable-items-table td.col-default {
    width: auto;
    min-width: 90px;
    max-width: 180px;
}

.editable-items-table input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.editable-items-table input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Textarea для колонки товара - многострочный текст */
.editable-items-table td.col-product textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    box-sizing: border-box;
    white-space: pre-wrap; /* Сохраняем переносы строк и переносим текст */
    word-wrap: break-word;
    word-break: break-word;
    min-height: 60px; /* Минимальная высота для многострочного текста */
    resize: vertical; /* Разрешаем изменение размера по вертикали */
    font-family: inherit; /* Наследуем шрифт */
    line-height: 1.4;
}

.editable-items-table td.col-product textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.save-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: nowrap;
}

.btn-save-action {
    font-size: 1.1rem;
    padding: 18px 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    white-space: nowrap;
}

.save-section #backBtn {
    min-width: 140px;
}

.save-section #saveAndContinueBtn {
    min-width: 220px;
    max-width: 280px;
}

/* Responsive */
@media (max-width: 1200px) {
    .editable-data-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .upload-card {
        padding: 30px 20px;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .results-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .actions-section {
        flex-direction: column;
    }

    .btn-action {
        width: 100%;
    }

    .btn-settings {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .editable-data-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .editable-group {
        padding: 12px;
    }

    .btn-save {
        min-width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        max-width: 100%;
    }

    .editable-group {
        padding: 10px;
    }

    .editable-field {
        margin-bottom: 12px;
    }

    .editable-label {
        font-size: 0.85rem;
    }

    .editable-input,
    .editable-textarea {
        font-size: 0.9rem;
        padding: 8px 10px;
    }
}


/* Parse Buttons - Two buttons side by side */
.parse-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.btn-fast, .btn-detailed {
    border: none;
    border-radius: 12px;
    padding: 15px 30px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    flex: 1;
    width: auto; /* Переопределяем width: 100% из btn-primary */
}

.btn-fast {
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
}

.btn-fast:hover:not(:disabled) {
    background: linear-gradient(135deg, #d97706 0%, #ea580c 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-detailed {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
}

.btn-detailed:hover:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-fast i, .btn-detailed i {
    font-size: 1.2rem;
}

/* Confirm Dialog Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
