/* Apple-style Design System */
:root {
    --apple-primary: #007AFF;
    --apple-primary-dark: #0056CC;
    --apple-success: #34C759;
    --apple-danger: #FF3B30;
    --apple-warning: #FF9500;
    --apple-background: #FFFFFF;
    --apple-secondary-bg: #F2F2F7;
    --apple-tertiary-bg: #E5E5EA;
    --apple-label: #000000;
    --apple-secondary-label: #8E8E93;
    --apple-border: #C7C7CC;
    --apple-card-shadow: 0px 4px 16px rgba(0, 0, 0, 0.04);
    --apple-modal-shadow: 0px 10px 30px rgba(0, 0, 0, 0.1);
}

/* Base Styles */
.apple-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.apple-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--apple-border);
}

.apple-title {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: var(--apple-label);
    letter-spacing: -0.3px;
    margin: 0;
}

/* Form Elements */
.apple-form-group {
    margin-bottom: 24px;
}

.apple-label {
    display: block;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--apple-secondary-label);
    margin-bottom: 6px;
    letter-spacing: -0.15px;
}

.apple-input,
.apple-textarea,
.apple-select {
    width: 100%;
    padding: 14px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 16px;
    border: 1px solid var(--apple-border);
    border-radius: 12px;
    background: var(--apple-background);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

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

.apple-textarea {
    min-height: 120px;
    resize: vertical;
}

/* Product Selection */
.product-selection-container {
    background: var(--apple-secondary-bg);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
}

.product-selection-title {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--apple-label);
}

.product-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 768px) {
    .product-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.product-field {
    position: relative;
}

.product-search-input {
    padding-right: 40px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--apple-background);
    border: 1px solid var(--apple-border);
    border-radius: 12px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--apple-modal-shadow);
    display: none;
}

.search-result-item {
    padding: 12px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 15px;
    border-bottom: 1px solid var(--apple-tertiary-bg);
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-result-item:hover {
    background: var(--apple-secondary-bg);
}

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

.product-type-badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
    margin-left: 8px;
    font-weight: 500;
}

.badge-pesticide { background: var(--apple-success); color: white; }
.badge-fertilizer { background: var(--apple-warning); color: white; }
.badge-seed { background: var(--apple-primary); color: white; }

.selected-product {
    background: var(--apple-secondary-bg);
    border-radius: 12px;
    padding: 12px 16px;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.selected-product-name {
    font-weight: 500;
}

.remove-product {
    color: var(--apple-danger);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
}

/* Argument Type */
.argument-type-container {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.argument-type-btn {
    flex: 1;
    padding: 14px;
    border: 2px solid var(--apple-border);
    border-radius: 12px;
    background: var(--apple-background);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.argument-type-btn:hover {
    border-color: var(--apple-primary);
}

.argument-type-btn.active {
    border-color: var(--apple-primary);
    background: rgba(0, 122, 255, 0.1);
}

.argument-type-btn.advantage.active {
    border-color: var(--apple-success);
    background: rgba(52, 199, 89, 0.1);
}

.argument-type-btn.disadvantage.active {
    border-color: var(--apple-danger);
    background: rgba(255, 59, 48, 0.1);
}

/* File Upload */
.file-upload-area {
    border: 2px dashed var(--apple-border);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    background: var(--apple-secondary-bg);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 24px;
}

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

.file-upload-area.dragover {
    border-color: var(--apple-primary);
    background: rgba(0, 122, 255, 0.1);
}

.upload-icon {
    font-size: 48px;
    color: var(--apple-secondary-label);
    margin-bottom: 12px;
}

.upload-text {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 16px;
    color: var(--apple-label);
    margin-bottom: 4px;
}

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

/* Image Preview */
.image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.image-preview {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: var(--apple-secondary-bg);
}

.preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.preview-img:hover {
    transform: scale(1.05);
}

.remove-image {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--apple-danger);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.image-preview:hover .remove-image {
    opacity: 1;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 12px;
    margin-top: 32px;
}

.apple-btn {
    flex: 1;
    padding: 16px 24px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 17px;
    font-weight: 500;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

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

.apple-btn.primary:hover {
    background: var(--apple-primary-dark);
}

.apple-btn.secondary {
    background: var(--apple-secondary-bg);
    color: var(--apple-label);
}

.apple-btn.secondary:hover {
    background: var(--apple-tertiary-bg);
}

.apple-btn.success {
    background: var(--apple-success);
    color: white;
}

.apple-btn.success:hover {
    background: #2DA34E;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    display: none;
}

.apple-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--apple-tertiary-bg);
    border-top-color: var(--apple-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 17px;
    color: var(--apple-label);
    font-weight: 500;
}

/* Alerts */
.apple-alert {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    animation: slideIn 0.3s ease;
}

.alert-success {
    background: rgba(52, 199, 89, 0.1);
    border: 1px solid var(--apple-success);
    color: #2DA34E;
}

.alert-error {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid var(--apple-danger);
    color: #D70015;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Responsive */
@media (max-width: 768px) {
    .apple-container {
        padding: 16px;
    }
    
    .apple-title {
        font-size: 24px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .argument-type-container {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .apple-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .image-preview-container {
        grid-template-columns: repeat(2, 1fr);
    }
}