/**
 * Zephyr Builder Frontend Block Editor Styles
 */

/* Hide Alpine elements until initialized */
[x-cloak] {
    display: none !important;
}

/* Editor Status Badge (fixed bottom floater) */
.zephyr-editor-badge {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    flex-wrap: wrap;
    justify-content: center;
}

.zephyr-editor-badge-dot {
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

.zephyr-editor-badge-you {
    color: #fff;
}

.zephyr-editor-badge-others {
    display: inline;
}

.zephyr-editor-badge-separator {
    color: #888;
    margin: 0 2px;
}

.zephyr-editor-badge-other {
    color: #90CAF9;
}

.zephyr-editor-badge-label {
    color: #aaa;
    margin-left: 2px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Edit Buttons - shown on block hover */
.zephyr-builder-block {
    position: relative;
}

/* Button container - stacks buttons vertically */
.zephyr-block-edit-btns {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 3;
}

.zephyr-builder-block:hover .zephyr-block-edit-btns {
    opacity: 1;
}

.zephyr-block-edit-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(33, 150, 243, 0.95);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    white-space: nowrap;
}

.zephyr-block-edit-btn:hover {
    background: rgba(25, 118, 210, 0.95);
}

.zephyr-block-edit-btn svg {
    width: 14px;
    height: 14px;
}

/* Block Type Label Pill (top-left) */
.zephyr-block-type-label {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 3;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    pointer-events: none;
    white-space: nowrap;
}

.zephyr-builder-block:hover .zephyr-block-type-label {
    opacity: 1;
}

/* Modal Overlay */
.zephyr-config-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

/* Modal Container */
.zephyr-config-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 800px;
    max-width: 92vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Modal Header */
.zephyr-config-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    border-radius: 8px 8px 0 0;
}

.zephyr-config-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.zephyr-config-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.zephyr-config-modal-close:hover {
    background: #e0e0e0;
}

/* Modal Body */
.zephyr-config-modal-body {
    padding: 20px;
    flex: 1;
    overflow: auto;
}

/* Section styling */
.zephyr-editor-section {
    margin-bottom: 20px;
}

.zephyr-editor-section:last-child {
    margin-bottom: 0;
}

.zephyr-editor-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.zephyr-editor-section-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.zephyr-json-toggle-btn {
    font-size: 11px;
    padding: 4px 8px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
}

.zephyr-json-toggle-btn:hover {
    background: #e0e0e0;
}

/* Content Editor Textarea */
.zephyr-content-editor-textarea {
    width: 100%;
    height: 200px;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.6;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
    box-sizing: border-box;
}

.zephyr-content-editor-textarea:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* JSON Editor with Line Numbers */
.zephyr-config-modal-textarea-wrapper {
    display: flex;
    height: 350px;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

.zephyr-config-modal-textarea-wrapper:focus-within {
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.zephyr-config-modal-line-numbers {
    background: #f5f5f5;
    border-right: 1px solid #ddd;
    padding: 12px 8px;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #999;
    text-align: right;
    user-select: none;
    overflow: hidden;
    min-width: 40px;
}

.zephyr-config-modal-line-numbers span {
    display: block;
}

.zephyr-config-modal-textarea {
    flex: 1;
    height: 100%;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 12px;
    border: none;
    resize: none;
    box-sizing: border-box;
    outline: none;
    overflow: auto;
    white-space: pre;
    word-wrap: normal;
    overflow-x: auto;
}

/* Modal Footer */
.zephyr-config-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f5f5f5;
    border-top: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
}

.zephyr-config-modal-error {
    font-size: 13px;
    color: #d32f2f;
}

.zephyr-config-modal-buttons {
    display: flex;
    gap: 8px;
}

.zephyr-btn-cancel {
    padding: 8px 20px;
    background: #e0e0e0;
    color: #333;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.zephyr-btn-cancel:hover {
    background: #d0d0d0;
}

.zephyr-btn-save {
    padding: 8px 20px;
    background: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.zephyr-btn-save:hover {
    background: #43A047;
}

.zephyr-btn-save:disabled {
    background: #a5d6a7;
    cursor: not-allowed;
}

/* Help text */
.zephyr-editor-help {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

/* ============================================
   Row Editor Styles
   ============================================ */

/* Row highlight when hovering "Edit Parent Row" button */
.zephyr-builder-row.zephyr-row-highlight {
    box-shadow: inset 0 0 0 2px #ef4444 !important;
}

/* Row Settings Modal - narrower width */
.zephyr-config-modal.zephyr-row-settings-modal {
    width: 400px;
}

/* Row color picker field */
.zephyr-row-color-field {
    display: flex;
    gap: 8px;
    align-items: center;
}

.zephyr-row-color-field input[type="color"] {
    width: 44px;
    height: 36px;
    padding: 2px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
}

.zephyr-row-color-field input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.zephyr-row-color-field input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.zephyr-row-color-field input[type="text"] {
    flex: 1;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, monospace;
}

.zephyr-row-color-field input[type="text"]:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.zephyr-row-color-field button {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f0f0f0;
    color: #666;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zephyr-row-color-field button:hover {
    background: #e0e0e0;
}

/* Row toggle buttons */
.zephyr-row-toggle-field {
    display: flex;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
}

.zephyr-row-toggle-field button {
    flex: 1;
    padding: 10px 20px;
    background: #fff;
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: #666;
    transition: background 0.15s, color 0.15s;
}

.zephyr-row-toggle-field button:first-child {
    border-right: 1px solid #ccc;
}

.zephyr-row-toggle-field button.active {
    background: #2196F3;
    color: #fff;
}

.zephyr-row-toggle-field button:hover:not(.active) {
    background: #f5f5f5;
}
