/* ==========================================================================
   MxChat Actions Page Styles - v2.0
   Uses admin-sidebar.css for core layout/navigation styles
   ========================================================================== */

/* ==========================================================================
   Override parent content padding for split panel view
   ========================================================================== */
.mxch-content:has(#all-actions.mxch-section.active) {
    padding: 0 !important;
    overflow: hidden;
}

#all-actions.mxch-section {
    padding: 0;
    margin: 0;
    height: calc(100vh - 32px); /* Account for WP admin bar */
    overflow: hidden;
}

/* Ensure the admin wrapper fills the viewport */
.mxch-actions-wrapper .mxch-content {
    height: calc(100vh - 32px);
    overflow: hidden;
}

.mxch-actions-wrapper {
    height: calc(100vh - 32px);
}

/* ==========================================================================
   Stats Grid
   ========================================================================== */
.mxch-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--mxch-spacing-lg);
    margin-bottom: var(--mxch-spacing-xl);
}

.mxch-stat-card {
    background: var(--mxch-card-bg);
    border: 1px solid var(--mxch-card-border);
    border-radius: var(--mxch-radius-lg);
    padding: var(--mxch-spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--mxch-spacing-md);
    transition: all var(--mxch-transition);
}

.mxch-stat-card:hover {
    box-shadow: var(--mxch-card-shadow-hover);
    transform: translateY(-2px);
}

.mxch-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--mxch-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mxch-stat-icon svg {
    width: 24px;
    height: 24px;
}

.mxch-stat-icon-primary {
    background: rgba(120, 115, 245, 0.1);
    color: var(--mxch-primary);
}

.mxch-stat-icon-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--mxch-success);
}

.mxch-stat-icon-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--mxch-info);
}

.mxch-stat-icon-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--mxch-warning);
}

.mxch-stat-content {
    display: flex;
    flex-direction: column;
}

.mxch-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--mxch-text-primary);
    line-height: 1.2;
}

.mxch-stat-label {
    font-size: 13px;
    color: var(--mxch-text-secondary);
    margin-top: 2px;
}

/* ==========================================================================
   Quick Actions
   ========================================================================== */
.mxch-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--mxch-spacing-md);
}

.mxch-quick-action-btn {
    display: flex;
    align-items: center;
    gap: var(--mxch-spacing-sm);
    padding: var(--mxch-spacing-md) var(--mxch-spacing-lg);
    background: #f8fafc;
    border: 1px solid var(--mxch-card-border);
    border-radius: var(--mxch-radius-md);
    color: var(--mxch-text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--mxch-transition-fast);
}

.mxch-quick-action-btn:hover {
    background: var(--mxch-primary);
    border-color: var(--mxch-primary);
    color: white;
}

.mxch-quick-action-btn svg {
    flex-shrink: 0;
}

/* ==========================================================================
   Info Section - What are Actions
   ========================================================================== */
.mxch-info-section {
    background: var(--mxch-card-bg);
    border: 1px solid var(--mxch-card-border);
    border-radius: var(--mxch-radius-lg);
    padding: var(--mxch-spacing-lg);
    margin-top: var(--mxch-spacing-lg);
}

.mxch-info-section-header {
    display: flex;
    align-items: center;
    gap: var(--mxch-spacing-sm);
    margin-bottom: var(--mxch-spacing-md);
}

.mxch-info-section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--mxch-primary);
    border-radius: 10px;
    color: white;
    flex-shrink: 0;
}

.mxch-info-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--mxch-text-primary);
    margin: 0;
}

.mxch-info-section-desc {
    font-size: 14px;
    line-height: 1.7;
    color: var(--mxch-text-secondary);
    margin: 0 0 var(--mxch-spacing-lg) 0;
}

.mxch-info-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--mxch-spacing-md);
}

.mxch-info-feature {
    display: flex;
    gap: var(--mxch-spacing-sm);
    padding: var(--mxch-spacing-md);
    background: #f9fafb;
    border: 1px solid var(--mxch-card-border);
    border-radius: var(--mxch-radius-md);
}

.mxch-info-feature-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--mxch-primary);
    border-radius: 8px;
    color: white;
    flex-shrink: 0;
}

.mxch-info-feature-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mxch-info-feature-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--mxch-text-primary);
}

.mxch-info-feature-desc {
    font-size: 12px;
    color: var(--mxch-text-secondary);
    line-height: 1.5;
}

