/**
 * ОБЩИЕ СТИЛИ ДЛЯ МОДАЛЬНЫХ ОКОН
 */

/* Контейнер модального окна */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Затемненный фон */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* Контент модального окна */
.modal-content {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Размеры модальных окон */
.modal-sm {
    width: 90%;
    max-width: 450px;
}

.modal-md {
    width: 90%;
    max-width: 650px;
}

.modal-lg {
    width: 90%;
    max-width: 900px;
}

.modal-xl {
    width: 90%;
    max-width: 1200px;
}

/* Фиксированная высота для карточки товара */
#product-card-modal .modal-content {
    height: 90vh;
    max-height: 90vh;
}

/* Заголовок модального окна */
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-title i {
    color: var(--primary-color, #3498db);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background-color: #f0f0f0;
    color: #333;
}

/* Тело модального окна */
.modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

/* Подвал модального окна */
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* ==================
   СТИЛИ ФОРМ В МОДАЛЬНЫХ ОКНАХ
   ================== */

.modal-form {
    width: 100%;
}

.modal-form-group {
    margin-bottom: 16px;
}

.modal-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.modal-form-group label i {
    margin-right: 6px;
    color: var(--primary-color, #3498db);
    width: 16px;
    display: inline-block;
}

.modal-form-group input,
.modal-form-group select,
.modal-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-form-group input:focus,
.modal-form-group select:focus,
.modal-form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color, #3498db);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.modal-form-group input[readonly],
.modal-form-group select[disabled],
.modal-form-group textarea[readonly] {
    background-color: #f5f5f5;
    cursor: not-allowed;
    color: #666;
}

.modal-form-group .readonly-field {
    background-color: #f5f5f5 !important;
    cursor: not-allowed !important;
    color: #666 !important;
}

.modal-form-group select.readonly-field[disabled] {
    opacity: 1;
    -webkit-text-fill-color: #666;
}

.modal-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-form-hint {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
    font-style: italic;
}

.modal-form-error {
    font-size: 12px;
    color: #e74c3c;
    margin-top: 4px;
}

/* Сетка форм */
.modal-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.modal-form-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
}

.modal-form-grid.cols-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.modal-form-group.span-2 {
    grid-column: span 2;
}

.modal-form-group.span-3 {
    grid-column: span 3;
}

/* ==================
   КНОПКИ В МОДАЛЬНЫХ ОКНАХ
   ================== */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    text-decoration: none;
}

.btn i {
    font-size: 14px;
}

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

.btn-primary {
    background-color: var(--primary-color, #3498db);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #229954;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

.btn-warning {
    background-color: #f39c12;
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background-color: #d68910;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(243, 156, 18, 0.3);
}

.btn-cancel,
.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-cancel:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
    background-color: #7f8c8d;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(149, 165, 166, 0.3);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid #ddd;
    color: #333;
}

.btn-outline:hover:not(:disabled) {
    background-color: #f8f9fa;
    border-color: #999;
}

/* ==================
   УВЕДОМЛЕНИЯ
   ================== */

.modal-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 300px;
    max-width: 500px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease-out;
    z-index: 10000;
}

.modal-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.modal-notification i {
    font-size: 24px;
    flex-shrink: 0;
}

.modal-notification-success {
    border-left: 4px solid #27ae60;
}

.modal-notification-success i {
    color: #27ae60;
}

.modal-notification-error {
    border-left: 4px solid #e74c3c;
}

.modal-notification-error i {
    color: #e74c3c;
}

.modal-notification-warning {
    border-left: 4px solid #f39c12;
}

.modal-notification-warning i {
    color: #f39c12;
}

.modal-notification-info {
    border-left: 4px solid #3498db;
}

.modal-notification-info i {
    color: #3498db;
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: #2c3e50;
}

.notification-message {
    font-size: 13px;
    color: #666;
}

.notification-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.notification-close:hover {
    background-color: #f0f0f0;
    color: #333;
}

/* ==================
   ВЫБОР ТОВАРА (PRODUCT PICKER)
   ================== */

.product-picker-search {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.product-picker-search-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.product-picker-search-input:focus {
    outline: none;
    border-color: var(--primary-color, #3498db);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.product-picker-search-btn {
    padding: 10px 20px;
    background-color: var(--primary-color, #3498db);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
}

.product-picker-search-btn:hover {
    background-color: #2980b9;
}

.product-picker-tree.search-active .product-picker-tree-item.search-match .product-picker-item {
    background-color: #fff3cd;
}

.product-picker-tree {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
}

.product-picker-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.product-picker-item {
    padding: 10px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-picker-item:hover {
    background-color: #e3f2fd;
}

.product-picker-item i {
    color: var(--primary-color, #3498db);
    font-size: 14px;
}

.product-item-selectable {
    background-color: #f8f9fa;
    border-left: 3px solid #4caf50;
}

.product-item-selectable:hover {
    background-color: #e8f5e9;
    border-left-color: #2e7d32;
}

.folder-item {
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.folder-item:hover {
    background-color: #f5f5f5;
}

.folder-item i {
    font-size: 14px;
}

.folder-item .fa-folder {
    color: #ffa726;
}

.folder-toggle {
    font-size: 10px;
    color: #999;
    transition: transform 0.2s;
}

.folder-children {
    margin-left: 0;
}

.product-picker-item-name {
    font-weight: 500;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-picker-item-name mark {
    background-color: #ffeb3b;
    padding: 2px 4px;
    border-radius: 2px;
}

.product-picker-item-path {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.product-picker-tree-item {
    margin-bottom: 2px;
}

.product-input-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.product-input-group input {
    flex: 1;
}

.product-input-group button {
    flex-shrink: 0;
    padding: 10px 16px;
    background-color: var(--primary-color, #3498db);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.product-input-group button:hover {
    background-color: #2980b9;
}

.product-input-group button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

/* ==================
   АДАПТИВНОСТЬ
   ================== */

@media (max-width: 768px) {
    .modal-content {
        width: 95% !important;
        max-width: none !important;
        max-height: 95vh;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }

    .modal-form-grid.cols-2,
    .modal-form-grid.cols-3 {
        grid-template-columns: 1fr;
    }

    .modal-form-group.span-2,
    .modal-form-group.span-3 {
        grid-column: span 1;
    }

    .modal-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

