/* Pixel Explorer - Image Pixel Inspection Tool */

.tool-form.pixel-explorer {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

/* Upload Section */
.upload-section {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    border: 2px dashed #d0d7de;
    border-radius: 8px;
    background: #f6f8fa;
    transition: all 0.2s ease;
}

.upload-section:hover {
    border-color: #4a90e2;
    background: #f0f7ff;
}

.upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 2rem;
    background: #4a90e2;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-label:hover {
    background: #3a7bc8;
    transform: translateY(-2px);
}

.upload-label i {
    font-size: 2rem;
}

#image-upload {
    display: none;
}

.upload-info {
    font-size: 0.9rem;
    color: #666;
}

/* Workspace Section */
.workspace-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.image-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.image-viewer {
    position: relative;
    overflow: auto;
    max-height: 500px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#main-canvas {
    display: block;
    max-width: 100%;
    cursor: crosshair;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.selection-box {
    position: absolute;
    width: 50px;
    height: 50px;
    border: 2px solid #ff5722;
    background: rgba(255, 87, 34, 0.2);
    pointer-events: none;
    display: none;
}

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

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zoom-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background: #f0f0f0;
    color: #333;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    background: #e0e0e0;
}

.zoom-level {
    min-width: 50px;
    text-align: center;
    font-weight: 600;
}

.grid-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

/* Pixel Info Section */
.pixel-info-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.pixel-viewer {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f0f0f0;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pixel-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.pixel-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none;
}

.crosshair-h, .crosshair-v {
    position: absolute;
    background: rgba(255, 0, 0, 0.5);
    pointer-events: none;
}

.crosshair-h {
    height: 1px;
    width: 100%;
    left: 0;
}

.crosshair-v {
    width: 1px;
    height: 100%;
    top: 0;
}

.pixel-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pixel-details h3 {
    margin: 0;
    color: #333;
}

.pixel-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: #f0f0f0;
    border-radius: 6px;
}

.info-label {
    font-weight: 600;
    color: #555;
}

.info-value {
    font-family: monospace;
    color: #333;
}

.zoom-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.zoom-controls label {
    font-weight: 600;
    color: #555;
}

#pixel-zoom-slider {
    width: 100%;
}

.zoom-value {
    text-align: center;
    font-weight: 600;
}

.color-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f0f0f0;
    border-radius: 6px;
}

.color-box {
    width: 40px;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Image Info */
.image-info {
    padding: 1rem;
    background: #f0f0f0;
    border-radius: 8px;
}

.image-info h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #333;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .tool-form.pixel-explorer {
        padding: 1rem;
    }
    
    .pixel-info-section {
        grid-template-columns: 1fr;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .zoom-controls {
        justify-content: center;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

/* Grid Overlay Styles */
.grid-overlay-enabled .pixel-grid-overlay {
    display: block;
    background-image: 
        linear-gradient(to right, #ddd 1px, transparent 1px),
        linear-gradient(to bottom, #ddd 1px, transparent 1px);
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: #666;
}

.loading::after {
    content: "";
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 2px solid #ddd;
    border-top: 2px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}