/* ==========================================================================
   Empty Text
   ========================================================================== */
.mxch-empty-text {
    font-size: 13px;
    color: var(--mxch-text-secondary);
    text-align: center;
    padding: var(--mxch-spacing-md);
    margin: 0;
    background: rgba(120, 115, 245, 0.1);
    padding: 2px 10px;
    border-radius: 12px;
}

.mxch-empty-text {
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

/* ==========================================================================
   Split Panel Layout - Action List + Editor
   ========================================================================== */
.mxch-split-panel {
    display: flex;
    height: 100%;
    background: #fff;
    border: none;
    border-radius: 0;
    overflow: hidden;
}

/* Left Panel - Action List */
.mxch-action-list-panel {
    width: 360px;
    min-width: 300px;
    max-width: 440px;
    display: flex;
    height: 100%;
    overflow: hidden;
    flex-direction: column;
    border-right: 1px solid #e5e7eb;
    background: #fff;
}

/* Bulk Actions Toolbar */
.mxch-bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}

.mxch-bulk-select-all {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
}

.mxch-bulk-select-all input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #3b82f6;
}

.mxch-bulk-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.mxch-bulk-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}

.mxch-bulk-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.mxch-bulk-btn.mxch-bulk-delete {
    color: #dc2626;
    border-color: #fecaca;
}

.mxch-bulk-btn.mxch-bulk-delete:hover {
    background: #fef2f2;
    border-color: #fca5a5;
}

.mxch-bulk-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mxch-filter-select {
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    cursor: pointer;
    max-width: 140px;
}

.mxch-selected-count {
    font-size: 11px;
    color: #3b82f6;
    font-weight: 600;
    padding: 2px 8px;
    background: #eff6ff;
    border-radius: 10px;
    display: none;
}

.mxch-selected-count.has-selection {
    display: inline-block;
}

.mxch-panel-header {
    padding: 0;
    border-bottom: 1px solid #e5e7eb;
}

.mxch-panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
}

.mxch-panel-count {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.mxch-panel-actions {
    display: flex;
    gap: 4px;
}

.mxch-icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #6b7280;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.mxch-icon-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.mxch-btn-danger-icon:hover {
    background: #fef2f2;
    color: #dc2626;
}

.mxch-icon-btn.spinning svg {
    animation: spin 0.5s linear;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Search */
.mxch-search-wrapper {
    position: relative;
    background: #fff;
}

.mxch-search-wrapper svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    width: 14px;
    height: 14px;
    z-index: 1;
}

.mxch-search-input {
    width: 100%;
    padding: 10px 12px 10px 34px;
    border: none;
    border-radius: 0;
    font-size: 13px;
    background: #fff;
    transition: all 0.15s;
    box-sizing: border-box;
}

.mxch-search-input:focus {
    outline: none;
    background: #fff;
    box-shadow: none;
}

.mxch-search-input::placeholder {
    color: #9ca3af;
}

/* Action List */
.mxch-action-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* Important for flex children to allow scroll */
}

.mxch-action-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
    position: relative;
}

.mxch-action-item:hover {
    background: #f9fafb;
}

.mxch-action-item.active {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    border-left: 3px solid var(--mxch-primary);
    padding-left: 9px;
}

.mxch-action-item.selected {
    background: #f5f3ff;
}

.mxch-action-item.disabled {
    opacity: 0.6;
}

/* Checkbox for action items */
.mxch-action-checkbox {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--mxch-primary);
    opacity: 0;
    transition: opacity 0.15s;
}

.mxch-action-item:hover .mxch-action-checkbox,
.mxch-action-item.selected .mxch-action-checkbox,
.mxch-action-list.selection-mode .mxch-action-checkbox {
    opacity: 1;
}

