/**
 * AutomationEditor Styles
 * 
 * Full-screen editor with form on left and actions panel on right
 */

/* Used when AutomationEditor had custom overlay - kept for reference, Popup is used now */
.editorOverlay {
    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: 1000;
    padding: 1rem;
}

/* Popup customisation for fullscreen editor - fill content area */
.editorPopup :global([class*="content"]) {
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.editorContainer {
    background: var(--surface-color, #ffffff);
    border-radius: 12px;
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.editorHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    background: var(--bg-primary, #ffffff);
    flex-shrink: 0;
}

.headerLeft {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.editorTitle {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #333);
    margin: 0;
}

.modeBadge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.modeBadge.template {
    background: var(--info-bg, #e3f2fd);
    color: var(--info-color, #1976d2);
}

.modeBadge.definition {
    background: var(--success-bg, #e8f5e9);
    color: var(--success-color, #388e3c);
}

.headerActions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.closeButton {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary, #666);
    font-size: 1.125rem;
    transition: all 0.2s;
}

.closeButton:hover {
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-primary, #333);
}

/* Main Content Area */
.editorContent {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Form Panel (Left Side) */
.formPanel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-right: 1px solid var(--border-color, #e0e0e0);
}

.formPanelHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary, #f5f5f5);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    flex-shrink: 0;
}

.formPanelTitle {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary, #666);
    margin: 0;
}

.formPanelContent {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Actions Panel (Right Side) */
.actionsPanel {
    width: 400px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary, #f8f9fa);
}

.actionsPanelCollapsed {
    width: 48px;
}

.actionsPanelToggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-secondary, #f5f5f5);
    border: none;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    cursor: pointer;
    color: var(--text-secondary, #666);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    flex-shrink: 0;
}

.actionsPanelToggle:hover {
    background: var(--bg-hover, #e8e8e8);
    color: var(--text-primary, #333);
}

.actionsPanelToggle svg {
    margin-right: 0.5rem;
}

.actionsPanelCollapsed .actionsPanelToggle {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 1rem 0.75rem;
    height: 100%;
}

.actionsPanelCollapsed .actionsPanelToggle svg {
    margin-right: 0;
    margin-bottom: 0.5rem;
    transform: rotate(90deg);
}

.actionsPanelContainer {
    flex: 1;
    overflow: hidden;
}

/* Footer */
.editorFooter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color, #e0e0e0);
    background: var(--bg-primary, #ffffff);
    flex-shrink: 0;
}

.footerLeft {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.footerRight {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Buttons */
.primaryButton {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--primary-color, #f25843);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.primaryButton:hover:not(:disabled) {
    background: var(--primary-dark, #d94d3a);
}

.primaryButton:active:not(:disabled) {
    transform: scale(0.98);
}

.primaryButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.secondaryButton {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--surface-color, #ffffff);
    color: var(--text-primary, #333);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.secondaryButton:hover:not(:disabled) {
    background: var(--bg-secondary, #f5f5f5);
    border-color: var(--text-secondary, #666);
}

.secondaryButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.dangerButton {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--danger-color, #dc3545);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.dangerButton:hover:not(:disabled) {
    background: var(--danger-dark, #c82333);
}

/* JSON Editor Section */
.jsonEditorSection {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

.jsonEditorHeader {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.jsonEditorLabelRow {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.jsonEditorLabel {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary, #333);
}

.jsonEditorHint {
    font-size: 0.75rem;
    color: var(--text-tertiary, #999);
}

.formatButton {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-secondary, #666);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.formatButton:hover {
    background: var(--primary-color, #f25843);
    color: white;
    border-color: var(--primary-color, #f25843);
}

.jsonTextarea {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    background: var(--bg-code, #1e1e1e);
    color: var(--text-code, #d4d4d4);
    resize: vertical;
    tab-size: 2;
}

.jsonTextarea:focus {
    outline: none;
    border-color: var(--primary-color, #f25843);
    box-shadow: 0 0 0 3px rgba(242, 88, 67, 0.1);
}

.jsonTextarea.error {
    border-color: var(--danger-color, #dc3545);
}

.jsonError {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--danger-bg, #fef2f2);
    color: var(--danger-color, #dc3545);
    border-radius: 4px;
    font-size: 0.8125rem;
}

/* Placeholders Section */
.placeholdersSection {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

.placeholdersHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.placeholdersTitle {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary, #333);
}

.placeholdersHint {
    font-size: 0.75rem;
    color: var(--text-tertiary, #999);
}

.placeholdersList {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.placeholderItem {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 6px;
}

.placeholderKeyRow {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.placeholderKey {
    padding: 0.375rem 0.625rem;
    background: var(--bg-code, #e9ecef);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary, #333);
}

.placeholderDescription {
    font-size: 0.75rem;
    color: var(--text-secondary, #666);
    flex: 1;
}

.placeholderType {
    padding: 0.25rem 0.5rem;
    background: var(--info-bg, #e3f2fd);
    color: var(--info-color, #1976d2);
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
}

.placeholderError {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--error-bg, #ffebee);
    color: var(--error-color, #c62828);
    border: 1px solid var(--error-border, #ef9a9a);
    border-radius: 6px;
    font-size: 0.8125rem;
}

.placeholderError svg {
    flex-shrink: 0;
}

.sharepointFolderInput {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sharepointFolderHint {
    font-size: 0.75rem;
    color: var(--text-secondary, #666);
    font-style: italic;
}

/* SharePoint Folder Picker */
.sharepointFolderPicker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sharepointFolderHeader {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.sharepointFolderHeader .placeholderInput {
    flex: 1;
}

.sharepointBrowseButton {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: var(--secondary-button-bg, #f0f0f0);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary, #333);
    white-space: nowrap;
    transition: background-color 0.15s;
}

.sharepointBrowseButton:hover {
    background: var(--secondary-button-hover-bg, #e0e0e0);
}

.sharepointFolderBrowser {
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    padding: 1rem;
    background: var(--bg-secondary, #fafafa);
}

.sharepointError {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--danger-bg, #fff0f0);
    color: var(--danger-color, #d32f2f);
    border-radius: 4px;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.sharepointSection {
    margin-bottom: 1rem;
}

.sharepointSection:last-child {
    margin-bottom: 0;
}

.sharepointSection label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #666);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.sharepointLoading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    color: var(--text-secondary, #666);
    font-size: 0.875rem;
}

.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.sharepointSelect {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--bg-primary, white);
    cursor: pointer;
}

.sharepointSelect:focus {
    outline: none;
    border-color: var(--primary-color, #1976d2);
}

.sharepointBreadcrumb {
    font-size: 0.75rem;
    color: var(--text-secondary, #666);
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.sharepointFolderList {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 4px;
    background: var(--bg-primary, white);
}

.sharepointFolderItem {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
    transition: background-color 0.1s;
}

.sharepointFolderItem:last-child {
    border-bottom: none;
}

.sharepointFolderItem:hover {
    background: var(--bg-hover, #f5f5f5);
}

.sharepointFolderItem .folderName {
    flex: 1;
    cursor: pointer;
}

.sharepointFolderItem .folderName:hover {
    text-decoration: underline;
}

.selectFolderButton {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: var(--primary-color, #1976d2);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

.sharepointFolderItem:hover .selectFolderButton {
    opacity: 1;
}

.selectFolderButton:hover {
    background: var(--primary-hover, #1565c0);
}

.sharepointEmpty {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary, #666);
    font-size: 0.875rem;
    font-style: italic;
}

.selectCurrentFolderButton {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--success-color, #2e7d32);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.15s;
}

.selectCurrentFolderButton:hover {
    background: var(--success-hover, #1b5e20);
}

.placeholderInput {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #333);
}

.placeholderInput:focus {
    outline: none;
    border-color: var(--primary-color, #f25843);
}

.placeholderSelect {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #333);
    cursor: pointer;
}

.placeholderSelect:focus {
    outline: none;
    border-color: var(--primary-color, #f25843);
}

.placeholderSelect:disabled {
    background: var(--bg-secondary, #f5f5f5);
    cursor: not-allowed;
}

.placeholderTextarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #333);
    resize: vertical;
    min-height: 60px;
}

.placeholderTextarea:focus {
    outline: none;
    border-color: var(--primary-color, #f25843);
}

.placeholderCheckbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-primary, #333);
    cursor: pointer;
}

.placeholderCheckbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color, #f25843);
    cursor: pointer;
}

.noPlaceholders {
    padding: 1rem;
    text-align: center;
    color: var(--text-tertiary, #999);
    font-size: 0.875rem;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 6px;
}

/* Form Fields */
.formFields {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.formGroup {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.formLabel {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary, #333);
}

.formLabel .required {
    color: var(--danger-color, #dc3545);
}

.formInput {
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #333);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.formInput:focus {
    outline: none;
    border-color: var(--primary-color, #f25843);
    box-shadow: 0 0 0 3px rgba(242, 88, 67, 0.1);
}

.formTextarea {
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #333);
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.formTextarea:focus {
    outline: none;
    border-color: var(--primary-color, #f25843);
    box-shadow: 0 0 0 3px rgba(242, 88, 67, 0.1);
}

.formHint {
    font-size: 0.75rem;
    color: var(--text-tertiary, #999);
    margin: 0;
}

.checkboxLabel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary, #333);
    cursor: pointer;
}

.checkboxLabel input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color, #f25843);
    cursor: pointer;
}

/* Language Tabs */
.languageTabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    padding-bottom: 0.5rem;
}

.languageTab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary, #666);
    cursor: pointer;
    transition: all 0.2s;
}

.languageTab:hover {
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-primary, #333);
}

.languageTab.active {
    background: var(--bg-primary, #ffffff);
    border-color: var(--border-color, #e0e0e0);
    color: var(--primary-color, #f25843);
    border-bottom: 2px solid var(--primary-color, #f25843);
    margin-bottom: -1px;
}

/* Loading State */
.loadingState {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary, #666);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, #e0e0e0);
    border-top-color: var(--primary-color, #f25843);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Responsive */
@media (max-width: 1200px) {
    .actionsPanel {
        width: 350px;
    }
}

@media (max-width: 900px) {
    .editorContent {
        flex-direction: column;
    }
    
    .formPanel {
        border-right: none;
        border-bottom: 1px solid var(--border-color, #e0e0e0);
    }
    
    .actionsPanel {
        width: 100%;
        height: 300px;
    }
    
    .actionsPanelCollapsed {
        width: 100%;
        height: 48px;
    }
    
    .actionsPanelCollapsed .actionsPanelToggle {
        writing-mode: horizontal-tb;
        text-orientation: mixed;
        padding: 0.75rem;
        height: auto;
    }
    
    .actionsPanelCollapsed .actionsPanelToggle svg {
        margin-bottom: 0;
        margin-right: 0.5rem;
        transform: none;
    }
}
