/* Headstone Configurator - Frontend Styles */

.hsc-configurator-wrapper {
    width: 100%;
    margin: 0;
    padding: 20px;
}

.hsc-configurator-container {
    display: grid;
    grid-template-columns: 600px 1fr;
    gap: 30px;
    align-items: start;
}

/* Preview Panel */
.hsc-preview-panel {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.hsc-preview-panel h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.3em;
}

.hsc-preview-display {
    background: #f8f9fa;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    aspect-ratio: 1/1;
    width: 100%;
}

/* Monument Preview */
.monument-preview {
    width: 100%;
    height: 100%;
    aspect-ratio: 1/1;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    overflow: visible; /* v3.0: Must be visible so drag controls aren't clipped */
}

/* Monument Image Container */
.monument-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    position: relative;
    z-index: 1;               /* v3.0: Below overlays */
    pointer-events: none;      /* v3.0: Let clicks pass through to overlays */
    border-radius: 8px;
    overflow: hidden;          /* v3.0: Clip image here instead of on parent */
}

.monument-image-container img {
    max-width: 90%;
    max-height: 90%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    pointer-events: none;     /* v3.0: Images don't intercept drag events */
}

.monument-placeholder {
    color: #6c757d;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

/* Remove monument type aspect ratio overrides - all square now */
.monument-preview.flat,
.monument-preview.upright,
.monument-preview.companion,
.monument-preview.angel {
    aspect-ratio: 1/1;
}

/* Material colors */
.monument-preview.gray-granite {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.monument-preview.black-granite {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
}

.monument-preview.pink-granite {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
}

.monument-preview.white-marble {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.monument-preview.bronze {
    background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
}

/* Auto-center text for specific monument types */
.monument-preview.flat .preview-area-overlay,
.monument-preview.upright .preview-area-overlay,
.monument-preview.slant .preview-area-overlay,
.monument-preview.angel .preview-area-overlay,
.monument-preview.heart .preview-area-overlay {
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.monument-content {
    width: 100%;
    padding: 15px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    position: relative;
    flex-shrink: 0;
}

.engraving-area {
    text-align: center;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.preview-text {
    margin: 3px 0;
}

.name-text {
    font-size: 1em;
    font-weight: bold;
}

.dates-text {
    font-size: 0.8em;
    opacity: 0.9;
}

.epitaph-text {
    font-size: 0.75em;
    font-style: italic;
    margin-top: 8px;
    opacity: 0.85;
    text-align: center; /* v2.0.1: Auto-center epitaph */
}

/* v2.0.1: Ensure epitaph is centered in preview overlays */
.preview-area-overlay .epitaph-text,
.preview-area-overlay [data-field="epitaph"] {
    text-align: center;
}

/* Price Summary */
.hsc-price-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.hsc-price-summary h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #2c3e50;
}

.price-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.price-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95em;
    color: #555;
}

.price-row.total {
    border-top: 2px solid #ddd;
    padding-top: 8px;
    margin-top: 8px;
    font-size: 1.1em;
    color: #2c3e50;
}

/* Add to Cart Button */
.hsc-btn-primary {
    width: 100%;
    padding: 15px;
    background: #2c3e50;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s ease;
}

.hsc-btn-primary:hover:not(:disabled) {
    background: #1a252f;
}

.hsc-btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Version 2.0: Submit buttons wrapper */
.submit-buttons-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.submit-buttons-wrapper .hsc-btn {
    width: 100%;
    max-width: 400px;
}

.submit-buttons-wrapper .hsc-btn.success {
    background: #0a9;
}

.submit-buttons-wrapper .hsc-btn.success:hover {
    background: #088;
}

.submit-buttons-wrapper .hsc-btn-secondary {
    background: #666;
    width: auto;
    padding: 10px 20px;
    font-size: 0.95em;
}

.submit-buttons-wrapper .hsc-btn-secondary:hover {
    background: #555;
}

.preview-hint {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
    text-align: center;
}

/* Message */
.hsc-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
}

.hsc-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.hsc-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Configuration Panel */
.hsc-config-panel {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 30px;
}

.hsc-config-panel > h2 {
    margin-top: 0;
    color: #2c3e50;
    border-bottom: 2px solid #2c3e50;
    padding-bottom: 10px;
    margin-bottom: 30px;
}

.hsc-config-section {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid #eee;
}

.hsc-config-section:last-child {
    border-bottom: none;
}

.hsc-config-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
}

/* Monument Grid */
.monument-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.monument-card {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.monument-card:hover {
    border-color: #2c3e50;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.monument-card.selected {
    border-color: #2c3e50;
    background: #f8f9fa;
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.2);
}

.monument-image {
    width: 100%;
    height: 150px;
    background-size: cover;
    background-position: center;
    border-radius: 6px;
    margin-bottom: 10px;
    background-color: #f0f0f0;
}

.monument-card h4 {
    margin: 10px 0 5px 0;
    color: #2c3e50;
    font-size: 1.1em;
}

.monument-type {
    color: #777;
    font-size: 0.9em;
    margin: 5px 0;
}

.monument-price {
    color: #2c3e50;
    font-weight: bold;
    margin: 10px 0;
}

.hsc-btn-select {
    padding: 8px 20px;
    background: #2c3e50;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.hsc-btn-select:hover {
    background: #1a252f;
}

/* Material Options */
.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.material-option {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.material-option:hover {
    border-color: #2c3e50;
    transform: translateY(-2px);
}

.material-option.selected {
    border-color: #2c3e50;
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.2);
}

.material-swatch {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.material-swatch.gray-granite {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.material-swatch.black-granite {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
}

.material-swatch.pink-granite {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
}

.material-swatch.white-marble {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.material-swatch.bronze {
    background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
}

/* Size Options */
.option-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.size-option {
    display: flex;
    align-items: center;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.size-option:hover {
    border-color: #2c3e50;
    background: #f8f9fa;
}

.size-option input[type="radio"] {
    margin-right: 15px;
}

.size-option input[type="radio"]:checked ~ .size-details {
    color: #2c3e50;
    font-weight: 600;
}

.size-details {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.size-name {
    font-weight: 600;
    min-width: 100px;
}

.size-dimensions {
    color: #777;
    flex: 1;
}

.size-price {
    font-weight: bold;
    color: #2c3e50;
    font-size: 1.1em;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.hsc-input,
.hsc-textarea,
.hsc-select,
.hsc-file-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.hsc-input:focus,
.hsc-textarea:focus,
.hsc-select:focus {
    outline: none;
    border-color: #2c3e50;
}

.hsc-textarea {
    resize: vertical;
    font-family: inherit;
}

small {
    display: block;
    margin-top: 5px;
    color: #777;
    font-size: 0.9em;
}

/* Radio Groups */
.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.radio-group label:hover {
    border-color: #2c3e50;
    background: #f8f9fa;
}

.radio-group input[type="radio"]:checked + span {
    font-weight: 600;
    color: #2c3e50;
}

/* Preset Images */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.preset-image {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-image:hover {
    border-color: #2c3e50;
    transform: translateY(-2px);
}

.preset-image.selected {
    border-color: #2c3e50;
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.2);
}

.preset-icon {
    font-size: 2.5em;
    margin-bottom: 8px;
}

/* Add-ons */
.addon-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.addon-item {
    display: flex;
    align-items: center;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.addon-item:hover {
    border-color: #2c3e50;
    background: #f8f9fa;
}

.addon-item input[type="checkbox"] {
    margin-right: 15px;
}

.addon-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
}

.addon-name {
    font-weight: 600;
}

.addon-price {
    color: #2c3e50;
    font-weight: bold;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #777;
}

.error {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 15px;
    border-radius: 6px;
}

/* v2.0.1: Image Upload Styles */
.area-image-upload {
    display: block;
    width: 100%;
    padding: 8px;
    border: 2px dashed #ddd;
    border-radius: 4px;
    cursor: pointer;
    background: #f9f9f9;
    transition: border-color 0.3s ease;
}

.area-image-upload:hover {
    border-color: #2271b1;
}

.uploaded-image-preview {
    margin-top: 10px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.uploaded-image-preview img {
    display: block;
    max-width: 200px;
    height: auto;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.remove-image-btn {
    margin-top: 8px;
    padding: 6px 12px;
    background: #d63638;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.3s ease;
}

.remove-image-btn:hover {
    background: #c92a2b;
}

/* v2.0.1: Draggable Image on Preview */
.draggable-uploaded-image {
    border: 2px solid #2271b1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: box-shadow 0.2s ease;
}

.draggable-uploaded-image:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.draggable-uploaded-image.ui-draggable-dragging {
    opacity: 0.8;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.draggable-uploaded-image img {
    display: block;
    width: 100%;
    height: auto;
}

.resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 20px;
    height: 20px;
    background: #2271b1;
    cursor: nwse-resize;
    border-radius: 0 0 4px 0;
}

.resize-handle::after {
    content: '⇲';
    position: absolute;
    right: 2px;
    bottom: 0;
    font-size: 12px;
    color: white;
}

/* Responsive */
@media (max-width: 1024px) {
    .hsc-configurator-container {
        grid-template-columns: 1fr;
    }
    
    .hsc-preview-panel {
        position: relative !important;
        top: auto !important;
    }
    
    .monument-preview {
        max-width: 400px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .monument-grid {
        grid-template-columns: 1fr;
    }
    
    .option-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .radio-group {
        flex-direction: column;
        gap: 10px;
    }
}
/* Multi-Area Engraving Fields Styles */

.engraving-area-fields {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.engraving-area-fields h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.1em;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.area-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.form-field-full {
    grid-column: 1 / -1;
}

.form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

.form-field input,
.form-field textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-field input:focus,
.form-field textarea:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px rgba(34, 113, 177, 0.2);
}

.form-field input.error,
.form-field textarea.error {
    border-color: #d63638;
    background-color: #fef7f7;
}

.form-field textarea {
    resize: vertical;
    min-height: 80px;
}

.form-field .field-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Preview Area Overlays */
.preview-area-overlay {
    animation: fadeIn 0.3s ease;
}

/* ============================================
   v3.0: DRAG AND DROP OVERLAY SYSTEM
   ============================================ */

.draggable-overlay {
    cursor: move;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}

/* Hover state — show border and controls */
.draggable-overlay:hover {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.15);
}

/* Active dragging state */
.draggable-overlay.is-dragging {
    border-color: rgba(34, 113, 177, 0.8);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 200 !important;
    opacity: 0.92;
}

.draggable-overlay.ui-draggable-dragging {
    border-color: rgba(34, 113, 177, 0.8);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 200 !important;
}

/* Drag handle (grip dots) */
.overlay-drag-handle {
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(34, 113, 177, 0.85);
    color: #fff;
    padding: 2px 10px;
    border-radius: 0 0 6px 6px;
    cursor: move;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

.draggable-overlay:hover .overlay-drag-handle {
    opacity: 1;
}

.draggable-overlay.is-dragging .overlay-drag-handle {
    opacity: 1;
    background: rgba(34, 113, 177, 1);
}

/* Text content area */
.overlay-text-content {
    width: 100%;
    text-align: inherit;
    cursor: move;
    padding: 4px 0;
}

.overlay-line {
    display: block;
    line-height: 1.2;
    margin: 0;
    padding: 0;
}

.overlay-line-name {
    font-weight: bold;
    margin-bottom: 2px;
}

.overlay-line-epitaph {
    font-style: italic;
    opacity: 0.9;
    margin-top: 2px;
}

.overlay-line-dates {
    opacity: 0.95;
}

/* Controls bar (font size + reset) */
.overlay-controls {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(30, 30, 30, 0.9);
    padding: 3px 6px;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
    white-space: nowrap;
    pointer-events: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.draggable-overlay:hover .overlay-controls,
.overlay-controls.visible {
    opacity: 1;
}

.overlay-controls button {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    width: 26px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.overlay-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.overlay-font-size-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 10px;
    min-width: 28px;
    text-align: center;
    font-family: monospace;
}

.overlay-reset-pos {
    margin-left: 4px;
    border-left: 1px solid rgba(255, 255, 255, 0.2) !important;
    padding-left: 4px !important;
}

/* Area label badge */
.overlay-area-label {
    position: absolute;
    top: -18px;
    right: 4px;
    background: rgba(34, 113, 177, 0.85);
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    pointer-events: none;
}

.draggable-overlay:hover .overlay-area-label {
    opacity: 1;
}

/* Hide controls during html2canvas capture */
.capture-hidden {
    display: none !important;
}

/* Auto-centered overlay enhancements */
.preview-area-overlay.auto-centered-overlay .overlay-text-content {
    text-align: center;
}

/* Region-specific centering for doubles */
.preview-area-overlay.region-left .overlay-text-content,
.preview-area-overlay.region-right .overlay-text-content {
    text-align: center;
}

.preview-area-overlay.region-shared .overlay-text-content {
    text-align: center;
    font-style: italic;
}

/* Drag hint indicator on the preview panel */
.hsc-drag-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f0f6fc;
    border: 1px solid #c5d9ed;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 13px;
    color: #2271b1;
}

.hsc-drag-hint svg {
    flex-shrink: 0;
}

.hsc-drag-hint-text {
    line-height: 1.4;
}

.hsc-drag-hint-text strong {
    display: block;
    font-size: 13px;
    margin-bottom: 1px;
}

.hsc-drag-hint-text small {
    color: #666;
    font-size: 11px;
}

/* Mobile: make controls always visible since no hover */
@media (max-width: 1024px) {
    .overlay-drag-handle {
        opacity: 0.7;
    }
    
    .overlay-controls {
        opacity: 0.8;
    }
    
    .overlay-area-label {
        opacity: 0.7;
    }
    
    .draggable-overlay {
        border-color: rgba(255, 255, 255, 0.25);
    }
}

/* Subtle region debug borders (hidden by default) */
.hsc-debug-regions .preview-area-overlay {
    border: 1px dashed rgba(255, 255, 255, 0.3);
}

.hsc-debug-regions .preview-area-overlay.region-left {
    border-color: rgba(33, 150, 243, 0.4);
}

.hsc-debug-regions .preview-area-overlay.region-right {
    border-color: rgba(244, 67, 54, 0.4);
}

.hsc-debug-regions .preview-area-overlay.region-shared {
    border-color: rgba(76, 175, 80, 0.4);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Monument preview positioning — v3.0: overflow visible for drag controls */
#hsc-monument-preview {
    position: relative;
    overflow: visible;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .area-fields-grid {
        grid-template-columns: 1fr;
    }
    
    .engraving-area-fields {
        padding: 15px;
    }
}

/* Admin area configuration styles */
.hsc-areas-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.hsc-areas-info {
    background: #fff;
    padding: 15px;
    border-left: 4px solid #2271b1;
    margin-bottom: 20px;
}

.hsc-areas-info p {
    margin: 5px 0;
}

#engraving-areas-container {
    margin-bottom: 15px;
}

.hsc-area-config {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.hsc-area-config:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.hsc-area-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.hsc-area-header h4 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hsc-area-body {
    padding-top: 10px;
}

.hsc-form-subsection {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.hsc-form-subsection h5 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #2271b1;
    font-size: 14px;
    font-weight: 600;
}

.hsc-position-grid,
.hsc-styling-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.hsc-form-col-3,
.hsc-form-col-4 {
    display: flex;
    flex-direction: column;
}

.hsc-checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.remove-area {
    color: #d63638;
    text-decoration: none;
}

.remove-area:hover {
    color: #d63638;
    text-decoration: underline;
}

.hsc-help-tip {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background: #2271b1;
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    cursor: help;
    margin-left: 5px;
}

/* Make preview responsive */
.monument-preview {
    position: relative;
    width: 100%;
    max-width: 100%;
}

.monument-image-container {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* Square aspect ratio by default */
}

.monument-image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Area count badge in monument list */
.monument-areas {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* ============================================
   v4.0: CLIPART BROWSER
   ============================================ */

.hsc-clipart-browser {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}

/* Category tabs */
.hsc-clipart-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 8px 10px;
    background: #f7f8f9;
    border-bottom: 1px solid #e0e0e0;
}

.clipart-tab {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.clipart-tab:hover {
    background: #e9ecf0;
}

.clipart-tab.active {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

/* Search */
.hsc-clipart-search {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}

.hsc-clipart-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.hsc-clipart-search input:focus {
    border-color: #2271b1;
}

/* Clipart grid */
.hsc-clipart-browser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    padding: 12px;
    max-height: 320px;
    overflow-y: auto;
}

.clipart-browser-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
    text-align: center;
}

.clipart-browser-item:hover {
    border-color: #2271b1;
    background: #f0f6ff;
    transform: translateY(-2px);
}

.clipart-browser-item:active {
    transform: translateY(0);
}

.clipart-browser-item img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin-bottom: 4px;
    pointer-events: none;
}

.clipart-item-name {
    font-size: 11px;
    color: #444;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clipart-empty,
.clipart-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px;
    color: #888;
    font-style: italic;
}

.hsc-clipart-help {
    padding: 8px 12px;
    margin: 0;
    background: #f9f9f9;
    color: #666;
    font-size: 12px;
    border-top: 1px solid #eee;
}

/* Placed clipart summary */
.hsc-placed-clipart-summary {
    background: #f0f6fc;
    border: 1px solid #c5d9ed;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.hsc-placed-clipart-summary h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #2271b1;
}

.placed-clipart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid #d5e5f2;
}

.placed-clipart-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.placed-clipart-item img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 4px;
    background: #fff;
    padding: 2px;
}

.placed-clipart-item span {
    flex: 1;
    font-size: 13px;
}

.placed-clipart-item a {
    color: #b32d2e;
    font-size: 12px;
    text-decoration: none;
}

.placed-clipart-item a:hover {
    text-decoration: underline;
}

/* "or" divider */
.hsc-or-divider {
    text-align: center;
    border-bottom: 1px solid #ddd;
    line-height: 0;
    margin: 20px 0;
}

.hsc-or-divider span {
    background: #fff;
    padding: 0 14px;
    color: #888;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hsc-custom-upload-section .form-group {
    margin-top: 0;
}

/* ============================================
   v4.0: PLACED CLIPART ON PREVIEW
   ============================================ */

.placed-clipart-overlay {
    transition: box-shadow 0.2s;
    border: 2px solid transparent;
    border-radius: 3px;
}

.placed-clipart-overlay:hover {
    border-color: rgba(34, 113, 177, 0.6);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.placed-clipart-overlay.ui-draggable-dragging {
    border-color: rgba(34, 113, 177, 0.8);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    z-index: 200 !important;
}

/* Remove button */
.remove-placed-clipart {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 22px;
    height: 22px;
    background: #d63638;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 10;
    padding: 0;
}

.placed-clipart-overlay:hover .remove-placed-clipart {
    opacity: 1;
}

.remove-placed-clipart:hover {
    background: #a01c1f;
}

/* Resize handle */
.clipart-resize-handle {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    background: #2271b1;
    border: 2px solid #fff;
    border-radius: 2px;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 10;
}

.placed-clipart-overlay:hover .clipart-resize-handle {
    opacity: 1;
}

/* Mobile: always show controls */
@media (max-width: 1024px) {
    .remove-placed-clipart,
    .clipart-resize-handle {
        opacity: 0.7;
    }
    
    .hsc-clipart-browser-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    
    .clipart-browser-item img {
        width: 56px;
        height: 56px;
    }
}
