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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
}

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

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

.header p {
    font-size: 1.1em;
    opacity: 0.95;
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8em;
    }

    .header p {
        font-size: 1em;
    }
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 30px;
    margin-bottom: 40px;
}

.section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.section-title {
    font-size: 1.5em;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
    display: flex;
    align-items: center;
}

.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    margin-right: 12px;
    flex-shrink: 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-group input[type="file"],
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="color"],
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.form-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.range-value {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.9em;
    color: #666;
}

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

.radio-item, .checkbox-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-item:hover, .checkbox-item:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.radio-item input, .checkbox-item input {
    margin-right: 10px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

button {
    flex: 1;
    min-width: 140px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: 2px solid #e0e0e0;
}

.btn-secondary:hover:not(:disabled) {
    background: #e8e8e8;
    border-color: #d0d0d0;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-danger {
    background: #ff6b6b;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #ee5a52;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.4);
}

.btn-success {
    background: #51cf66;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #40c057;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(81, 207, 102, 0.4);
}

.preview-container {
    margin-top: 20px;
}

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

.preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    aspect-ratio: 1;
    border: 2px solid #e0e0e0;
    transition: all 0.2s;
}

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

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

.preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255, 107, 107, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

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

.color-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-input-wrapper input[type="color"] {
    width: 50px;
    height: 40px;
    padding: 4px;
    cursor: pointer;
}

.color-input-wrapper input[type="text"] {
    flex: 1;
}

.preview-text {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: white;
    text-align: center;
    word-break: break-word;
    padding: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}

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

.progress-text {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

.status-message {
    padding: 12px 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-weight: 500;
    display: none;
}

.status-message.show {
    display: block;
}

.status-message.success {
    background: #d3f9d8;
    color: #2f7d32;
    border: 2px solid #51cf66;
}

.status-message.error {
    background: #ffe0e0;
    color: #c41e3a;
    border: 2px solid #ff6b6b;
}

.status-message.info {
    background: #e7f5ff;
    color: #1971c2;
    border: 2px solid #74c0fc;
}

.two-column-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.result-container {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.result-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    aspect-ratio: 1;
    border: 2px solid #e0e0e0;
    transition: all 0.2s;
}

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

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

.result-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.result-item:hover .result-actions {
    opacity: 1;
}

.result-actions button {
    flex: 1;
    padding: 6px 10px;
    font-size: 0.9em;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

.hidden {
    display: none;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }

    .preview-column {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .hidden-mobile {
        display: none !important;
    }

    .two-column-section {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .section {
        padding: 20px;
    }

    .button-group {
        gap: 8px;
    }

    button {
        font-size: 0.95em;
        padding: 10px 15px;
    }

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

    .result-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

.divider {
    height: 1px;
    background: #e0e0e0;
    margin: 20px 0;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    border: 3px dashed #667eea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9ff;
}

.file-input-label:hover {
    background: #f0f2ff;
    border-color: #764ba2;
}

.file-input-label input {
    display: none;
}

.file-input-text {
    text-align: center;
}

.file-input-text .main-text {
    font-weight: 600;
    color: #333;
    font-size: 1em;
}

.file-input-text .sub-text {
    color: #666;
    font-size: 0.9em;
    margin-top: 4px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-button {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.download-all-section {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

/* Column definitions for layout */
.left-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.preview-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.right-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
