/**
 * Section Overlay System
 * Visual highlighting for sections in preview mode
 * Phase 2.3 - Visual Builder
 */

/* Overlay Container */
.section-overlay-container {
    position: relative;
    pointer-events: none;
}

.section-overlay-container.active {
    pointer-events: auto;
}

/* Section Overlay */
.section-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px dashed transparent;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 9998;
}

/* Hover State */
.section-overlay.hover {
    border-color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.05);
}

/* Active/Selected State */
.section-overlay.active {
    border-color: #2563eb;
    border-style: solid;
    background-color: rgba(37, 99, 235, 0.08);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

/* Locked State */
.section-overlay.locked {
    border-color: #dc2626;
    cursor: not-allowed;
}

.section-overlay.locked.hover {
    background-color: rgba(220, 38, 38, 0.05);
}

/* Section Label */
.section-label {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #3b82f6;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 0 0 0 6px;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Cairo', 'Tajawal', sans-serif;
    direction: rtl;
}

.section-overlay.hover .section-label,
.section-overlay.active .section-label {
    opacity: 1;
    transform: translateY(0);
}

.section-overlay.active .section-label {
    background: #2563eb;
}

.section-overlay.locked .section-label {
    background: #dc2626;
}

/* Section Label Icons */
.section-label-icon {
    display: inline-block;
    margin-left: 4px;
}

/* Action Buttons on Label */
.section-label-actions {
    display: inline-flex;
    gap: 4px;
    margin-left: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.section-overlay.active .section-label-actions {
    opacity: 1;
}

.section-label-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.section-label-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Resize Handles (for future use) */
.section-resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #3b82f6;
    border: 1px solid white;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: auto;
    cursor: grab;
}

.section-resize-handle:active {
    cursor: grabbing;
}

.section-overlay.active .section-resize-handle {
    opacity: 1;
}

.section-resize-handle.top-left {
    top: -4px;
    left: -4px;
    cursor: nwse-resize;
}

.section-resize-handle.top-right {
    top: -4px;
    right: -4px;
    cursor: nesw-resize;
}

.section-resize-handle.bottom-left {
    bottom: -4px;
    left: -4px;
    cursor: nesw-resize;
}

.section-resize-handle.bottom-right {
    bottom: -4px;
    right: -4px;
    cursor: nwse-resize;
}

/* Drag Handle */
.section-drag-handle {
    position: absolute;
    top: 50%;
    right: -30px;
    transform: translateY(-50%);
    width: 24px;
    height: 40px;
    background: #3b82f6;
    border-radius: 0 6px 6px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    opacity: 0;
    transition: all 0.2s ease;
    color: white;
    font-size: 12px;
    pointer-events: auto;
}

.section-drag-handle:active {
    cursor: grabbing;
}

.section-overlay.active .section-drag-handle {
    opacity: 1;
    right: -26px;
}

.section-drag-handle:hover {
    background: #2563eb;
}

/* Empty Section Placeholder */
.section-overlay.empty {
    border-style: dotted;
    border-color: #9ca3af;
    min-height: 60px;
}

.section-overlay.empty .section-label {
    background: #9ca3af;
}

/* RTL Support */
[dir="rtl"] .section-label {
    right: auto;
    left: -2px;
    border-radius: 0 0 6px 0;
}

[dir="rtl"] .section-drag-handle {
    right: auto;
    left: -30px;
    border-radius: 6px 0 0 6px;
}

[dir="rtl"] .section-overlay.active .section-drag-handle {
    right: auto;
    left: -26px;
}

/* Smooth Transitions */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Disable pointer events on section content during overlay interaction */
.visual-builder-active .section-overlay-container > *:not(.section-overlay) {
    pointer-events: none;
}

/* Loading State */
.section-overlay.loading {
    border-color: #f59e0b;
    background: repeating-linear-gradient(
        45deg,
        rgba(245, 158, 11, 0.05),
        rgba(245, 158, 11, 0.05) 10px,
        rgba(245, 158, 11, 0.1) 10px,
        rgba(245, 158, 11, 0.1) 20px
    );
    animation: loading-pulse 1s ease-in-out infinite;
}

@keyframes loading-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Highlight Animation */
@keyframes highlight-flash {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
}

.section-overlay.flash {
    animation: highlight-flash 0.6s ease-out;
}
