/* Базовые стили */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --border-color: #ddd;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --radius: 8px;
}

* {
    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;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Шапка */
.app-header {
    background: var(--primary-color);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    font-size: 0.9rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--warning-color);
}

.status-dot.connected {
    background: var(--success-color);
}

/* Основной контент */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 20px;
    padding: 20px;
    min-height: calc(100vh - 100px);
}

/* Карточки */
.card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card h2 {
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Поиск товара */
.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.input-group input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.input-group input:focus {
    border-color: var(--secondary-color);
    outline: none;
}

.hint {
    font-size: 0.85rem;
    color: #666;
    text-align: center;
}

/* Кнопки */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    font-weight: 500;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--secondary-color);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-secondary {
    background: var(--light-color);
    color: var(--dark-color);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-icon:hover {
    background: var(--light-color);
}

/* Информация о товаре */
.product-details {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 20px;
    align-items: start;
}

.product-image-container {
    position: relative;
    height: 150px;
    overflow: hidden;
    border-radius: var(--radius);
    background: #f8f9fa;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 0.9rem;
}

.product-text h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.product-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #555;
}

/* Выбор типа этикетки */
.button-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.label-type-btn {
    padding: 15px 10px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.label-type-btn:hover {
    border-color: var(--secondary-color);
    background: #f0f8ff;
}

.label-type-btn.active {
    border-color: var(--secondary-color);
    background: #e3f2fd;
    color: var(--secondary-color);
}

/* Формы */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--primary-color);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
}

.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 5px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Предпросмотр */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.preview-actions {
    display: flex;
    gap: 5px;
}

.preview-container {
    position: relative;
    min-height: 300px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    overflow: hidden;
}

.preview-placeholder {
    text-align: center;
    color: #999;
    padding: 40px;
}

.preview-placeholder i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #ccc;
}

.label-preview {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.preview-loader {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.preview-info {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
}

/* ZPL редактор */
.zpl-textarea {
    width: 100%;
    height: 200px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
    background: #f8f9fa;
}

.zpl-stats {
    text-align: right;
    margin-top: 10px;
    font-size: 0.85rem;
    color: #666;
}

/* Уведомления */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: var(--radius);
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    z-index: 1000;
    max-width: 400px;
}

.notification.success {
    background: var(--success-color);
}

.notification.error {
    background: var(--danger-color);
}

.notification.info {
    background: var(--secondary-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1001;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 20px;
}

/* Адаптивность */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .button-group {
        grid-template-columns: 1fr;
    }
    
    .product-details {
        grid-template-columns: 1fr;
    }
    
    .input-group {
        flex-direction: column;
    }
}

/* Контейнер предпросмотра */
.preview-container {
    position: relative;
    min-height: 300px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    overflow: auto; /* Изменено с hidden на auto */
    padding: 20px;
}

/* Адаптивное изображение этикетки */
.label-preview {
    max-width: 100%;
    max-height: 500px; /* Ограничиваем высоту */
    object-fit: contain;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Для больших этикеток - уменьшаем масштаб */
.label-big {
    transform: scale(0.85);
}

/* Контейнер для скролла при необходимости */
.preview-content {
    max-height: 500px;
    overflow-y: auto;
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Информация о размере этикетки */
.label-size-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary-color);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    z-index: 10;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .preview-container {
        min-height: 250px;
        padding: 10px;
    }
    
    .label-preview {
        max-height: 400px;
    }
    
    .label-big {
        transform: scale(0.7);
    }
}

/* Полоса прокрутки */
.preview-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.preview-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.preview-container::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

.preview-container::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

.btn-icon {
    position: relative;
}

.btn-icon:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark-color);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

/* Группировка кнопок */
.editor-actions,
.preview-actions {
    display: flex;
    gap: 8px;
}

/* Иконки на кнопках скачивания */
#downloadZPL i,
#downloadPNG i {
    font-size: 1rem;
}

#notificationArea {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.notification {
    padding: 15px 20px;
    border-radius: var(--radius);
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease, slideOut 0.3s ease 4.7s forwards;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 400px;
    min-width: 300px;
    opacity: 1;
    transform: translateX(0);
    transition: all 0.3s ease;
}

/* Анимация появления */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Анимация исчезновения */
@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Цвета уведомлений */
.notification.success {
    background: var(--success-color);
    border-left: 4px solid #1e8449;
}

.notification.error {
    background: var(--danger-color);
    border-left: 4px solid #c0392b;
}

.notification.info {
    background: var(--secondary-color);
    border-left: 4px solid #2980b9;
}

.notification.warning {
    background: var(--warning-color);
    border-left: 4px solid #d68910;
    color: #333;
}

/* Иконки в уведомлениях */
.notification i {
    font-size: 1.2rem;
    min-width: 20px;
}

/* Эффект при наведении */
.notification:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
}

/* Кнопка закрытия уведомления */
.notification-close {
    margin-left: auto;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    opacity: 0.7;
    font-size: 1rem;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.notification-close:hover {
    opacity: 1;
    background: rgba(255,255,255,0.2);
}

/* Для длинных сообщений */
.notification span {
    flex: 1;
    word-break: break-word;
}

/* Самый простой вариант - используем CSS Grid */
#notificationArea {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: min-content;
    gap: 10px;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px; /* Для скроллбара */
}

/* Стиль скроллбара */
#notificationArea::-webkit-scrollbar {
    width: 5px;
}

#notificationArea::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

#notificationArea::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 10px;
}

.notification {
    padding: 15px 20px;
    border-radius: var(--radius);
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 400px;
    animation: slideIn 0.3s ease forwards;
    transform: translateX(0);
    opacity: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