.mxch-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(120, 115, 245, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mxch-action-icon .dashicons {
    color: var(--mxch-primary);
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.mxch-action-info {
    flex: 1;
    min-width: 0;
}

.mxch-action-name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mxch-action-type-label {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.mxch-action-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.mxch-action-status {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.mxch-action-status.enabled {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.mxch-action-status.disabled {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
}

.mxch-list-loading,
.mxch-list-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 13px;
}

.mxch-panel-footer {
    padding: 8px 12px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.mxch-pagination-btns {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mxch-page-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #374151;
    transition: all 0.15s;
}

.mxch-page-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.mxch-page-info {
    font-size: 12px;
    color: #6b7280;
}

/* ==========================================================================
   Right Panel - Action Details/Editor
   ========================================================================== */
.mxch-action-detail-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f9fafb;
    overflow: hidden;
    height: 100%;
    min-height: 0;
}

/* Empty State */
.mxch-action-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    text-align: center;
    padding: 40px;
}

.mxch-empty-icon {
    margin-bottom: 16px;
    opacity: 0.5;
}

.mxch-action-empty h3 {
    font-size: 16px;
    font-weight: 600;
    color: #6b7280;
    margin: 0 0 8px 0;
}

.mxch-action-empty p {
    font-size: 13px;
    margin: 0 0 20px 0;
}

/* ==========================================================================
   Editor Steps
   ========================================================================== */
.mxch-action-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    min-height: 0;
}

.mxch-editor-step {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    min-height: 0;
}

.mxch-editor-step.active {
    display: flex;
}

.mxch-editor-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.mxch-editor-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.mxch-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mxch-editor-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #6b7280;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.mxch-editor-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.mxch-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    border: none;
    color: var(--mxch-primary);
    cursor: pointer;
    transition: all 0.15s;
}

.mxch-back-btn:hover {
    color: #6366f1;
}

/* Type Search & Categories */
.mxch-type-search {
    position: relative;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.mxch-type-search svg {
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.mxch-type-search input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: #f9fafb;
    transition: all 0.15s;
}

.mxch-type-search input:focus {
    outline: none;
    border-color: var(--mxch-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.1);
}

.mxch-type-categories {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
}

.mxch-category-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    background: #f3f4f6;
    border: 1px solid transparent;
    border-radius: 20px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
}

.mxch-category-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.mxch-category-btn.active {
    background: var(--mxch-primary);
    color: #fff;
}

/* Types Grid */
.mxch-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    align-content: start;
    min-height: 0;
}

.mxch-type-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.mxch-type-card:hover {
    border-color: var(--mxch-primary);
    box-shadow: 0 4px 12px rgba(120, 115, 245, 0.1);
    transform: translateY(-2px);
}

.mxch-type-card.selected {
    border-color: var(--mxch-primary);
    background: #f5f3ff;
}

.mxch-type-card.mxch-type-pro {
    opacity: 0.7;
}

.mxch-type-card.mxch-type-addon {
    opacity: 0.7;
}

.mxch-type-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(120, 115, 245, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mxch-type-icon .dashicons {
    color: var(--mxch-primary);
    font-size: 22px;
    width: 22px;
    height: 22px;
}

.mxch-type-pro .mxch-type-icon {
    background: linear-gradient(135deg, #7873f5, #fa73e6);
}

.mxch-type-pro .mxch-type-icon .dashicons {
    color: #fff;
}

.mxch-type-info {
    flex: 1;
    min-width: 0;
}

.mxch-type-info h4 {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 4px 0;
}

.mxch-type-info p {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
    line-height: 1.4;
}

.mxch-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    margin-top: 6px;
}

.mxch-badge-pro {
    background: linear-gradient(135deg, #7873f5, #fa73e6);
    color: #fff;
}

.mxch-badge-addon {
    background: rgba(245, 158, 11, 0.1);
    color: #b45309;
}

/* ==========================================================================
   Step 2 - Configure Action
   ========================================================================== */
.mxch-selected-type {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: #f5f3ff;
    border-bottom: 1px solid #e5e7eb;
}

.mxch-selected-type-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(120, 115, 245, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mxch-selected-type-icon .dashicons {
    color: var(--mxch-primary);
    font-size: 22px;
    width: 22px;
    height: 22px;
}

.mxch-selected-type-info {
    flex: 1;
}

.mxch-selected-type-info h4 {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 4px 0;
}

.mxch-selected-type-info p {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

/* Form Styles */
#mxch-action-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    min-height: 0;
}

.mxch-form-group {
    margin-bottom: 20px;
}

.mxch-form-group label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.mxch-form-group input[type="text"],
.mxch-form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: #f9fafb;
    transition: all 0.15s;
    box-sizing: border-box;
}

.mxch-form-group input[type="text"]:focus,
.mxch-form-group textarea:focus {
    outline: none;
    border-color: var(--mxch-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(120, 115, 245, 0.1);
}

.mxch-form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.mxch-form-hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 6px;
}

/* Threshold Slider */
.mxch-threshold-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--mxch-primary);
    background: rgba(120, 115, 245, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
}

.mxch-form-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(120, 115, 245, 0.2);
    outline: none;
    -webkit-appearance: none;
    margin: 10px 0;
}

