/**
 * CMS Drag-and-Drop Styles
 * EAA Ballpark CMS Page Builder
 *
 * Styles for drag-and-drop interactions, drop zones, and visual feedback.
 */

/* === Draggable Components === */
.cms-draggable {
    cursor: move;
    cursor: grab;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
}

.cms-draggable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.cms-draggable:active {
    cursor: grabbing;
}

/* Component being dragged */
.cms-dragging {
    opacity: 0.5;
    cursor: grabbing !important;
    transform: scale(1.05);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    will-change: transform;
    z-index: 1000;
}

/* === Drop Zones === */
.cms-drop-zone {
    min-height: 100px;
    border: 2px dashed transparent;
    border-radius: 4px;
    transition: all 0.3s ease;
    position: relative;
}

/* Drop zone when drag is active */
.cms-drop-zone-active {
    border-color: rgba(13, 93, 44, 0.3); /* EAA green */
    background: rgba(13, 93, 44, 0.05);
}

/* Drop zone on hover (valid drop) */
.cms-drop-zone-valid {
    border-color: #0d5d2c; /* EAA green */
    border-style: solid;
    background: rgba(13, 93, 44, 0.1);
    box-shadow: 0 0 0 4px rgba(13, 93, 44, 0.1);
}

/* Drop zone on hover (invalid drop) */
.cms-drop-zone-invalid {
    border-color: #d32f2f; /* Error red */
    border-style: solid;
    background: rgba(211, 47, 47, 0.1);
    box-shadow: 0 0 0 4px rgba(211, 47, 47, 0.1);
    cursor: not-allowed;
}

/* Drop zone placeholder */
.cms-drop-placeholder {
    min-height: 120px;
    border: 2px dashed rgba(13, 93, 44, 0.4);
    border-radius: 4px;
    background: repeating-linear-gradient(
        45deg,
        rgba(13, 93, 44, 0.05),
        rgba(13, 93, 44, 0.05) 10px,
        rgba(13, 93, 44, 0.1) 10px,
        rgba(13, 93, 44, 0.1) 20px
    );
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0d5d2c;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.cms-drop-placeholder:hover {
    background: repeating-linear-gradient(
        45deg,
        rgba(13, 93, 44, 0.1),
        rgba(13, 93, 44, 0.1) 10px,
        rgba(13, 93, 44, 0.15) 10px,
        rgba(13, 93, 44, 0.15) 20px
    );
}

/* === Component Palette === */
.cms-palette {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 16px;
    max-height: 600px;
    overflow-y: auto;
}

.cms-palette-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 12px;
    cursor: move;
    cursor: grab;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cms-palette-item:hover {
    border-color: #0d5d2c;
    box-shadow: 0 2px 8px rgba(13, 93, 44, 0.15);
    transform: translateX(4px);
}

.cms-palette-item:active {
    cursor: grabbing;
}

.cms-palette-item-icon {
    color: #0d5d2c;
    font-size: 24px;
}

.cms-palette-item-info {
    flex: 1;
}

.cms-palette-item-title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin: 0;
}

.cms-palette-item-description {
    font-size: 12px;
    color: #666;
    margin: 4px 0 0 0;
}

/* === Page Editor Grid === */
.cms-page-editor {
    background: white;
    border-radius: 8px;
    padding: 24px;
    min-height: 400px;
}

.cms-page-row {
    margin-bottom: 24px;
    position: relative;
}

.cms-page-row-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Placed Components === */
.cms-placed-component {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    padding: 16px;
    cursor: move;
    cursor: grab;
    transition: all 0.3s ease;
    position: relative;
}

.cms-placed-component:hover {
    border-color: #0d5d2c;
    box-shadow: 0 4px 12px rgba(13, 93, 44, 0.15);
}

.cms-placed-component-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.cms-placed-component-title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.cms-placed-component-actions {
    display: flex;
    gap: 4px;
}

.cms-placed-component-grip {
    color: #999;
    cursor: grab;
    font-size: 18px;
}

.cms-placed-component-grip:hover {
    color: #0d5d2c;
}

/* === Reorder Animation === */
.cms-reorder-transition {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* === Keyboard Focus === */
.cms-draggable:focus,
.cms-placed-component:focus {
    outline: 2px solid #0d5d2c;
    outline-offset: 2px;
}

.cms-keyboard-hint {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    font-style: italic;
}

/* === Empty State === */
.cms-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.cms-empty-state-icon {
    font-size: 48px;
    color: #ccc;
    margin-bottom: 16px;
}

.cms-empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
}

.cms-empty-state-description {
    font-size: 14px;
    color: #999;
}

/* === Snap Guides (Active) === */
.cms-snap-guide-active {
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* === Accessibility === */
[role="button"][aria-grabbed="true"] {
    box-shadow: 0 0 0 3px rgba(240, 179, 35, 0.5); /* EAA gold focus ring */
}

[aria-dropeffect="move"] {
    position: relative;
}

[aria-dropeffect="move"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px dashed rgba(13, 93, 44, 0.3);
    border-radius: 4px;
    pointer-events: none;
}

/* === Screen Reader Only === */
.cms-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* === Loading State === */
.cms-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.cms-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid rgba(13, 93, 44, 0.2);
    border-top-color: #0d5d2c;
    border-radius: 50%;
    animation: cms-spin 0.6s linear infinite;
}

@keyframes cms-spin {
    to { transform: rotate(360deg); }
}

/* === Responsive Adjustments === */
@media (max-width: 959px) {
    .cms-palette {
        max-height: 300px;
    }

    .cms-page-editor {
        padding: 16px;
    }

    .cms-placed-component {
        padding: 12px;
    }
}

/* === Dark Mode (Future) === */
@media (prefers-color-scheme: dark) {
    .cms-palette {
        background: #2a2a2a;
    }

    .cms-palette-item {
        background: #333;
        border-color: #444;
    }

    .cms-page-editor {
        background: #1e1e1e;
    }

    .cms-placed-component {
        background: #2a2a2a;
        border-color: #444;
    }
}
