/* LLM Chat Interface Styles */

#llm-chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Toggle Button */
.llm-chat-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--tcvelik-primary, #6000C9) 0%, var(--tcvelik-primary-light, #8B2BE2) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(96, 0, 201, 0.4);
    transition: all 0.3s ease;
    color: white;
    font-size: 24px;
}

.llm-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(96, 0, 201, 0.6);
}

/* Chat Window */
.llm-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.llm-chat-window.llm-chat-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Chat Header */
.llm-chat-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--tcvelik-primary, #6000C9) 0%, var(--tcvelik-primary-light, #8B2BE2) 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.llm-chat-header h5 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.llm-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.llm-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Container */
.llm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.llm-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.llm-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.llm-chat-messages::-webkit-scrollbar-thumb {
    background: var(--tcvelik-primary, #6000C9);
    border-radius: 3px;
}

.llm-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--tcvelik-primary-light, #8B2BE2);
}

/* Message Styles */
.llm-chat-message {
    display: flex;
    margin-bottom: 8px;
}

.llm-chat-message-user {
    justify-content: flex-end;
}

.llm-chat-message-bot {
    justify-content: flex-start;
}

.llm-chat-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
}

.llm-chat-message-user .llm-chat-message-content {
    background: linear-gradient(135deg, var(--tcvelik-primary, #6000C9) 0%, var(--tcvelik-primary-light, #8B2BE2) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.llm-chat-message-bot .llm-chat-message-content {
    background: #f1f3f5;
    color: #212529;
    border-bottom-left-radius: 4px;
}

.llm-chat-message-loading .llm-chat-message-content {
    background: #f1f3f5;
    color: #6c757d;
    font-style: italic;
}

.llm-chat-message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.llm-chat-message-user .llm-chat-message-content code {
    background: rgba(255, 255, 255, 0.2);
}

/* Input Container */
.llm-chat-input-container {
    padding: 16px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #f8f9fa;
    border-radius: 0 0 16px 16px;
}

.llm-chat-input {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    line-height: 1.5;
}

.llm-chat-input:focus {
    outline: none;
    border-color: var(--tcvelik-primary, #6000C9);
    box-shadow: 0 0 0 3px rgba(96, 0, 201, 0.1);
}

.llm-chat-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--tcvelik-primary, #6000C9) 0%, var(--tcvelik-primary-light, #8B2BE2) 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.llm-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(96, 0, 201, 0.4);
}

.llm-chat-send:active {
    transform: scale(0.95);
}

/* Preview Section Styles */
.llm-preview-container {
    position: relative;
    margin: 40px 0;
    padding: 20px 0;
    border-top: 3px dashed var(--tcvelik-primary, #6000C9);
    border-bottom: 3px dashed var(--tcvelik-primary, #6000C9);
    background: linear-gradient(to bottom, rgba(96, 0, 201, 0.05), rgba(139, 43, 226, 0.05));
}

.llm-preview-container::before {
    content: '👁️ Preview';
    position: absolute;
    top: -15px;
    left: 20px;
    background: linear-gradient(135deg, var(--tcvelik-primary, #6000C9) 0%, var(--tcvelik-primary-light, #8B2BE2) 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(96, 0, 201, 0.3);
}

.llm-preview-content {
    animation: fadeIn 0.5s ease-in;
}

.llm-preview-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    gap: 12px;
}

.llm-preview-accept-btn {
    background: linear-gradient(135deg, var(--tcvelik-primary, #6000C9) 0%, var(--tcvelik-primary-light, #8B2BE2) 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(96, 0, 201, 0.3);
}

.llm-preview-accept-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(96, 0, 201, 0.5);
}

.llm-preview-accept-btn:active:not(:disabled) {
    transform: translateY(0);
}

.llm-preview-accept-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.llm-preview-accept-btn i {
    font-size: 14px;
}

.llm-preview-delete-btn {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.llm-preview-delete-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(220, 53, 69, 0.5);
}

.llm-preview-delete-btn:active:not(:disabled) {
    transform: translateY(0);
}

.llm-preview-delete-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.llm-preview-delete-btn i {
    font-size: 14px;
}

/* Section Edit Button */
.llm-editable-section {
    position: relative;
}

.llm-section-edit-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, var(--tcvelik-primary, #6000C9) 0%, var(--tcvelik-primary-light, #8B2BE2) 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(96, 0, 201, 0.3);
    z-index: 1000;
}

.llm-section-edit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(96, 0, 201, 0.5);
}

.llm-section-edit-btn i {
    font-size: 12px;
}

/* Edit Mode Styles */
.llm-preview-edit-mode .llm-preview-content[contenteditable="true"] {
    padding: 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
}

.llm-preview-edit-mode .llm-preview-content[contenteditable="true"]:focus {
    outline: 2px solid var(--tcvelik-primary, #6000C9);
    outline-offset: 2px;
    background: white;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Node Browser Overlay */
.llm-node-browser-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    animation: fadeIn 0.3s ease;
}

/* Node Browser Styles */
.llm-node-browser {
    background: white;
    border: 2px solid var(--tcvelik-primary, #6000C9);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.llm-node-browser-header {
    background: linear-gradient(135deg, var(--tcvelik-primary, #6000C9) 0%, var(--tcvelik-primary-light, #8B2BE2) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.llm-node-browser-header h6 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.llm-node-browser-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.llm-node-browser-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.llm-node-browser-content {
    flex: 1;
    max-height: 50vh;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    min-height: 200px;
}

.llm-node-browser-content::-webkit-scrollbar {
    width: 6px;
}

.llm-node-browser-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.llm-node-browser-content::-webkit-scrollbar-thumb {
    background: var(--tcvelik-primary, #6000C9);
    border-radius: 3px;
}

.llm-node-browser-loading,
.llm-node-browser-error,
.llm-node-browser-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.llm-node-tree {
    font-size: 14px;
}

.llm-node-item {
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s ease;
    user-select: none;
}

.llm-node-item:hover {
    background: rgba(96, 0, 201, 0.1);
}

.llm-node-item.selected {
    background: linear-gradient(135deg, rgba(96, 0, 201, 0.2) 0%, rgba(139, 43, 226, 0.2) 100%);
    border: 2px solid var(--tcvelik-primary, #6000C9);
}

.llm-node-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.llm-node-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6c757d;
    transition: color 0.2s ease;
}

.llm-node-toggle:hover {
    color: var(--tcvelik-primary, #6000C9);
}

.llm-node-toggle-placeholder {
    width: 20px;
    height: 20px;
}

.llm-node-icon {
    color: var(--tcvelik-primary, #6000C9);
    font-size: 14px;
}

.llm-node-name {
    font-weight: 500;
    color: #212529;
    flex: 1;
}

.llm-node-type {
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

.llm-node-children {
    margin-top: 4px;
}

.llm-node-browser-footer {
    padding: 16px 20px;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: white;
}

.llm-node-browser-cancel,
.llm-node-browser-select {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.llm-node-browser-cancel {
    background: #e9ecef;
    color: #495057;
}

.llm-node-browser-cancel:hover {
    background: #dee2e6;
}

.llm-node-browser-select {
    background: linear-gradient(135deg, var(--tcvelik-primary, #6000C9) 0%, var(--tcvelik-primary-light, #8B2BE2) 100%);
    color: white;
}

.llm-node-browser-select:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(96, 0, 201, 0.3);
}

.llm-node-browser-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Page Form Modal */
.llm-page-form-modal {
    background: white;
    border: 2px solid var(--tcvelik-primary, #6000C9);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.llm-page-form-header {
    background: linear-gradient(135deg, var(--tcvelik-primary, #6000C9) 0%, var(--tcvelik-primary-light, #8B2BE2) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.llm-page-form-header h6 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.llm-page-form-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.llm-page-form-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.llm-page-form-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.llm-page-form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.llm-page-form-field label {
    font-weight: 600;
    color: #212529;
    font-size: 14px;
}

.llm-page-form-field .required {
    color: #dc3545;
}

.llm-page-form-input,
.llm-page-form-textarea {
    padding: 12px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.llm-page-form-input:focus,
.llm-page-form-textarea:focus {
    outline: none;
    border-color: var(--tcvelik-primary, #6000C9);
    box-shadow: 0 0 0 3px rgba(96, 0, 201, 0.1);
}

.llm-page-form-textarea {
    resize: vertical;
    min-height: 80px;
}

.llm-page-form-error {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.llm-page-form-error::before {
    content: '⚠️';
    font-size: 18px;
}

.llm-page-form-footer {
    padding: 16px 20px;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: white;
}

.llm-page-form-cancel,
.llm-page-form-submit {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.llm-page-form-cancel {
    background: #e9ecef;
    color: #495057;
}

.llm-page-form-cancel:hover {
    background: #dee2e6;
}

.llm-page-form-submit {
    background: linear-gradient(135deg, var(--tcvelik-primary, #6000C9) 0%, var(--tcvelik-primary-light, #8B2BE2) 100%);
    color: white;
}

.llm-page-form-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(96, 0, 201, 0.3);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .llm-chat-window {
        width: calc(100vw - 20px);
        right: -10px;
        bottom: 90px;
    }
    
    #llm-chat-container {
        right: 10px;
        bottom: 10px;
    }

    .llm-node-browser {
        width: 95%;
        max-height: 90vh;
    }

    .llm-node-browser-content {
        max-height: 60vh;
    }

    .llm-page-form-modal {
        width: 95%;
    }
}
