/* =========================================
   AUTOMATION SIDEBAR STYLES
   ========================================= */

.template-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.05);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.template-sidebar.visible {
    transform: translateX(0);
}

/* Header */
.automation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #0f172a;
}

.header-title h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.header-title svg {
    color: #3b82f6;
}

.exit-btn {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
    transition: all 0.2s;
}

.exit-btn:hover {
    background: #f1f5f9;
    color: #ef4444;
}

/* Workflow Section (Main Content) */
.workflow-section {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.step-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Empty State */
.workflow-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #94a3b8;
    background: white;
    border-radius: 12px;
    border: 2px dashed #e2e8f0;
    margin-bottom: 16px;
}

.empty-state-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.workflow-empty p {
    margin: 0;
    font-size: 14px;
}

/* Step Card */
.step-card {
    background: white;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.step-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.step-card.selected {
    border-color: #3b82f6;
    ring: 2px solid rgba(59, 130, 246, 0.1);
}

.step-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    background: white;
}

.step-number {
    width: 24px;
    height: 24px;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    margin-right: 12px;
}

.step-card.selected .step-number {
    background: #3b82f6;
    color: white;
}

.step-icon {
    font-size: 16px;
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.step-info {
    flex: 1;
    min-width: 0;
}

.step-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 2px;
}

.step-summary {
    display: block;
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.step-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.step-card:hover .step-actions {
    opacity: 1;
}

.step-config-btn,
.step-delete-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: #94a3b8;
    transition: all 0.15s;
}

.step-config-btn:hover {
    color: #3b82f6;
    background: #eff6ff;
}

.step-delete-btn:hover {
    color: #ef4444;
    background: #fef2f2;
}

/* Step Config Panel */
.step-config-panel {
    border-top: 1px solid #f1f5f9;
    padding: 16px;
    background: #f8fafc;
}

.config-group {
    margin-bottom: 12px;
}

.config-group:last-child {
    margin-bottom: 0;
}

.config-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 6px;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.config-row:last-child {
    margin-bottom: 0;
}

.config-group input[type="text"],
.config-group input[type="number"],
.config-group input[type="password"],
.config-group select,
.config-textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #334155;
    background: white;
    transition: border-color 0.2s;
}

.config-textarea {
    min-height: 60px;
    resize: vertical;
    font-family: inherit;
}

.config-group input:focus,
.config-group select:focus,
.config-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.config-hint {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

/* Add Step Button & Menu */
.add-step-wrapper {
    position: relative;
    margin-top: auto;
}

.add-step-btn {
    width: 100%;
    background: #3b82f6;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.add-step-btn:hover {
    background: #2563eb;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
}

.plus-icon {
    font-size: 18px;
    font-weight: 300;
}

.add-step-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    padding: 8px;
    display: none;
    z-index: 2001;
    max-height: 400px;
    overflow-y: auto;
}

.add-step-menu.visible {
    display: block;
    animation: menuSlideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.menu-category {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.menu-category:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.menu-category-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 4px 8px;
    margin-bottom: 4px;
    letter-spacing: 0.05em;
}

.add-step-menu button {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #334155;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.add-step-menu button:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* Footer Section */
.automation-footer {
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

/* Data Source Toggle */
.data-source-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
}

.data-source-toggle:hover {
    background: #f8fafc;
}

.toggle-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-header .icon {
    font-size: 16px;
}

.toggle-header .label {
    font-size: 14px;
    font-weight: 500;
    color: #334155;
}

.status-badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    background: #f1f5f9;
    color: #64748b;
    font-weight: 500;
}

.status-badge.success {
    background: #dcfce7;
    color: #166534;
}

.collapse-icon {
    font-size: 10px;
    color: #94a3b8;
    transition: transform 0.2s;
}

.data-config-panel.collapsed + .data-source-toggle .collapse-icon {
    transform: rotate(-90deg);
}

/* Data Config Panel */
.data-config-panel {
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.data-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.data-actions {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.csv-upload-btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: #475569;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.csv-upload-btn-small:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.clear-data-btn-small {
    padding: 6px 12px;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: #ef4444;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-data-btn-small:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

/* Preview Section */
.preview-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.preview-navigator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 4px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.preview-navigator button {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #64748b;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.preview-navigator button:hover:not(:disabled) {
    background: #f1f5f9;
    color: #0f172a;
}

.preview-navigator button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.row-indicator {
    font-size: 12px;
    font-weight: 500;
    color: #334155;
    font-variant-numeric: tabular-nums;
}

/* Output Settings */
.output-settings {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filename-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #334155;
    background: #f8fafc;
}

.filename-input:focus {
    background: white;
    border-color: #3b82f6;
    outline: none;
}

.output-mode-row {
    display: flex;
    gap: 16px;
}

.output-mode-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
}

.output-mode-row input[type="radio"] {
    margin: 0;
    cursor: pointer;
    accent-color: #3b82f6;
}

/* Generate Button */
.action-buttons {
    padding: 0 20px 20px;
}

.generate-btn {
    width: 100%;
    background: #10b981;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.generate-btn:hover {
    background: #059669;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}

.generate-btn:active {
    transform: translateY(0);
}

.generate-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Variable Chips/Dropdowns */
.insert-var-wrapper {
    margin-top: 8px;
    position: relative;
}

.insert-var-btn {
    background: transparent;
    border: 1px dashed #cbd5e1;
    color: #64748b;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}

.insert-var-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #eff6ff;
}

.variable-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 10;
    min-width: 150px;
    display: none;
    max-height: 200px;
    overflow-y: auto;
}

.variable-dropdown.visible {
    display: block;
}

.var-option {
    padding: 6px 12px;
    font-size: 12px;
    color: #334155;
    cursor: pointer;
}

.var-option:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.variable-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.var-chip {
    background: #eff6ff;
    color: #3b82f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
    cursor: pointer;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.var-chip:hover {
    background: #dbeafe;
    border-color: rgba(59, 130, 246, 0.4);
}

/* Pending Action Banner */
.automation-pending-action {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #1e293b;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 3000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.automation-pending-action.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.automation-pending-action .cancel-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.automation-pending-action .cancel-btn:hover {
    background: rgba(255,255,255,0.2);
}

.automation-element {
    position: absolute;
    border: 2px dashed #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    pointer-events: auto;
    z-index: 100;
    cursor: move;
}

.automation-element.step-selected {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    z-index: 101;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.automation-element::after {
    content: attr(data-step-number);
    position: absolute;
    top: -10px;
    left: -10px;
    width: 20px;
    height: 20px;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.automation-element.step-selected::after {
    background: #f59e0b;
    transform: scale(1.2);
}

/* Progress Overlay */
.template-progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.template-progress-modal {
    background: white;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.template-progress-modal h3 {
    margin: 0 0 20px;
    color: #1e293b;
    font-size: 18px;
}

.template-progress-bar {
    width: 100%;
    height: 8px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.template-progress-bar-fill {
    height: 100%;
    background: #3b82f6;
    transition: width 0.3s ease;
}

.template-progress-text {
    font-size: 14px;
    color: #64748b;
}