.mxch-form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7873f5, #fa73e6);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(120, 115, 245, 0.3);
}

.mxch-form-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7873f5, #fa73e6);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(120, 115, 245, 0.3);
}

/* Bot Selector */
.mxch-bot-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mxch-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    padding: 10px 14px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.15s;
}

.mxch-checkbox-label:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.mxch-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--mxch-primary);
    cursor: pointer;
}

/* Form Actions */
.mxch-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    margin-top: auto;
    border-top: 1px solid #e5e7eb;
}

/* ==========================================================================
   Action View (Viewing Details)
   ========================================================================== */
.mxch-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mxch-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.mxch-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.mxch-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d1d5db;
    transition: 0.3s;
    border-radius: 24px;
}

.mxch-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.mxch-toggle-switch input:checked + .mxch-toggle-slider {
    background: linear-gradient(135deg, #7873f5, #fa73e6);
}

.mxch-toggle-switch input:checked + .mxch-toggle-slider:before {
    transform: translateX(20px);
}

.mxch-action-details {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.mxch-detail-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 20px;
}

.mxch-detail-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: rgba(120, 115, 245, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mxch-detail-icon .dashicons {
    color: var(--mxch-primary);
    font-size: 26px;
    width: 26px;
    height: 26px;
}

.mxch-detail-content h4 {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 4px 0;
}

.mxch-detail-type {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

.mxch-detail-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.mxch-detail-section h5 {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
}

.mxch-phrases-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mxch-phrase-tag {
    display: inline-block;
    padding: 6px 12px;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 13px;
    color: #374151;
}

.mxch-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mxch-setting-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mxch-setting-label {
    font-size: 12px;
    color: #9ca3af;
}

.mxch-setting-value {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.mxch-setting-value.mxch-status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    width: fit-content;
}

.mxch-setting-value.mxch-status-enabled {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.mxch-setting-value.mxch-status-disabled {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
}

.mxch-bots-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mxch-bot-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(120, 115, 245, 0.1);
    border-radius: 6px;
    font-size: 13px;
    color: var(--mxch-primary);
    font-weight: 500;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.mxch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
}

.mxch-btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.mxch-btn-primary {
    background: linear-gradient(135deg, #7873f5, #8b5cf6);
    color: #fff;
}

.mxch-btn-primary:hover {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(120, 115, 245, 0.3);
}

.mxch-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.mxch-btn-secondary:hover {
    background: #e5e7eb;
}

.mxch-btn-danger {
    background: #dc2626;
    color: #fff;
}

.mxch-btn-danger:hover {
    background: #b91c1c;
}

/* ==========================================================================
   Loading & Modal
   ========================================================================== */
.mxch-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100001;
}

.mxch-loading-spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--mxch-primary);
    border-right-color: var(--mxch-primary);
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.mxch-loading-text {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

.mxch-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: 100000;
}

.mxch-modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.mxch-modal-sm {
    max-width: 400px;
}

.mxch-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.mxch-modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.mxch-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.15s;
}

.mxch-modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.mxch-modal-body {
    padding: 20px;
}

.mxch-modal-body p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

.mxch-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Mobile-first: Show list by default, hide detail panel until action selected */
@media screen and (max-width: 782px) {
    /* Remove viewport height constraints on mobile */
    #all-actions.mxch-section {
        height: auto;
        min-height: calc(100vh - 46px); /* WP admin bar is 46px on mobile */
        overflow: visible;
    }

    .mxch-actions-wrapper .mxch-content,
    .mxch-actions-wrapper {
        height: auto;
        overflow: visible;
    }

    .mxch-split-panel {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 46px);
        overflow: visible;
    }

    /* List panel takes full width and reasonable height */
    .mxch-action-list-panel {
        width: 100%;
        max-width: none;
        min-width: 0;
        height: auto;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        overflow: visible;
    }

    /* Action list scrolls within container */
    .mxch-action-list {
        max-height: 50vh;
        min-height: 200px;
        overflow-y: auto;
    }

    /* Detail panel hidden by default on mobile */
    .mxch-action-detail-panel {
        display: none;
        min-height: auto;
        height: auto;
    }

    /* When an action is selected, show detail panel */
    .mxch-action-detail-panel.mobile-active {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 46px; /* Below WP admin bar */
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        background: #f9fafb;
        height: auto;
    }

    /* Mobile back button */
    .mxch-mobile-back-btn {
        display: flex !important;
        align-items: center;
        gap: 6px;
        padding: 8px 12px;
        background: transparent;
        border: none;
        color: var(--mxch-primary);
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
    }

    .mxch-mobile-back-btn:hover {
        background: rgba(120, 115, 245, 0.1);
    }

    /* Adjust editor header for mobile */
    .mxch-editor-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .mxch-view-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px;
    }

    .mxch-view-header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* Stats grid */
    .mxch-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--mxch-spacing-md);
    }

    /* Type cards grid */
    .mxch-types-grid {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .mxch-type-card {
        padding: 12px;
    }

    /* Settings grid */
    .mxch-settings-grid {
        grid-template-columns: 1fr;
    }

    /* Form actions */
    .mxch-form-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .mxch-form-actions .mxch-btn {
        width: 100%;
    }

    /* Bulk toolbar adjustments */
    .mxch-bulk-toolbar {
        flex-wrap: wrap;
        padding: 8px;
    }

    .mxch-bulk-btn span {
        display: none;
    }

    .mxch-filter-select {
        flex: 1;
        min-width: 120px;
    }

    /* Action items tighter on mobile */
    .mxch-action-item {
        padding: 10px;
    }

    .mxch-action-icon {
        width: 36px;
        height: 36px;
    }

    .mxch-action-name {
        font-size: 13px;
    }

    .mxch-action-type-label {
        font-size: 11px;
    }

    /* Panel header adjustments */
    .mxch-panel-header {
        padding: 0;
    }

    .mxch-panel-title-row {
        padding: 8px 10px;
    }

    .mxch-search-input {
        padding: 8px 10px 8px 34px;
    }

    /* Form padding on mobile */
    #mxch-action-form {
        padding: 12px;
    }

    .mxch-action-details {
        padding: 12px;
    }

    /* Editor step content scrollable */
    .mxch-editor-step.active {
        overflow-y: auto;
    }

    /* Category buttons scroll horizontally */
    .mxch-category-btns {
        overflow-x: auto;
        padding: 12px;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .mxch-category-btn {
        flex-shrink: 0;
        padding: 6px 12px;
        font-size: 12px;
    }

    /* Hide close button on mobile (use back button instead) */
    .mxch-editor-close {
        display: none;
    }
}

