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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.2em;
    opacity: 0.9;
}

.form-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.section {
    margin-bottom: 30px;
}

.section h2 {
    margin-bottom: 15px;
    color: #4a5568;
    font-size: 1.3em;
}

.api-key-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.api-key-section label {
    font-weight: 600;
    color: #4a5568;
}

.api-key-section input {
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.api-key-section input:focus {
    outline: none;
    border-color: #667eea;
}

.api-key-section small {
    color: #667eea;
}

.api-key-section small a {
    color: #667eea;
    text-decoration: none;
}

.api-key-section small a:hover {
    text-decoration: underline;
}

.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

@media (max-width: 600px) {
    .upload-grid {
        grid-template-columns: 1fr;
    }
}

.upload-box {
    text-align: center;
}

.upload-box label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 10px;
}

.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.preview {
    border: 3px dashed #cbd5e0;
    border-radius: 16px;
    padding: 40px 20px;
    transition: all 0.3s ease;
    background: linear-gradient(145deg, #f8fafc 0%, #e2e8f0 100%);
    cursor: pointer;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(102, 126, 234, 0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.preview:hover::before {
    transform: translateX(100%);
}

.preview:hover {
    border-color: #667eea;
    background: linear-gradient(145deg, #667eea15, #764ba215);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.2);
}

.preview.drag-over {
    border-color: #48bb78;
    background: linear-gradient(145deg, #48bb7815, #38a16915);
    transform: scale(1.02);
    box-shadow: 0 15px 35px rgba(72, 187, 120, 0.3);
}

.preview.has-image {
    border-style: solid;
    border-color: #48bb78;
    background: linear-gradient(145deg, #f0fff4, #e6fffa);
    box-shadow: 0 8px 25px rgba(72, 187, 120, 0.15);
}

.preview img {
    max-width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

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

.preview .upload-text {
    font-size: 1.1em;
    color: #4a5568;
    font-weight: 500;
    margin-bottom: 8px;
}

.preview .upload-hint {
    font-size: 0.9em;
    color: #718096;
    text-align: center;
    margin-top: 8px;
}

.preview.drag-over .upload-text {
    color: #48bb78;
    font-weight: 600;
}

.process-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.process-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.process-btn:hover:not(:disabled)::before {
    left: 100%;
}

.process-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
}

.process-btn:active:not(:disabled) {
    transform: translateY(-1px);
}

.process-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.process-btn .btn-text {
    display: block;
}

.process-btn.loading .btn-text {
    display: none;
}

.loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.process-btn.loading .loading {
    display: flex;
}

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

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

.process-btn.loading {
    background: linear-gradient(135deg, #4c51bf 0%, #553c9a 100%);
    cursor: wait;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 8px 25px rgba(76, 81, 191, 0.3); }
    50% { box-shadow: 0 8px 35px rgba(76, 81, 191, 0.5); }
    100% { box-shadow: 0 8px 25px rgba(76, 81, 191, 0.3); }
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.result-item {
    text-align: center;
}

.result-item img {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

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

.result-item button {
    margin-top: 10px;
    padding: 8px 16px;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
}

.result-item button:hover {
    background: #38a169;
}

.download-btn {
    width: 100%;
    padding: 12px;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.download-btn:hover {
    background: #38a169;
}

.error-section {
    background: #fed7d7;
    border: 1px solid #feb2b2;
    border-radius: 10px;
    padding: 20px;
    color: #c53030;
}

.error-section h2 {
    color: #c53030;
}

footer {
    text-align: center;
    margin-top: 30px;
    color: rgba(255,255,255,0.8);
    font-size: 0.9em;
}

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

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

@keyframes scaleIn {
    from { 
        opacity: 0; 
        transform: scale(0.8); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

.section {
    animation: fadeIn 0.8s ease-out;
}

.section:nth-child(even) {
    animation: slideInUp 0.8s ease-out;
    animation-delay: 0.1s;
    animation-fill-mode: both;
}

.result-item {
    animation: scaleIn 0.5s ease-out;
}

.result-item:nth-child(even) {
    animation-delay: 0.1s;
    animation-fill-mode: both;
}

/* Enhanced transitions */
.api-key-section input {
    transition: all 0.3s ease;
}

.api-key-section input:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.upload-box label {
    transition: color 0.3s ease;
}

.upload-box:hover label {
    color: #667eea;
}