/* SVG Editor specific styles */

.svg-editor-container {
    display: grid;
    grid-template-columns: 280px 1fr; /* Controls on left, editor on right */
    gap: 30px;
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    min-height: 700px; /* Ensure enough height */
}

@media (max-width: 992px) {
    .svg-editor-container {
        grid-template-columns: 1fr; /* Stack on smaller screens */
    }
    .editor-controls {
        order: 2; /* Move controls below canvas on small screens */
    }
    .editor-main {
        order: 1; /* Move canvas above controls on small screens */
    }
}

.editor-controls {
    display: flex;
    flex-direction: column;
    gap: 25px; /* Spacing between control sections */
    border-right: 1px solid #eee; /* Separator for desktop */
    padding-right: 25px;
}

@media (max-width: 992px) {
    .editor-controls {
        border-right: none;
        border-top: 1px solid #eee; /* Separator for mobile */
        padding-right: 0;
        padding-top: 25px;
    }
}

.control-group {
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.control-group:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.control-section-title {
    font-size: 1.2em;
    color: #007bff; /* Primary color */
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.button-group .btn {
    flex-grow: 1;
    min-width: 120px;
}

.button-group .btn.active {
    background-color: #0056b3; /* Darker blue for active state */
    border-color: #0056b3;
    cursor: default;
}

.button-group .btn.active:hover {
    background-color: #0056b3; /* Keep dark on hover for active */
}

.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.form-control,
.jscolor { /* jscolor input will also inherit form-control styles */
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.95rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    box-sizing: border-box;
}

.form-control:focus,
.jscolor:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

/* Editor Main Section */
.editor-main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.svg-canvas-wrapper {
    position: relative;
    width: 100%;
    /* Keep aspect ratio (e.g., 4:3) or set a fixed height for visual consistency */
    padding-bottom: 66.66%; /* For 3:2 aspect ratio (400/600) */
    background-color: #f8f8f8;
    border: 1px solid #ccc;
    border-radius: 8px;
    overflow: hidden; /* Hide scrollbars if content overflows due to pan/zoom */
    box-shadow: inset 0 0 5px rgba(0,0,0,0.1);
}

#svgCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff; /* Actual SVG background */
    touch-action: none; /* Prevent browser default touch actions like pan/zoom */
    /* Add a subtle grid pattern with CSS if desired */
    /* background-image: linear-gradient(to right, #eee 1px, transparent 1px), linear-gradient(to bottom, #eee 1px, transparent 1px); */
    /* background-size: 20px 20px; */
}

#svgCanvas.drawing {
    cursor: crosshair;
}
#svgCanvas.moving {
    cursor: grabbing;
}
#svgCanvas.resizing-handle {
    cursor: nwse-resize; /* Diagonal resize for corners */
}
#svgCanvas.resizing-handle[data-direction="n"], #svgCanvas.resizing-handle[data-direction="s"] {
    cursor: ns-resize;
}
#svgCanvas.resizing-handle[data-direction="e"], #svgCanvas.resizing-handle[data-direction="w"] {
    cursor: ew-resize;
}
#svgCanvas.select {
    cursor: default;
}


/* SVG Elements Styling (inside the SVG) */
#svgCanvas rect,
#svgCanvas circle,
#svgCanvas ellipse {
    cursor: grab;
    transition: all 0.1s ease-out; /* Smooth transition for property changes */
    user-select: none; /* Prevent text selection issues */
}

#svgCanvas .selected-shape {
    outline: 2px dashed #007bff; /* Visual indicator for selected shape */
    outline-offset: 5px;
}

#svgCanvas .resize-handle {
    fill: #007bff;
    stroke: #fff;
    stroke-width: 1;
    cursor: nwse-resize; /* Default resize handle cursor */
    pointer-events: all; /* Ensure handles are clickable */
}

/* Output Area */
.output-field-wrapper {
    position: relative;
    margin-top: 15px;
}

.output-field {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 15px;
    border-radius: 5px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.9em;
    color: #333;
    white-space: pre-wrap; /* Ensures text wraps and preserves whitespace */
    word-break: break-all; /* Breaks words to prevent overflow */
    min-height: 150px;
    overflow-y: auto;
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 8px 12px;
    font-size: 0.85em;
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

.copy-btn:hover {
    opacity: 1;
}

/* Hide Jscolor's default input when using it as a button */
.jscolor {
    background-image: none !important;
    background-color: #fff !important; /* Force white background for color input */
    text-align: center;
    text-transform: uppercase;
    font-weight: bold;
}