:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --radius-lg: 16px;
    --radius-md: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.app-container {
    width: 100%;
    max-width: 800px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
}

/* Upload Section */
.upload-section {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #f8fafc;
}

.upload-section:hover,
.upload-section.drag-over {
    border-color: var(--primary-color);
    background-color: #eff6ff;
}

.icon-placeholder {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-content h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-content p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Image List Section - Floating Bottom */
.image-list-section {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    padding: 1rem 2rem;
    z-index: 1000;
    box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: transform 0.3s ease;
}

/* Adjust body padding to prevent content from being hidden behind the bar */
body {
    padding-bottom: 220px;
    /* Adjust based on bar height */
}

.image-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.image-list-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

.btn-text {
    background: none;
    border: none;
    color: var(--danger-color);
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: underline;
}

.btn-text:hover {
    color: #dc2626;
}

.image-list {
    display: flex;
    /* Horizontal layout */
    overflow-x: auto;
    gap: 1rem;
    padding: 0.5rem;
    width: 100%;
    margin: 0 auto;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.image-list::-webkit-scrollbar {
    height: 8px;
}

.image-list::-webkit-scrollbar-track {
    background: transparent;
}

.image-list::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

.image-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    min-width: 100px;
    /* Fixed width for items */
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    /* Don't shrink */
    background-color: #f1f5f9;
    border: 2px solid transparent;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
}

.image-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.image-item.dragging {
    opacity: 0.5;
    border-color: var(--primary-color);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    /* Prevent image drag interfering with item drag */
}

.delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background-color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--danger-color);
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s;
}

.delete-btn:hover {
    transform: scale(1.1);
    background-color: #fff;
}


/* Controls Section */
.controls-section {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    padding: 1.5rem;
    background-color: #f1f5f9;
    border-radius: var(--radius-md);
    align-items: center;
    justify-content: space-between;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

.direction-toggle {
    display: flex;
    gap: 1rem;
}

.radio-label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

/* Preview Section */
.preview-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.canvas-container {
    width: 100%;
    min-height: 200px;
    background-color: #eeeeee;
    background-image: linear-gradient(45deg, #e0e0e0 25%, transparent 25%), linear-gradient(-45deg, #e0e0e0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e0e0e0 75%), linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    border: 1px solid var(--border-color);
}

canvas {
    max-width: 100%;
    height: auto;
    box-shadow: var(--shadow-sm);
    display: none;
    /* Initially hidden */
}

.empty-state {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-primary:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}