/* Hide mobile back button on desktop */
.mxch-mobile-back-btn {
    display: none;
}

/* Prevent body scroll when mobile panel is open */
body.mxch-mobile-panel-open {
    overflow: hidden;
}

/* Tablet adjustments */
@media screen and (min-width: 783px) and (max-width: 1024px) {
    .mxch-split-panel {
        flex-direction: column;
    }

    .mxch-action-list-panel {
        width: 100%;
        max-width: none;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        max-height: 350px;
    }

    .mxch-action-detail-panel {
        flex: 1;
        min-height: 400px;
    }

    .mxch-types-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   Phrase Tag Input
   ========================================================================== */

.mxch-phrase-input-wrapper {
    border: 1px solid var(--mxch-card-border, #e5e7eb);
    border-radius: 8px;
    padding: 10px;
    background: var(--mxch-card-bg, #fff);
}

.mxch-phrase-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
    min-height: 28px;
}

.mxch-phrase-tags:empty {
    margin-bottom: 0;
}

.mxch-phrase-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: #f3f4f6;
    border-radius: 16px;
    font-size: 13px;
    color: #374151;
    border: 1px solid #e5e7eb;
    line-height: 1.4;
    max-width: 100%;
    word-break: break-word;
}

.mxch-phrase-pill .mxch-phrase-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
}

.mxch-phrase-pill .mxch-phrase-remove:hover {
    color: #ef4444;
}

/* Legacy phrase pill */
.mxch-phrase-pill.mxch-phrase-legacy {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.mxch-legacy-badge {
    font-size: 10px;
    text-transform: uppercase;
    background: #f59e0b;
    color: #fff;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Legacy tag in view mode */
.mxch-phrase-tag.mxch-phrase-legacy {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.mxch-phrase-add-row {
    display: flex;
    gap: 8px;
}

.mxch-phrase-add-row input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
}

.mxch-phrase-add-row input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.mxch-phrase-add-row .mxch-btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    white-space: nowrap;
}

.mxch-no-phrases {
    font-size: 13px;
    color: #9ca3af;
    font-style: italic;
}
