/* === Базовые настройки и сетка === */
@import url('https://fonts.googleapis.com/css2?family=Segoe+UI:wght@300;400;600;700&display=swap');

* {
    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%);
    min-height: 100vh;
    //padding: 20px;
}

.mb-2 {
    margin-bottom: .5rem !important;
}

/* === Каркас приложения === */
.container {
    //max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    //box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 16px;
    opacity: 0.9;
}

/* === Основная область с панелями === */
.main-content {
    background: #f8f9fa;
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 0;
    //min-height: 600px;
    min-height: 100vh;
}

.left-panel {
    background: #f8f9fa;
    padding-left: 25px;
    padding-right: 25px;
    padding-bottom: 25px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 20px);
    //max-height: 100vh;
    border-right: 1px solid #e0e0e0;
    margin-top: 20px;
}

/* Контейнер с уменьшенным масштабом контента левой панели */
.left-panel-inner {
    transform: scale(0.8);
    transform-origin: top left;
    width: 125%;
}

.right-panel {
    background: #fff;
    position: relative;
    display: flex;
    flex-direction: column;
}

#canvas-container {
    flex: 1;
    position: relative;
    min-height: 500px;
    width: 100%;
    height: 100%;
}

#three-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* === Оверлей прогресса === */
#loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 5;
}

#loading-overlay.visible {
    display: flex;
}

#loading-overlay img {
    width: 72px;
    height: 72px;
}

#loading-overlay span {
    margin-top: 14px;
    font-size: 14px;
    font-weight: 600;
    color: #ff7a00;
}

/* === Статистика размещения === */
.stats-overlay {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    min-width: 250px;
    max-width: 320px;
    z-index: 10;
    display: none;
    font-family: 'Segoe UI', sans-serif;
}

.stats-overlay.visible {
    display: block;
}

.stats-overlay.collapsed .stats-content {
    display: none;
}

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

.stats-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.stats-toggle {
    border: none;
    background: rgba(0, 0, 0, 0.1);
    color: #333;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.stats-toggle:hover {
    background: rgba(0, 0, 0, 0.18);
}

.stats-toggle:active {
    transform: scale(0.94);
}

.stats-content {
    display: flex;
    flex-direction: column;
}

.stats-overlay .stat-item {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.stats-overlay .stat-context {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: #555;
    opacity: 0.85;
}

.stats-overlay .stat-label {
    font-weight: 600;
    color: #333;
    display: inline-block;
    min-width: 140px;
}

.input-row.quantity-row {
    gap: 8px;
}

.input-row.quantity-row input {
    flex: 1;
}

input.box-weight {
    min-width: 110px;
}

.stats-overlay .stat-item:last-child {
    margin-bottom: 0;
}

#info-panel {
    padding: 15px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    font-size: 14px;
    color: #666;
}

/* === Общие элементы форм === */
.section {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid #e0e0e0;
}

.section:last-child {
    border-bottom: none;
}

.section h2 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
}

.section h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    margin-bottom: 8px;
}

.input-row {
    display: flex;
    gap: 10px;
}

.input-row input {
    flex: 1;
}

input[type="number"],
input[type="text"],
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Segoe UI', sans-serif;
    transition: border-color 0.3s;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: #667eea;
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #777;
}

/* === Кнопки управления грузами === */
.box-controls {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    z-index: 11;
    font-family: 'Segoe UI', sans-serif;
}

.box-controls button {
    border: none;
    border-radius: 8px;
    padding: 8px 10px;
    min-width: 44px;
    background: linear-gradient(135deg, #ff9955, #ff7a00);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

.box-controls button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(255, 122, 0, 0.35);
}

.box-controls button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.box-controls.visible {
    display: flex;
}

/* === Настройки чекбоксов и справочного текста === */
.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #555;
}

.checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.stacking-control {
    margin-bottom: 12px;
}

/* === Кнопки действий и их состояния === */
.action-buttons {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.action-buttons .btn-secondary {
    flex: 1;
    width: auto;
}

.btn-icon {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    background: #6c757d;
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    min-width: 44px;
    height: 44px;
}

.btn-icon:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-primary,
.btn-secondary,
.btn-add {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Segoe UI', sans-serif;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    margin-bottom: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

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

.btn-add {
    background: #28a745;
    color: white;
}

.btn-add:hover {
    background: #218838;
}

/* === Карточки грузов === */
.box-item {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 15px;
}

.box-item h4 {
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.quantity-row {
    align-items: center;
}

.btn-remove-inline {
    margin-left: 6px;
    padding: 10px 14px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #ff5f5f, #d73838);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn-remove-inline:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(215, 56, 56, 0.35);
}

.btn-remove-inline:active {
    transform: translateY(0);
    box-shadow: none;
}

/* === Панель информации и подсказки === */
#info-panel p {
    margin-bottom: 6px;
}

/* === Адаптивные правки === */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .left-panel {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .right-panel {
        min-height: 400px;
    }

    .box-controls {
        bottom: 10px;
    }
}

