/*
Plugin CSS for Simple Tile Visualizer (stv)

This stylesheet provides the styling for the plugin's interface,
including the layout, buttons, sliders, and canvas area.
It's designed to be clean, user-friendly, and responsive.
*/

.stv-visualizer-container {
    max-width: 900px; /* Max width of the main container */
    margin: 20px auto; /* Center the container with some top/bottom margin */
    padding: 20px;
    background-color: #fff;
    border-radius: 8px; /* Rounded corners for the container */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
    font-family: 'Inter', sans-serif; /* Consistent font */
    color: #333;
}

.stv-title {
    text-align: center;
    color: #2c3e50; /* Dark blue/grey for heading */
    margin-bottom: 25px;
    font-size: 2.2em; /* Larger font size */
    font-weight: 700; /* Bold */
    border-bottom: 2px solid #e0e0e0; /* Separator line */
    padding-bottom: 10px;
}

.stv-controls {
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap; /* Allows wrapping on smaller screens */
    gap: 20px; /* Space between control sections */
    justify-content: space-between;
    align-items: flex-end; /* Align controls to the bottom if they have different heights */
}

/* Flex items for control sections */
.stv-upload-section,
.stv-adjustments,
.stv-actions {
    flex: 1; /* Allows sections to grow and shrink */
    min-width: 280px; /* Minimum width before stacking */
}

.stv-upload-group,
.stv-slider-group {
    margin-bottom: 15px; /* Space between individual control groups */
}

.stv-label {
    display: block; /* Make label take full width */
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

/* Styling for WordPress standard buttons used as upload triggers */
.stv-upload-button.button {
    background-color: #0073aa; /* WordPress primary blue */
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-weight: 500;
}

.stv-upload-button.button:hover {
    background-color: #005177; /* Darker blue on hover */
}

.stv-file-name {
    margin-left: 10px;
    font-style: italic;
    color: #666;
    font-size: 0.9em;
}

.stv-slider-group {
    display: flex; /* Flex layout for slider and value span */
    align-items: center;
    gap: 10px;
}

/* Basic styling for range input (slider) */
.stv-slider-group input[type="range"] {
    flex-grow: 1; /* Slider takes available space */
    -webkit-appearance: none; /* Remove default WebKit styling */
    appearance: none;
    height: 8px;
    background: #ddd; /* Track color */
    border-radius: 5px;
    outline: none;
    opacity: 0.9;
    transition: opacity .2s;
}

/* Styling for slider thumb (handle) - WebKit (Chrome, Safari) */
.stv-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%; /* Circular thumb */
    background: #0073aa;
    cursor: grab; /* Grab cursor indicates draggable */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Styling for slider thumb (handle) - Mozilla (Firefox) */
.stv-slider-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0073aa;
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Cursor change when dragging slider thumb */
.stv-slider-group input[type="range"]:active::-webkit-slider-thumb {
    cursor: grabbing;
}
.stv-slider-group input[type="range"]:active::-moz-range-thumb {
    cursor: grabbing;
}

/* Fixed width for slider value display for alignment */
#stv-tile-scale-value,
#stv-tile-opacity-value {
    font-weight: bold;
    color: #0073aa;
    width: 45px;
    text-align: right;
}

.stv-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end; /* Align buttons to the right */
}

/* General button styling for actions */
.stv-actions .button {
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Specific styling for "Define Tile Area" button */
.stv-actions .button-primary {
    background-color: #28a745; /* Green */
    color: #fff;
    border: none;
}
.stv-actions .button-primary:hover {
    background-color: #218838; /* Darker green on hover */
    transform: translateY(-1px); /* Slight lift effect */
}

/* Specific styling for "Apply Tiles" button */
#stv-apply-tiles.button {
    background-color: #007bff; /* Bootstrap primary blue */
    color: #fff;
    border: none;
}
#stv-apply-tiles.button:hover:not(:disabled) {
    background-color: #0069d9; /* Darker blue on hover */
    transform: translateY(-1px);
}
#stv-apply-tiles.button:disabled {
    background-color: #cccccc; /* Grey when disabled */
    cursor: not-allowed;
    box-shadow: none;
}

/* Specific styling for "Clear" button */
.stv-clear-button.button {
    background-color: #dc3545; /* Bootstrap danger red */
    color: #fff;
    border: none;
}
.stv-clear-button.button:hover {
    background-color: #c82333; /* Darker red on hover */
    transform: translateY(-1px);
}

.stv-canvas-area {
    position: relative; /* Essential for positioning canvas and guide */
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio (height is 56.25% of width) */
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden; /* Hide overflow from canvas */
    margin-bottom: 25px;
}

.stv-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    background-size: contain; /* Ensure room image fits without stretching */
    background-repeat: no-repeat;
    background-position: center;
}

/* Overlay for drawing guide */
#stv-drawing-guide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4); /* Semi-transparent dark overlay */
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    font-weight: 700;
    cursor: crosshair; /* Crosshair cursor for drawing */
    z-index: 10; /* Ensure it's above the canvas */
}

.stv-message {
    text-align: center;
    color: #d33; /* Red for error/status messages */
    font-weight: 500;
    margin-top: 10px;
    min-height: 20px; /* Prevents layout shift when message appears/disappears */
}

.stv-instructions {
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.stv-instructions h3 {
    font-size: 1.5em;
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: center;
}

.stv-instructions ol {
    padding-left: 25px;
    list-style-type: decimal;
}

.stv-instructions li {
    margin-bottom: 8px;
    line-height: 1.5;
    color: #666;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .stv-controls {
        flex-direction: column; /* Stack control sections vertically */
        align-items: stretch; /* Make items fill available width */
    }
    .stv-upload-section,
    .stv-adjustments,
    .stv-actions {
        min-width: unset; /* Remove min-width constraint */
    }
    .stv-actions {
        flex-direction: column; /* Stack action buttons vertically */
    }
    /* Make buttons full width on small screens */
    .stv-upload-button.button,
    .stv-actions .button {
        width: 100%;
        text-align: center;
    }
}
