* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 3em;
    color: #667eea;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.2em;
}

.search-section {
    margin-bottom: 40px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 300px;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 15px 30px;
    font-size: 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.upload-section {
    margin-bottom: 40px;
}

.upload-section h2 {
    margin-bottom: 20px;
    color: #333;
}

.upload-options {
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 16px;
    color: #333;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.api-select {
    padding: 10px 15px;
    font-size: 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    color: #333;
}

.api-select:focus {
    outline: none;
    border-color: #667eea;
}

.upload-progress {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 10px;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s;
    width: 0%;
}

.progress-text {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin: 0;
}

.upload-hint {
    margin-top: 10px;
    font-size: 13px;
    color: #666;
    text-align: center;
    font-style: italic;
}

.status-messages {
    margin-top: 10px;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
}

.status-messages .status-info {
    color: #1976d2;
    background: #e3f2fd;
    padding: 8px 12px;
    border-radius: 5px;
    margin: 5px 0;
}

.status-messages .status-warning {
    color: #d32f2f;
    background: #ffebee;
    padding: 8px 12px;
    border-radius: 5px;
    margin: 5px 0;
    font-weight: 600;
}

.status-messages .status-success {
    color: #388e3c;
    background: #e8f5e9;
    padding: 8px 12px;
    border-radius: 5px;
    margin: 5px 0;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    background: #f8f9ff;
    transition: background 0.3s;
    cursor: pointer;
    position: relative;
}

.upload-area:hover {
    background: #f0f2ff;
}

.upload-area input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    font-size: 18px;
    color: #667eea;
    font-weight: 600;
    pointer-events: auto;
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
}

.upload-label * {
    pointer-events: none;
}

.upload-icon {
    font-size: 48px;
}

.preview-container {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.preview-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

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

.preview-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.preview-info {
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.05);
    font-size: 12px;
}

.auto-badge {
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.keywords-count {
    color: #666;
    font-size: 11px;
}

.preview-keywords {
    padding: 10px;
    background: #f8f9ff;
    border-top: 1px solid #e0e0e0;
    font-size: 12px;
}

.preview-keywords-label {
    color: #666;
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 11px;
    text-transform: uppercase;
}

.preview-keywords-list {
    color: #333;
    line-height: 1.5;
    word-wrap: break-word;
}

.preview-item .add-keywords-btn {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.results-section h2 {
    margin-bottom: 20px;
    color: #333;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.result-item {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
    background: white;
}

.result-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.result-item img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
}

.result-item .keywords {
    padding: 15px;
    background: #f8f9ff;
}

.result-item .keywords-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-item .keywords-list {
    color: #333;
    font-size: 14px;
    line-height: 1.6;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 40px;
    font-size: 18px;
    grid-column: 1 / -1;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s;
}

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

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideDown 0.3s;
}

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

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: #000;
}

.modal-image-preview {
    margin: 20px 0;
    text-align: center;
}

.modal-image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.keywords-input-section {
    margin: 20px 0;
}

.keywords-input {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    margin-bottom: 10px;
}

.keywords-input:focus {
    outline: none;
    border-color: #667eea;
}

.keywords-hint {
    color: #666;
    font-size: 14px;
    font-style: italic;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .search-section {
        flex-direction: column;
    }

    .search-input {
        min-width: 100%;
    }

    .results-grid,
    .preview-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

