:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
}

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

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

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

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

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

/* Format Section */
.formats-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.format-inputs {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.format-inputs input {
    width: 100px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.saved-formats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.format-tag {
    background: var(--background);
    padding: 0.5rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.format-tag button {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
}

/* Format Previews */
.format-previews {
    background: var(--background);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.format-previews h3 {
    margin-bottom: 1rem;
    color: var(--text-light);
    font-size: 0.875rem;
    position: sticky;
    top: 0;
    background: var(--background);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

#format-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
}

.format-preview {
    position: relative;
    margin: 5px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.format-preview:hover {
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

.format-preview.selected {
    border-color: #007bff;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.5);
    background-color: rgba(0, 123, 255, 0.05);
}

.format-preview-image {
    width: 100%;
    height: 90px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 3px;
}

.format-preview-info {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
    background: var(--background);
    padding: 0.25rem 0.5rem;
    border-radius: calc(var(--radius) - 2px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.format-preview:hover {
    transform: scale(1.02);
}

.format-preview.active {
    border: 2px solid var(--primary-color);
}

/* Format Selector */
.format-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.format-selector label {
    font-size: 0.875rem;
    color: var(--text-light);
}

.format-selector select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
}

.crop-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.navigation-controls {
    display: flex;
    gap: 0.5rem;
}

/* Upload Section */
.upload-container {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-container:hover {
    border-color: var(--primary-color);
}

.upload-container.dragover {
    border-color: var(--primary-color);
    background: var(--background);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
}

/* Preview Section */
.preview-container {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1.5rem;
    min-height: 600px;
}

.image-list {
    border-right: 1px solid var(--border);
    padding-right: 1rem;
    overflow-y: auto;
    max-height: 600px;
}

#image-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: var(--radius);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.thumbnail:hover {
    transform: scale(1.02);
}

.thumbnail.active {
    border-color: var(--primary-color);
    transform: scale(1.02);
}

.crop-preview {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.crop-container {
    flex: 1;
    min-height: 500px;
    background: #f1f5f9;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.crop-container img {
    max-width: 100%;
    max-height: 100%;
}

/* Cropper.js Customization */
.cropper-view-box,
.cropper-face {
    border-radius: var(--radius);
}

.cropper-modal {
    background-color: rgba(0, 0, 0, 0.85);
}

.cropper-line,
.cropper-point {
    background-color: var(--primary-color);
}

.cropper-view-box {
    outline: 2px solid var(--primary-color);
    outline-color: var(--primary-color);
}

.cropper-point {
    width: 10px;
    height: 10px;
    opacity: 1;
}

.cropper-point.point-n,
.cropper-point.point-s,
.cropper-point.point-e,
.cropper-point.point-w {
    width: 12px;
    height: 12px;
}

/* Progress Overlay */
.progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    width: 90%;
    max-width: 400px;
}

.progress-bar {
    height: 8px;
    background: var(--background);
    border-radius: 4px;
    margin: 1rem 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.2s;
}

/* Output Format Selector */
.format-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.format-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.output-format {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.output-format label {
    color: var(--text-light);
    font-size: 0.875rem;
}

.output-format select {
    padding: 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.output-format select:hover {
    border-color: var(--primary-color);
}

.output-format select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color-light);
}

/* Output Controls */
.output-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.max-size-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.max-size-control label {
    color: var(--text-light);
    font-size: 0.875rem;
}

.max-size-control input {
    width: 100px;
    padding: 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.max-size-control input:hover {
    border-color: var(--primary-color);
}

.max-size-control input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color-light);
}

/* Responsive Design */
@media (max-width: 768px) {
    .format-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .output-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .preview-container {
        grid-template-columns: 1fr;
    }

    .image-list {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding-right: 0;
        padding-bottom: 1rem;
    }

    #image-thumbnails {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        max-height: 200px;
    }
}
