/* Reset and Base Styles */
* {
    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;
}

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

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

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

/* Configuration Section */
.config-section {
    margin-bottom: 30px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
}

.input-group input[type="text"] {
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

/* Drop Zone */
.drop-zone {
    border: 3px dashed #cbd5e0;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    transition: all 0.3s;
    background: #f9fafb;
}

.drop-zone.dragging {
    border-color: #667eea;
    background: #eef2ff;
    transform: scale(1.02);
}

.drop-zone.has-images {
    padding: 20px;
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.upload-icon {
    width: 80px;
    height: 80px;
    color: #9ca3af;
    margin-bottom: 20px;
}

.drop-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.drop-subtext {
    color: #6b7280;
    margin-bottom: 20px;
}

.btn-upload, .btn-add-more {
    padding: 12px 32px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-upload:hover, .btn-add-more:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.supported-formats {
    margin-top: 16px;
    font-size: 0.875rem;
    color: #9ca3af;
}

.has-images-prompt {
    display: flex;
    justify-content: center;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 12px 16px;
    background: #f3f4f6;
    border-radius: 8px;
}

.status-bar span {
    font-weight: 600;
    color: #374151;
}

.btn-clear {
    padding: 8px 16px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.btn-clear:hover {
    background: #dc2626;
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.image-card {
    position: relative;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    transition: all 0.2s;
    cursor: move;
}

.image-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.sortable-ghost {
    opacity: 0.4;
}

.drag-handle {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    background: rgba(255,255,255,0.9);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 10;
}

.drag-handle svg {
    width: 16px;
    height: 16px;
    color: #6b7280;
}

.drag-handle:active {
    cursor: grabbing;
}

.thumbnail {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 12px;
}

.image-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.caption-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.875rem;
}

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

.order-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.btn-remove {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}

.btn-generate {
    padding: 16px 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.6);
}

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

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

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

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

.loading-overlay p {
    color: white;
    font-size: 1.25rem;
    margin-top: 20px;
}

/* Footer */
footer {
    text-align: center;
    color: white;
    margin-top: 30px;
    font-size: 0.875rem;
    opacity: 0.8;
}

/* Caption Settings */
.caption-settings {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
}

.radio-label input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
    margin-top: 10px;
}

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

.slider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

/* Drop Hints */
.drop-hint {
    font-size: 0.875rem;
    color: #667eea;
    font-weight: 500;
    margin-top: 8px;
}

.drop-hint-small {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 8px;
}

.has-images-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.thumbnail {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 1;
}

.modal-close:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.modal-image {
    max-width: 100%;
    max-height: calc(90vh - 100px);
    object-fit: contain;
    border-radius: 8px;
}

.modal-filename {
    margin-top: 15px;
    font-weight: 600;
    color: #374151;
    text-align: center;
    word-break: break-word;
}

/* Responsive */
@media (max-width: 768px) {
    .config-section {
        grid-template-columns: 1fr;
    }

    .image-grid {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .container {
        padding: 20px;
    }

    .caption-settings {
        padding: 15px;
    }

    .radio-group {
        flex-direction: column;
        gap: 10px;
    }
}
