/* Visual mode: push page content and show sidebar */
body.epictr-visual-mode-active {
    margin-right: 380px !important;
}

/* Sidebar — fixed right panel */
#epictr-visual-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100vh;
    background: #fff;
    border-left: none;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 13px;
    color: #1d2327;
    box-sizing: border-box;
}

/* Account for WP admin bar */
body.admin-bar #epictr-visual-sidebar {
    top: 32px;
    height: calc(100vh - 32px);
}

@media screen and (max-width: 782px) {
    body.admin-bar #epictr-visual-sidebar {
        top: 46px;
        height: calc(100vh - 46px);
    }
}

/* --- Header --- */
.epictr-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #1d2327;
    flex-shrink: 0;
}

.epictr-sidebar-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.epictr-sidebar-header h2 .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.6);
}

.epictr-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 20px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.epictr-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* --- Content area --- */
.epictr-sidebar-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.epictr-sidebar-content h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px;
    color: #787c82;
    display: flex;
    align-items: center;
    gap: 5px;
}

.epictr-sidebar-content h3 .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.epictr-sidebar-content hr {
    border: none;
    border-top: 1px solid #f0f0f1;
    margin: 20px 0;
}

/* --- Button styles (WP admin CSS not available on frontend) --- */
#epictr-visual-sidebar .epictr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 14px;
    height: 34px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1;
    text-decoration: none;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    background: #fff;
    color: #2c3338;
    cursor: pointer;
    transition: all 0.15s ease;
    box-sizing: border-box;
    white-space: nowrap;
}

#epictr-visual-sidebar .epictr-btn:hover {
    background: #f6f7f7;
    border-color: #8c8f94;
    color: #1d2327;
}

#epictr-visual-sidebar .epictr-btn-primary {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

#epictr-visual-sidebar .epictr-btn-primary:hover {
    background: #135e96;
    border-color: #135e96;
    color: #fff;
}

#epictr-visual-sidebar .epictr-btn-sm {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 400;
    border-radius: 5px;
}

#epictr-visual-sidebar .epictr-btn-danger {
    color: #d63638;
    border-color: #d63638;
    background: #fff;
}

#epictr-visual-sidebar .epictr-btn-danger:hover {
    background: #d63638;
    color: #fff;
}

#epictr-visual-sidebar .epictr-btn-full {
    width: 100%;
}

/* Dashicons inside buttons */
#epictr-visual-sidebar .epictr-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
    vertical-align: text-bottom;
}

#epictr-visual-sidebar .epictr-btn-sm .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* --- Select Element primary action --- */
#epictr-select-element {
    margin-top: 4px;
    height: 40px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
}

/* Active selection state */
.epictr-selecting-active #epictr-select-element {
    background: #d63638 !important;
    border-color: #d63638 !important;
    color: #fff !important;
}

/* --- Event list items --- */
.epictr-event-item {
    background: #f8f9fa;
    border: 1px solid #f0f0f1;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.epictr-event-item:hover {
    border-color: #c3c4c7;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.epictr-event-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.epictr-event-item-name {
    font-weight: 600;
    font-size: 13px;
    color: #1d2327;
}

.epictr-event-item-tag {
    flex-shrink: 0;
    display: inline-block;
    background: #e7f1fa;
    color: #2271b1;
    font-size: 11px;
    font-family: Menlo, Consolas, Monaco, monospace;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.epictr-event-item-selector {
    color: #787c82;
    font-size: 11px;
    font-family: Menlo, Consolas, Monaco, monospace;
    margin-top: 8px;
    word-break: break-all;
    line-height: 1.4;
}

.epictr-event-item-actions {
    margin-top: 12px;
    display: flex;
    gap: 6px;
}

/* --- Form styling --- */
#epictr-event-form {
    margin-top: 20px;
}

.epictr-form-group {
    margin-bottom: 14px;
}

.epictr-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #1d2327;
}

.epictr-form-group input[type="text"] {
    width: 100%;
    font-size: 13px;
    font-family: inherit;
    padding: 8px 12px;
    height: 36px;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    box-sizing: border-box;
    color: #2c3338;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.epictr-form-group input[type="text"]:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15);
    outline: none;
}

.epictr-form-group input[type="text"][readonly] {
    background: #f8f9fa;
    color: #50575e;
    border-color: #e0e0e0;
}

.epictr-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* --- Highlight overlay for element hover during selection --- */
#epictr-highlight-overlay {
    position: absolute;
    background: rgba(34, 113, 177, 0.08);
    border: 2px solid #2271b1;
    pointer-events: none;
    z-index: 99998;
    transition: all 0.1s ease;
    box-sizing: border-box;
    border-radius: 4px;
}

/* Prevent page interactions during selection */
body.epictr-selecting-active *:not(#epictr-visual-sidebar):not(#epictr-visual-sidebar *):not(#epictr-highlight-overlay):not(#wpadminbar):not(#wpadminbar *) {
    cursor: crosshair !important;
}

/* --- No events message --- */
.epictr-no-events {
    color: #a7aaad;
    font-size: 13px;
    text-align: center;
    padding: 28px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px dashed #dcdcde;
    margin: 0;
}

.epictr-loading {
    color: #787c82;
    text-align: center;
    padding: 28px 0;
}

/* --- Button loading state --- */
@keyframes epictr-spin {
    to { transform: rotate(360deg); }
}

#epictr-visual-sidebar .epictr-btn-loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

#epictr-visual-sidebar .epictr-btn-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: epictr-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-left: 6px;
}
