/* Layout */
.editor-container {
    margin-top: 2em;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2em;
    align-items: start;
    background: #f5f5f5;
    padding: 1em;
    border-radius: 8px;
    border: 1px solid #eee;
}

/* Preview Container */
.preview-container {
    position: relative;
    aspect-ratio: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3em;  /* Increased from 2em to 3em */
    box-sizing: border-box;
    overflow: hidden;
}

.preview-frame {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-frame.fill-mode {
    cursor: grab;
}

.preview-frame.fill-mode:active {
    cursor: grabbing;
}

.preview-image {
    display: none;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.preview-image[src] {
    display: block;
    /* Add shadow specifically to the image */
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

/* Controls Panel */
.controls-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    height: 100%;
}



/* Add this to create space between controls and download button */
.control-group:last-of-type {
    margin-bottom: auto;
}

/* Create a new wrapper for the controls */
.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.8em;
    flex: 1; 
}

.control-group {
    width: 100%;
    box-sizing: border-box;
    background: white;
    padding: 0.5em;
    border-radius: 4px;
    border: 1px solid #eee;
}

/* Compact Controls */
.compact-controls {
    display: flex;
    align-items: center;
    padding: 0.75em;
    background: white;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}

/* Dimension Controls */
.dimension-control {
    display: flex;
    align-items: center;
    background: #f5f8fa;
    border: 1px solid #e0e6eb;
    border-radius: 4px;
    height: 24px;
}

.size-btn {
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: none;
    color: #4c96b3;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.size-btn:hover {
    background: #e7f3f7;
    border-radius: 3px;
}

.size-btn:active {
    background: #d3e7eb;
}

.size-value {
    min-width: 1em;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: #4a4a4a;
    padding: 0 4px;
}

.size-multiply {
    color: #8a9ba8;
    font-size: 14px;
    margin: 0 0.5em;
    font-weight: 300;
}

/* File Input Control */
.file-control {
    display: flex;
    align-items: center;
    gap: 0.8em;
    padding: 0.5em;
    background: white;
    border-radius: 4px;
    border: 1px solid #eee;
}

.upload-btn {
    flex: 0 0 auto; /* Don't grow, don't shrink, auto base size */
    padding: 0 12px;
    height: 30px;
    border: 1px solid #4c96b3;
    border-radius: 4px;
    color: #4c96b3;
    background-color: #e7f3f7;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.filename {
    flex: 1 1 0;
    color: #666;
    font-size: 12px;
    overflow: hidden;
    white-space: nowrap;
    padding: 0 4px;
    min-width: 0; /* Important for flex text truncation */
}

#imageInput {
    display: none;
}

/* Preprocessing Controls */
.preprocessing-controls {
    display: flex;
    flex-direction: column;
    gap: 0.8em;
    width: 100%;
}

.effect-control {
    display: flex;
    align-items: center;
    gap: 1em;
    width: 100%;
}

.effect-toggle {
    display: flex;
    align-items: center;
    gap: 0.5em;
    min-width: 100px;
}

.effect-toggle input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid #4c96b3;
    background-color: #e7f3f7;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin: 0;
    flex-shrink: 0;
    position: relative;
}

.effect-toggle input[type="checkbox"]:checked {
    background-color: #4c96b3;
}

.effect-toggle input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -65%) rotate(45deg);
}

.effect-toggle span {
    color: #4a4a4a;
    font-size: 12px;
    white-space: nowrap;
}

/* Range Input Styling */
.effect-control input[type="range"] {
    flex: 1;
    height: 4px;
    background: #e7f3f7;
    border: 1px solid #4c96b3;
    border-radius: 2px;
    appearance: none;
}

.effect-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 6px;
    height: 16px;
    background: #4c96b3;
    border: none;
    border-radius: 1px;
    cursor: pointer;
    margin-top: -6px;
}

.effect-control input[type="range"]::-moz-range-thumb {
    width: 6px;
    height: 16px;
    background: #4c96b3;
    border: none;
    border-radius: 1px;
    cursor: pointer;
}

.effect-control input[type="range"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #4a4a4a;
}

/* Common Interactive States */
.size-btn:hover,
.frame-preview-btn:hover,
#imageInput::file-selector-button:hover,
.download-button:hover,
.effect-toggle input[type="checkbox"]:hover {
    background-color: #d3e7eb;
    color: #4d92a3;
}

.size-btn:active,
.frame-preview-btn:active,
.download-button:active {
    background-color: #c1dce1;
    color: #4d92a3;
}

