:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-dark: #1f2937;
    --bg-light: #f9fafb;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-secondary-active: #f3f4f6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
}

.header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

/* Переключатель окружения */
.env-selector {
    display: flex;
    align-items: center;
    gap: 15px;
}

.env-toggle-input {
    display: none;
}

.env-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 32px;
    cursor: pointer;
}

.env-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--primary-color);
    transition: .4s;
    border-radius: 34px;
}

.env-switch .slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.env-toggle-input:checked + .env-switch .slider {
    background-color: var(--secondary-color);
}

.env-toggle-input:checked + .env-switch .slider:before {
    transform: translateX(28px);
}

.env-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.env-text.prod-text { order: 3; }
.env-text.test-text { order: 1; }

.env-toggle-input:not(:checked) ~ .env-text.test-text { color: var(--primary-color); font-weight: 600; }
.env-toggle-input:not(:checked) ~ .env-text.prod-text { color: var(--text-secondary); opacity: 0.5; }
.env-toggle-input:checked ~ .env-text.test-text { color: var(--text-secondary); opacity: 0.5; }
.env-toggle-input:checked ~ .env-text.prod-text { color: var(--secondary-color); font-weight: 600; opacity: 1; }

.env-text:hover { background: var(--bg-light); }

.sidebar {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-lg);
    height: fit-content;
    position: sticky;
    top: 20px;
}

.request-menu {
    max-height: 600px;
    overflow-y: auto;
}

.request-item {
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.request-item:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.request-item.active {
    background: var(--primary-color);
    color: var(--text-secondary-active);
    border-color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.request-item .name {
    font-weight: 600;
    margin-bottom: 4px;
}

.request-item .desc {
    font-size: 13px;
    opacity: 0.9;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.request-header {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-lg);
}

#requestTitle {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--primary-color);
}

#requestDescription {
    color: var(--text-secondary);
    font-size: 16px;
}

.form-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-lg);
}

.form-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--primary-color);
}

#paramsContainer {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.param-group {
    display: flex;
    flex-direction: column;
    /*gap: 8px;*/
}

.param-group label {
    font-weight: 500;
    color: var(--text-primary);
}

.param-group input,
.param-group select,
.param-group textarea {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    transition: border-color 0.3s;
    width: 100%;
    font-family: inherit;
}

.param-group input:focus,
.param-group select:focus,
.param-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.param-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-2px);
}

.response-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.response-tabs {
    display: flex;
    gap: 10px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-btn:hover { color: var(--primary-color); }
.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.response-content {
    min-height: 400px;
    flex: 1;
}

.tab-content {
    display: none;
}

.tab-content.active { display: block; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.json-response {
    background: #f8f9fa;
    padding: 20px;
    border-radius: var(--radius-md);
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: auto;
    max-height: 500px;
    border-left: 4px solid var(--secondary-color);
    white-space: pre;
    margin: 0;
}

.params-display {
    padding: 20px;
    background: white;
    border-radius: var(--radius-md);
    font-family: 'Courier New', monospace;
    font-size: 15px;
    line-height: 1.8;
    white-space: pre-wrap;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary-color);
    max-height: 500px;
    overflow-y: auto;
}

.params-display strong { color: var(--primary-color); font-weight: 600; }
.params-display .empty { color: var(--text-secondary); font-style: italic; }

.xml-code {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: var(--radius-md);
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    max-height: 500px;
    display: block;
    white-space: pre;
    tab-size: 4;
    overflow-x: auto;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.error-response {
    background: #fef2f2;
    border-left: 4px solid var(--danger-color);
    padding: 20px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
}

.success-response {
    background: #f0fdf4;
    border-left: 4px solid var(--secondary-color);
    padding: 20px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 300px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(99, 102, 241, 0.3);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.notification.show { transform: translateX(0); }

.notification.info    { background: var(--primary-color); }
.notification.success { background: var(--secondary-color); }
.notification.error   { background: var(--danger-color); }

@media (max-width: 900px) {
    .container { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .env-selector { flex-direction: column; align-items: flex-start; gap: 8px; }
    .env-text { order: unset !important; }
}

/* ──────────────────────────────────────────────
   ДИНАМИЧЕСКИЕ МАССИВЫ (улучшенный дизайн 2025)
─────────────────────────────────────────────── */

.dynamic-button-group {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
}

.array-items-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    grid-column: 1 / -1;
    margin-top: 15px;
}

.array-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    flex-wrap: wrap;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 45px 15px 15px 15px;
    background: var(--bg-light);
    position: relative;
    box-shadow: var(--shadow-sm);
}

.array-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    flex: 1;
    min-width: 0;
}

.array-fields .param-group {
    flex: 1;
    min-width: 180px;
    margin-bottom: 0;
}

.btn-add-item {
    width: 100%;
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-add-item:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-remove-item {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 6px 10px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-remove-item:hover {
    background: #dc2626;
    transform: scale(1.05);
}
/* Специальные стили для GetOstatok_Temp - размещаем кнопку рядом с платформой */
#paramsContainer {
    display: flex;
    flex-direction: column;
}

/* Находим контейнер с полем Platform и перемещаем кнопку */
#paramsContainer > .param-group:first-child {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 15px;
    margin-bottom: 20px;
}

#paramsContainer > .param-group:first-child label {
    width: 100%;
    margin-bottom: 5px;
}

#paramsContainer > .param-group:first-child select,
#paramsContainer > .param-group:first-child input {
    flex: 1;
    min-width: 200px;
}


/* Создаем новую кнопку рядом с платформой */
.paramsContainer > .param-group:first-child::after {
    content: "Добавить товар";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    height: 42px;
    white-space: nowrap;
}

#paramsContainer > .param-group:first-child:hover::after {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    #paramsContainer > .param-group:first-child {
        flex-direction: column;
        align-items: stretch;
    }
    
    #paramsContainer > .param-group:first-child::after {
        width: 100%;
    }
}