/* ========== ОСНОВНЫЕ СТИЛИ ========== */
:root {
    --apple-blue: #007aff;
    --apple-blue-hover: #005bbf;
    --apple-green: #34c759;
    --apple-red: #ff3b30;
    --apple-orange: #ff9500;
    --apple-gray: #8e8e93;
    --apple-light-gray: #e5e5ea;
    --apple-background: #f5f5f7;
    --apple-white: #ffffff;
    --apple-black: #1c1c1e;
    --apple-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --apple-shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.12);
    --apple-border-radius: 12px;
    --apple-border-radius-sm: 8px;
    --apple-transition: all 0.2s ease;
}

/* ========== КОНТЕЙНЕРЫ ========== */
.apple-file-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
    background: var(--apple-background);
    min-height: calc(100vh - 60px);
}

.apple-file-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.back-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--apple-white);
    border-radius: 50%;
    color: var(--apple-black);
    cursor: pointer;
    transition: var(--apple-transition);
    box-shadow: var(--apple-shadow);
}

.back-button:hover {
    background: var(--apple-light-gray);
    transform: scale(0.95);
}

.apple-file-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--apple-black);
    margin: 0;
}

/* ========== КАРТОЧКА ФОРМЫ ========== */
.apple-file-card {
    background: var(--apple-white);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--apple-shadow);
    margin-bottom: 24px;
}

/* ========== СЕКЦИЯ ВЫБОРА ПРОДУКТОВ ========== */
.product-section {
    margin-bottom: 32px;
    border-bottom: 1px solid var(--apple-light-gray);
    padding-bottom: 24px;
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.product-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--apple-black);
    margin: 0;
}

.add-product-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--apple-blue);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--apple-transition);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.add-product-btn:hover {
    background: var(--apple-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4);
}

.add-product-btn svg {
    transition: transform 0.3s;
}

.add-product-btn:hover svg {
    transform: rotate(90deg);
}

/* ========== СЕТКА ПРОДУКТОВ ========== */
.products-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 16px;
}

.product-search-item {
    background: var(--apple-background);
    border-radius: var(--apple-border-radius);
    padding: 20px;
    border: 1px solid transparent;
    transition: var(--apple-transition);
    animation: slideIn 0.3s ease;
}

.product-search-item:hover {
    border-color: var(--apple-blue);
    box-shadow: var(--apple-shadow);
}

.product-search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.product-search-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--apple-black);
}

.remove-product-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255, 59, 48, 0.1);
    color: var(--apple-red);
    border: 1px solid rgba(255, 59, 48, 0.2);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--apple-transition);
}

.remove-product-btn:hover {
    background: var(--apple-red);
    color: white;
    border-color: var(--apple-red);
}

.product-search-wrapper {
    position: relative;
    width: 100%;
}

.product-search-input {
    width: 100%;
    padding: 14px 16px;
    background: white;
    border: 1.5px solid var(--apple-light-gray);
    border-radius: var(--apple-border-radius-sm);
    font-size: 15px;
    transition: var(--apple-transition);
}

.product-search-input:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    outline: none;
}

/* ========== РЕЗУЛЬТАТЫ ПОИСКА ========== */
.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--apple-border-radius);
    box-shadow: var(--apple-shadow-hover);
    max-height: 280px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    border: 1px solid var(--apple-light-gray);
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--apple-transition);
    border-bottom: 1px solid var(--apple-light-gray);
}

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

.search-result-item:hover {
    background: rgba(0, 122, 255, 0.05);
}

.product-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--apple-black);
}

.product-type-badge {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.badge-pesticide {
    background: rgba(52, 199, 89, 0.1);
    color: #1e7b3c;
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.badge-fertilizer {
    background: rgba(0, 122, 255, 0.1);
    color: var(--apple-blue);
    border: 1px solid rgba(0, 122, 255, 0.2);
}

.badge-seed {
    background: rgba(255, 149, 0, 0.1);
    color: #b15e00;
    border: 1px solid rgba(255, 149, 0, 0.2);
}

/* ========== ВЫБРАННЫЙ ПРОДУКТ ========== */
.selected-product {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f0f8ff, #e6f2ff);
    border-radius: var(--apple-border-radius-sm);
    margin-top: 12px;
    border: 1px solid rgba(0, 122, 255, 0.2);
    animation: fadeIn 0.3s ease;
}

.selected-product-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.selected-product-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    color: var(--apple-blue);
}

.selected-product-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--apple-black);
}

.selected-product-type {
    font-size: 12px;
    color: var(--apple-gray);
}

/* ========== ЗАГРУЗКА ФАЙЛОВ ========== */
.file-upload-section {
    margin-bottom: 24px;
}

.file-upload-area {
    background: linear-gradient(135deg, #f9f9fb, #f2f2f5);
    border: 2px dashed var(--apple-gray);
    border-radius: 20px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--apple-transition);
    margin-bottom: 20px;
}

.file-upload-area:hover {
    border-color: var(--apple-blue);
    background: rgba(0, 122, 255, 0.02);
}

.file-upload-area.dragover {
    border-color: var(--apple-blue);
    background: rgba(0, 122, 255, 0.05);
    transform: scale(1.02);
}

.upload-icon {
    margin-bottom: 16px;
    color: var(--apple-gray);
}

.upload-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--apple-black);
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 14px;
    color: var(--apple-gray);
}

