:root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --primary-color: #bb86fc;
    --secondary-color: #03dac6;
    --text-color: #e0e0e0;
    --border-color: #333;
    --danger-color: #cf6679;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin-top: 2rem;
    padding: 2rem;
    background-color: var(--surface-color);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.upload-area {
    border: 2px dashed var(--border-color);
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s ease;
    border-radius: 8px;
    margin-bottom: 2rem;
}

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

.editor-container {
    display: none;
    flex-direction: column;
    gap: 2rem;
}

.editor-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
}

.image-container {
    flex: 2;
    min-width: 300px;
    background-color: #000;
    border-radius: 4px;
    overflow: hidden;
    max-height: 600px;
}

.image-container img {
    max-width: 100%;
    display: block; /* This rule is very important, please do not ignore this */
}

.controls {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.control-group {
    background-color: #2c2c2c;
    padding: 1rem;
    border-radius: 4px;
}

.control-group h3 {
    margin-top: 0;
    font-size: 1rem;
    color: var(--secondary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

input[type="number"], select {
    width: 100%;
    padding: 0.5rem;
    background-color: #333;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 4px;
    box-sizing: border-box;
}

button {
    background-color: var(--primary-color);
    color: #000;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: opacity 0.2s;
    width: 100%;
    margin-top: 0.5rem;
}

button:hover {
    opacity: 0.9;
}

button.secondary {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.aspect-ratios {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.aspect-ratios button {
    width: auto;
    padding: 0.5rem;
    font-size: 0.8rem;
    margin-top: 0;
}

.result-area {
    margin-top: 2rem;
    text-align: center;
    display: none;
}

.result-area img {
    max-width: 100%;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
}

.download-link {
    display: inline-block;
    margin-top: 1rem;
    background-color: var(--secondary-color);
    color: #000;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-weight: bold;
}

/* Cropper.js override for dark theme compatibility */
.cropper-view-box,
.cropper-face {
    border-radius: 0;
}

/* Gallery Styles */
.gallery-section {
    margin-top: 4rem;
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
    width: 100%;
}

.gallery-section h2 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.gallery-item {
    background-color: #2c2c2c;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-color);
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    border-color: var(--primary-color);
}

.gallery-thumb {
    width: 100%;
    height: 150px;
    object-fit: cover;
    background-color: #000;
    cursor: pointer;
}

.gallery-info {
    padding: 1rem;
    font-size: 0.85rem;
}

.gallery-info p {
    margin: 0.3rem 0;
    color: #bbb;
}

.gallery-info .dim {
    color: var(--secondary-color);
    font-weight: bold;
}

.gallery-actions {
    padding: 0 1rem 1rem;
    display: flex;
    justify-content: space-between;
}

.gallery-actions a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.8rem;
}

.gallery-actions a:hover {
    text-decoration: underline;
}
