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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 1800px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.header-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.logo-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: transform 0.3s ease;
    border-radius: 8px;
}

.logo-link:hover {
    transform: scale(1.05);
}

.logo-link:hover .header-logo {
    filter: drop-shadow(0 4px 8px rgba(102, 126, 234, 0.3));
}

.version {
    font-size: 1rem;
    font-weight: 500;
    color: #8a8a8a;
    background: none;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: initial;
    background-clip: initial;
    margin-left: 10px;
}

.upload-section {
    margin-bottom: 30px;
}

.upload-label {
    cursor: pointer;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 60px;
    text-align: center;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-area svg {
    color: #667eea;
    margin-bottom: 15px;
}

.upload-area p {
    color: #666;
    font-size: 1.1rem;
}

.preview-section {
    animation: fadeIn 0.3s ease;
}

/* Image Carousel Sidebar */
.image-carousel {
    width: 320px;
    min-width: 320px;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    position: sticky;
    top: 20px;
}

.carousel-header {
    margin-bottom: 15px;
    text-align: center;
}

.carousel-header h4 {
    color: #333;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.carousel-counter {
    color: #666;
    font-size: 0.85rem;
}

.carousel-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.carousel-thumbnail {
    width: 100%;
    aspect-ratio: 4/5;
    border-radius: 10px;
    background: white;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-thumbnail:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.carousel-thumbnail.active {
    border-color: #667eea;
    background: #f0f4ff;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.carousel-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.carousel-thumbnail .thumbnail-index {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.carousel-thumbnail .export-status {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #28a745;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.carousel-thumbnail.exported .export-status {
    opacity: 1;
}

.carousel-thumbnail.exported .export-status::after {
    content: '✓';
    color: white;
    font-size: 10px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.previews-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.preview-item {
    text-align: center;
}

.preview-item h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1rem;
    font-weight: 600;
}

.preview-item .canvas-container {
    margin-bottom: 15px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Canvas container animation enhancements */
.canvas-container.animate__animated {
    animation-duration: 0.5s;
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.canvas-container.animate__fadeIn {
    animation-duration: 0.5s;
}

/* Smooth transition for canvas elements */
.canvas-container {
    background: #f5f5f5;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 320px;
    max-height: calc(80vh - 160px);
    overflow: hidden;
    position: relative;
    transition: transform 0.1s ease;
}

.canvas-container::after {
    content: '🎨 Click or drag to sample colors';
    position: absolute;
    bottom: 10px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.canvas-container:hover::after {
    opacity: 1;
}

#preview-canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: block;
}

.controls {
    display: grid;
    gap: 15px;
    position: sticky;
    top: 20px;
}

.compact-controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.control-group.compact {
    flex: 1;
    min-width: 200px;
}

.control-group.compact select,
.control-group.compact input[type="text"] {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.control-group.compact label {
    font-weight: 600;
    color: #333;
    min-width: 60px;
    font-size: 0.9rem;
}

.control-group label {
    font-weight: 600;
    color: #333;
    min-width: 140px;
    font-size: 0.95rem;
}

.control-group input[type="text"],
.control-group select {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

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

.control-group select:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    opacity: 0.7;
}

.control-group input[type="color"] {
    width: 60px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.control-group input[type="range"] {
    flex: 1;
}

.button-group {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.primary-btn,
.secondary-btn {
    flex: 1;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.primary-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.primary-btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

.secondary-btn {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.secondary-btn:hover {
    background: #f0f4ff;
}

.border-color-group {
    flex-direction: column;
    align-items: flex-start;
}

.color-controls {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    width: 100%;
}

.color-suggestions {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    display: none; /* Hidden by default */
}

.suggestions-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.color-swatches {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid #e0e0e0;
    transition: all 0.2s ease;
    position: relative;
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.color-swatch.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

.color-swatch::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.color-swatch:hover::after {
    opacity: 1;
}

/* Color Picker Magnifier */
.color-magnifier {
    position: fixed;
    width: 120px;
    height: 120px;
    border: 3px solid #667eea;
    border-radius: 50%;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

.color-magnifier.visible {
    opacity: 1;
    transform: scale(1);
}

#magnifier-canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.magnifier-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 2px;
    background: #667eea;
    border: 1px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.5);
}

.magnifier-info {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    display: flex;
    gap: 8px;
}

.magnifier-info span {
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 1600px) {
    .container {
        max-width: 1400px;
    }
}

@media (max-width: 1200px) {
    .container {
        max-width: 1100px;
    }
    
    .previews-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .image-carousel {
        width: 280px;
        min-width: 280px;
    }
}

@media (max-width: 900px) {
    .app-layout {
        flex-direction: column;
    }
    
    .image-carousel {
        width: 100%;
        max-height: 180px;
        padding: 15px;
        position: static;
        order: 1;
    }
    
    .carousel-thumbnails {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 10px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    
    .carousel-thumbnail {
        min-width: 144px;
        width: 144px;
        scroll-snap-align: start;
    }
    
    .main-content {
        order: 2;
    }
    
    .upload-section {
        order: 0;
    }
    
    .preview-section {
        order: 3;
    }
    
    .controls {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .compact-controls {
        grid-template-columns: 1fr;
    }

    .control-group.compact {
        margin-bottom: 15px;
    }

    .control-group.compact select,
    .control-group.compact input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .compact-controls {
        flex-direction: column;
    }
    
    .control-group.compact {
        min-width: auto;
    }
    
    .control-group.compact select,
    .control-group.compact input[type="text"] {
        max-width: none;
    }
    
    .control-group {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .control-group label {
        min-width: auto;
    }
    
    .button-group {
        flex-direction: column;
    }
}

/* Aspect ratio warning */
.aspect-ratio-warning {
    background: #fff3cd;
    border: 1px solid #ffeb3b;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #856404;
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
}

.aspect-ratio-warning svg {
    flex-shrink: 0;
    color: #ff9800;
}

/* Interaction mode toggle */
.interaction-mode-toggle {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #666;
}

.mode-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.mode-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.mode-btn svg {
    width: 16px;
    height: 16px;
}

/* Visual separator after color picker button */
#color-mode-btn::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 24px;
    background-color: #ddd;
    z-index: 1;
}

#color-mode-btn {
    position: relative;
    margin-right: 12px;
}

#position-mode-btn {
    margin-left: 0;
}

/* Auto frame button */
.auto-frame-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid #28a745;
    background: white;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #28a745;
}

.auto-frame-btn:hover {
    background: #28a745;
    color: white;
}

.auto-frame-btn svg {
    width: 16px;
    height: 16px;
}

/* Export disabled message */
.export-disabled-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 14px 16px 18px 16px;
    margin: 0px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #721c24;
    font-size: 0.9rem;
    line-height: 1.3;
    animation: fadeIn 0.3s ease;
    min-height: 24px;
}

.export-disabled-message svg {
    flex-shrink: 0;
    color: #dc3545;
    vertical-align: middle;
}

/* Update canvas container for positioning mode */
.canvas-container.position-mode {
    cursor: move;
}

.canvas-container.position-mode::after {
    content: '✋ Drag to reposition image';
}

/* Fit height button */
.fit-height-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid #17a2b8;
    background: white;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #17a2b8;
}

.fit-height-btn:hover {
    background: #17a2b8;
    color: white;
}

.fit-height-btn svg {
    width: 16px;
    height: 16px;
}

/* Image progress indicator */
.image-progress {
    text-align: center;
    margin-top: 15px;
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.image-progress span {
    color: #667eea;
    font-weight: 600;
}

/* Export Warning Modal */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-backdrop.show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.7);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.modal-backdrop.show .modal-content {
    transform: scale(1);
    opacity: 1;
}

.modal-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.modal-icon svg {
    color: #ff9800;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.modal-title {
    text-align: center;
    color: #333;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-message {
    text-align: center;
    color: #666;
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 32px;
}

.modal-checkbox-container {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.modal-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #666;
    user-select: none;
}

.modal-checkbox {
    display: none;
}

.modal-checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 4px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.modal-checkbox:checked + .modal-checkbox-custom {
    background: #667eea;
    border-color: #667eea;
}

.modal-checkbox:checked + .modal-checkbox-custom::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 6px;
    height: 10px;
    border: 2px solid white;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

.modal-checkbox-label:hover .modal-checkbox-custom {
    border-color: #667eea;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

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

.modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.modal-btn-secondary {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #e0e0e0;
}

.modal-btn-secondary:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* Responsive modal */
@media (max-width: 600px) {
    .modal-content {
        padding: 24px;
        width: 95%;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-btn {
        width: 100%;
    }
}

/* App Layout */
.app-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.main-content {
    flex: 1;
    min-width: 0; /* Prevents flex item from overflowing */
}