/* ========== ПРЕВЬЮ ФАЙЛОВ ========== */
.files-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.file-preview-card {
    background: white;
    border-radius: var(--apple-border-radius);
    padding: 16px;
    box-shadow: var(--apple-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: relative;
    animation: slideIn 0.3s ease;
    border: 1px solid var(--apple-light-gray);
}

.file-preview-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--apple-background);
    border-radius: 12px;
}

.file-preview-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--apple-black);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-size {
    font-size: 11px;
    color: var(--apple-gray);
}

.remove-file-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 28px;
    height: 28px;
    background: white;
    border: 1px solid var(--apple-light-gray);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--apple-red);
    cursor: pointer;
    transition: var(--apple-transition);
    box-shadow: var(--apple-shadow);
}

.remove-file-btn:hover {
    background: var(--apple-red);
    color: white;
    transform: rotate(90deg);
}

/* ========== ПОЛЯ ФОРМЫ ========== */
.apple-form-group {
    margin-bottom: 24px;
}

.apple-label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--apple-black);
    margin-bottom: 8px;
}

.apple-input {
    width: 100%;
    padding: 14px 16px;
    background: white;
    border: 1.5px solid var(--apple-light-gray);
    border-radius: var(--apple-border-radius-sm);
    font-size: 15px;
    transition: var(--apple-transition);
    box-sizing: border-box;
}

.apple-input:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    outline: none;
}

.apple-textarea {
    width: 100%;
    padding: 14px 16px;
    background: white;
    border: 1.5px solid var(--apple-light-gray);
    border-radius: var(--apple-border-radius-sm);
    font-size: 15px;
    transition: var(--apple-transition);
    min-height: 120px;
    resize: vertical;
    box-sizing: border-box;
}

.apple-textarea:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    outline: none;
}

/* ========== КНОПКИ ========== */
.button-group {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    margin-top: 32px;
}

.apple-btn {
    padding: 14px 32px;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--apple-transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.apple-btn.primary {
    background: var(--apple-blue);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.apple-btn.primary:hover {
    background: var(--apple-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 122, 255, 0.4);
}

.apple-btn.secondary {
    background: white;
    color: var(--apple-blue);
    border: 1.5px solid var(--apple-blue);
}

.apple-btn.secondary:hover {
    background: rgba(0, 122, 255, 0.05);
    transform: translateY(-2px);
}

/* ========== АЛЕРТЫ ========== */
.apple-alert {
    padding: 16px 20px;
    border-radius: var(--apple-border-radius);
    margin-bottom: 20px;
    font-size: 15px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

.alert-success {
    background: rgba(52, 199, 89, 0.1);
    color: #1e7b3c;
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.alert-error {
    background: rgba(255, 59, 48, 0.1);
    color: #c41e1e;
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.alert-warning {
    background: rgba(255, 149, 0, 0.1);
    color: #b15e00;
    border: 1px solid rgba(255, 149, 0, 0.2);
}

.alert-info {
    background: rgba(0, 122, 255, 0.1);
    color: var(--apple-blue);
    border: 1px solid rgba(0, 122, 255, 0.2);
}

/* ========== ОВЕРЛЕЙ ЗАГРУЗКИ ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
}

.apple-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loading-text {
    color: white;
    font-size: 18px;
    font-weight: 500;
}

/* ========== МОДАЛЬНОЕ ОКНО ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--apple-black);
}

.modal-close {
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--apple-gray);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--apple-transition);
}

.modal-close:hover {
    background: rgba(255, 59, 48, 0.1);
    color: var(--apple-red);
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid var(--apple-light-gray);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--apple-transition);
}

.modal-btn-primary {
    background: var(--apple-blue);
    color: white;
}

.modal-btn-primary:hover {
    background: var(--apple-blue-hover);
    transform: translateY(-2px);
}

.modal-btn-secondary {
    background: var(--apple-light-gray);
    color: var(--apple-black);
}

.modal-btn-secondary:hover {
    background: #d1d1d6;
}

/* ========== СПИСОК ПРОДУКТОВ ========== */
.products-list {
    margin-top: 24px;
    background: var(--apple-background);
    border-radius: var(--apple-border-radius);
    padding: 20px;
}

.products-list-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--apple-black);
    margin-bottom: 16px;
}

.products-list-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.product-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: var(--apple-border-radius-sm);
    border: 1px solid var(--apple-light-gray);
    transition: var(--apple-transition);
}

.product-list-item:hover {
    border-color: var(--apple-blue);
    transform: translateX(4px);
}

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

.product-list-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--apple-black);
}

.product-list-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--apple-gray);
}

.product-list-remove {
    padding: 6px;
    background: transparent;
    border: none;
    color: var(--apple-gray);
    cursor: pointer;
    border-radius: 50%;
    transition: var(--apple-transition);
}

.product-list-remove:hover {
    background: rgba(255, 59, 48, 0.1);
    color: var(--apple-red);
}

/* ========== АНИМАЦИИ ========== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 768px) {
    .apple-file-container {
        padding: 16px;
    }
    
    .apple-file-card {
        padding: 20px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .apple-btn {
        width: 100%;
        justify-content: center;
    }
    
    .product-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .add-product-btn {
        width: 100%;
        justify-content: center;
    }
    
    .files-preview-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .apple-file-title {
        font-size: 24px;
    }
    
    .modal-content {
        width: 95%;
    }
}