/* Responsive Design */
@media (max-width: 900px) {
    .editor-container {
        grid-template-columns: 1fr;
        gap: 1em;
    }
    
    .controls-panel {
        order: 2;
    }
    
    .preview-container {
        order: 1;
    }
}

.frame-buttons {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5em;
    padding: 0.5em;
    min-width: 0; /* Prevent grid from overflowing in Chrome */
    width: 100%;
    box-sizing: border-box;
}

.frame-btn {
    width: 100%;
    aspect-ratio: 1;
    padding: 2px;
    border: 2px solid transparent;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    min-width: 0; /* Allow button to shrink below content size */
}

.frame-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    filter: brightness(1.2) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
    min-width: 0; /* Allow image to shrink below content size */
}

.frame-btn:hover {
    background-color: #e7f3f7;
}

.frame-btn.active {
    border-color: #4c96b3;
    background-color: #e7f3f7;
}

.frame-btn[data-frame="none"] {
    display: none;
}

/* Add responsive adjustment for smaller screens */
@media (max-width: 600px) {
    .frame-buttons {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(5, 1fr);
    }
}

/* Toggle Group Styles */
.toggle-group {
    display: flex;
    margin-left: auto;
    flex-shrink: 0;
}

.toggle-btn {
    height: 24px;
    padding: 0;
    border: 1px solid #4c96b3;
    background-color: #e7f3f7;
    color: #7a8c97;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(1);
    transform-origin: center;
    margin-right: -1px;
    position: relative;
}

.toggle-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.toggle-btn:last-child {
    border-radius: 0 4px 4px 0;
}

.toggle-btn.active {
    background-color: #3d87a4;
    color: white;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3),
                0 1px 3px rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    z-index: 1;
}

.toggle-btn:hover:not(.active) {
    background-color: #d3e7eb;
}

/* Specific button sizes */
.mode-btn {
    width: 48px;
}

.variation-btn {
    width: 24px;
}

/* Frame Controls Layout */
.frame-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5em;
    padding: 0.5em;
}

/* Frame Toggle */
.frame-toggle {
    margin-bottom: 0;
}

/* Add disabled state for toggle buttons */
.toggle-btn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
    background-color: #f5f5f5;
    border-color: #ccc;
    /* color: #999; */
    pointer-events: none;
}

.toggle-btn:disabled.active {
    background-color: #8ab3c4;
    box-shadow: none;
}

/* Main Button Style */
.main-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    padding: 0 12px;
    border: 1px solid #4c96b3;
    border-radius: 4px;
    color: #4c96b3;
    background-color: #e7f3f7;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
    text-decoration: none;
}

.main-btn:hover {
    background-color: #d3e7eb;
    color: #4d92a3;
}

.main-btn:active {
    background-color: #c1dce1;
    color: #4d92a3;
}


/* Refresh Button */
.refresh-btn {
    padding: 10px;
    margin-right: 10px; 
    height: 24px;
    text-align: start;
}


.refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f5f5f5;
    border-color: #ccc;
    pointer-events: none;
}

/* Update pan indicator styles */
.pan-indicator {
    position: absolute;
    display: none;
    color: #666;
    font-size: 30px;
    pointer-events: none;
    opacity: 0.5;
    text-align: center;
    z-index: 10;  /* Ensure indicators appear above the image */
}

.pan-indicator.vertical {
    left: 0em;  /* Position relative to preview container padding */
    top: 50%;
    transform: translateY(-50%);
}

.pan-indicator.horizontal {
    bottom: 0em;  /* Position relative to preview container padding */
    left: 50%;
    transform: translateX(-50%);
}

/* Only show indicators in fill mode when they're needed */
.preview-frame.fill-mode .pan-indicator {
    display: flex;
}

.pan-indicator span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    position: relative;  /* For tooltip positioning */
}

/* Add tooltip */
.pan-indicator .tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

/* Tool Description */
.tool-description {
    text-align: center;
    color: #666;
    margin-top: 1em;
    font-size: 0.9em;
    line-height: 1.4;
}

.tool-description.emphasis {
    font-weight:400;
    margin: 0;
    color: #4a4a4a;
}

/* Mobile Warning Message */
.mobile-warning {
    display: none;
    text-align: center;
    background: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    padding: 1em;
    border-radius: 4px;
    margin-bottom: 1em;
}

@media (max-width: 900px) {
    .mobile-warning {
        display: block;
    }
}
