/* --- Editor Page Styles --- */

/* Guest user upgrade button in editor header */
.guest-editor-upgrade-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.85rem;
    background: linear-gradient(135deg, #8b5cf6, #d946ef);
    color: #fff !important;
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none !important;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
    animation: guest-pulse 2.5s ease-in-out infinite;
    transition: transform 0.2s, opacity 0.2s;
}

.guest-editor-upgrade-btn:hover {
    transform: scale(1.05);
    opacity: 0.9;
    animation: none;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.6);
}

@keyframes guest-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.5);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(139, 92, 246, 0);
    }
}

body:has(.editor-container) {
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

#app:has(.editor-container) {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100%;
    height: 100vh;
}

.editor-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-color);
}

/* Header - simplified: back + name on left, save on right */
.editor-header {
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 20;
    color: var(--text-main);
}

.editor-header h2 {
    font-size: 1.2rem;
    margin: 0;
    color: var(--text-main);
}

/* Workspace - full width preview now */
.editor-workspace {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex !important;
    /* Override pages.css grid layout */
}

/* Preview Area - takes full space */
.editor-preview {
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
    flex-shrink: 0;
}

.preview-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: white;
}

/* ==============================
   Floating Prompt Box
   ============================== */

.prompt-float {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 680px;
    z-index: 100;

    background: rgba(22, 22, 30, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;

    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.prompt-float.collapsed {
    transform: translateX(-50%) translateY(calc(100% - 44px));
    padding: 0;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.prompt-toggle-btn {
    position: absolute;
    top: -36px;
    right: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(30, 30, 35, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    transition: all 0.2s;
    z-index: 101;
}

.prompt-toggle-btn:hover {
    color: var(--text-main);
    background: rgba(40, 40, 45, 0.95);
    transform: translateY(-2px);
}

.prompt-toggle-btn svg {
    transition: transform 0.3s;
}

.prompt-float.collapsed .prompt-toggle-btn svg {
    transform: rotate(180deg);
}

.prompt-float.collapsed> :not(.prompt-toggle-btn) {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* Action buttons row */
.prompt-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
}

.prompt-actions .action-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.prompt-actions .action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--text-main);
}

.prompt-actions .action-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Spacer to push chat history toggle to the right */
.prompt-actions .action-spacer {
    flex: 1;
}

/* Input area */
.prompt-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.prompt-input-row .prompt-textarea {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.prompt-input-row .prompt-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.prompt-input-row .prompt-textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.prompt-send-btn {
    background: var(--primary);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.prompt-send-btn:hover {
    filter: brightness(1.15);
    transform: scale(1.05);
}

.prompt-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Selected element indicator (inside floating prompt) */
.selected-element-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: rgba(59, 130, 246, 0.12);
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.25);
    font-size: 0.85rem;
}

.selected-element-bar.visible {
    display: flex;
}

/* ==============================
   Thinking Animation (3 dots)
   ============================== */

.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.thinking-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    animation: dotBounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.16s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes dotBounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==============================
   Chat History Panel
   ============================== */

.chat-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.chat-panel-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.chat-panel {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 90%;
    max-width: 680px;
    max-height: 50vh;
    z-index: 200;

    background: rgba(22, 22, 30, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.3);

    display: flex;
    flex-direction: column;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-panel.open {
    transform: translateX(-50%) translateY(0);
}

.chat-panel-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-panel-header h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-main);
}

.chat-panel-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    transition: color 0.15s;
}

.chat-panel-close:hover {
    color: var(--text-main);
}

.chat-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

/* Chat Messages */
.message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    max-width: 85%;
    line-height: 1.6;
    font-size: 0.9rem;
    position: relative;
    animation: msgSlideIn 0.25s ease-out;
}

@keyframes msgSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.agent {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 2px;
    align-self: flex-start;
}

.message.user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

/* ==============================
   Modals (kept from original)
   ============================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 2005 !important;
    animation: fadeIn 0.3s ease-out;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    z-index: 2001;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* ==============================
   Wizard Modal 
   ============================== */

.wizard-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    color: var(--text-main);
}

.wizard-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.wizard-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
    z-index: 2001;
    animation: modalBounce 0.4s cubic-bezier(0.2, 0.8, 0.2, 1.15);
}

@keyframes modalBounce {
    0% {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.wizard-header {
    padding: 1.5rem 2rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wizard-progress {
    height: 4px;
    background: var(--bg-primary);
    width: 100%;
}

.wizard-progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.4s ease;
}

.wizard-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.wizard-step h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.wizard-help {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Card Grid for choices */
.wizard-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.wizard-card-input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    position: relative;
}

.wizard-card-input:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--text-muted);
}

.wizard-card-input.selected {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb, 230, 57, 70), 0.08);
    box-shadow: 0 0 0 1px var(--primary);
}

.wizard-card-input input {
    display: none;
}

.wizard-footer {
    padding: 1.5rem 2rem;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Sections Grid */
.sections-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.section-checkbox {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.section-checkbox.locked {
    opacity: 0.6;
    cursor: not-allowed;
}

.review-summary {
    border-radius: 12px;
}

/* Scrollbar for Wizard */
.wizard-body::-webkit-scrollbar {
    width: 6px;
}

.wizard-body::-webkit-scrollbar-track {
    background: transparent;
}

.wizard-body::-webkit-scrollbar-thumb {
    background: var(--border-dim);
    border-radius: 10px;
}


/* ==============================
   Responsive
   ============================== */

@media (max-width: 768px) {
    .editor-header {
        height: 48px;
        padding: 0 0.75rem;
    }

    .prompt-float {
        bottom: 1rem;
        width: 95%;
        padding: 0.75rem 1rem;
        border-radius: 12px;
    }

    .prompt-actions .action-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }

    .chat-panel {
        width: 100%;
        max-width: 100%;
        max-height: 60vh;
        border-radius: 12px 12px 0 0;
    }

    .wizard-modal {
        padding: 0.5rem;
    }

    .wizard-content {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 8px;
    }

    .wizard-header {
        padding: 1rem 1.25rem;
    }

    .wizard-header h2 {
        font-size: 1.25rem;
    }

    .wizard-body {
        padding: 1.25rem;
    }

    .wizard-footer {
        padding: 1rem 1.25rem;
    }

    .step-options {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .editor-header {
        height: 44px;
        padding: 0 0.5rem;
    }

    .prompt-float {
        bottom: 0.5rem;
        width: 98%;
        padding: 0.6rem 0.75rem;
        border-radius: 10px;
    }

    .prompt-actions {
        gap: 0.3rem;
    }

    .prompt-actions .action-btn {
        padding: 0.25rem 0.4rem;
        font-size: 0.7rem;
    }

    .chat-panel {
        max-height: 70vh;
    }

    .wizard-modal {
        padding: 0;
    }

    .wizard-content {
        max-height: 100vh;
        border-radius: 0;
    }

    .wizard-header {
        padding: 0.875rem 1rem;
    }

    .wizard-header h2 {
        font-size: 1.125rem;
    }

    .wizard-body {
        padding: 1rem;
    }

    .wizard-footer {
        padding: 0.875rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .wizard-footer .btn {
        flex: 1;
        min-width: 100px;
    }
}