/* Automation Modal Styles */

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

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

.automation-modal-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    height: 80vh;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Modal Header */
.automation-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.automation-modal-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-icon {
    font-size: 1.75rem;
}

.server-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: normal;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: var(--success);
}

.status-dot.disconnected {
    background: var(--error);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Modal Body */
.automation-modal-body {
    flex: 1;
    overflow: hidden;
}

.automation-layout {
    display: flex;
    height: 100%;
}

/* Sidebar */
.automation-sidebar {
    width: 350px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.sidebar-actions {
    display: flex;
    gap: 0.5rem;
}

/* Button styles replaced - using /css/components/buttons.css */
/* All .btn-icon, .btn-icon.btn-small, .btn-icon.btn-primary now from buttons.css */

/* Automations List */
.automations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.automation-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.automation-list-item:hover {
    border-color: var(--primary-color);
    transform: translateX(2px);
}

.automation-list-item.selected {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
}

.automation-list-item.running {
    border-color: var(--success);
}

.automation-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-secondary);
    flex-shrink: 0;
}

.automation-status-indicator.idle {
    background: var(--text-secondary);
}

.automation-status-indicator.running {
    background: var(--success);
    animation: pulse 1s infinite;
}

.automation-status-indicator.failed {
    background: var(--error);
}

.automation-status-indicator.success {
    background: var(--success);
}

/* Flash animation for completed automations */
.automation-list-item.flash {
    animation: flash-highlight 2s ease-out;
}

@keyframes flash-highlight {
    0% {
        background: rgba(52, 152, 219, 0.3);
        transform: scale(1.02);
    }
    50% {
        background: rgba(52, 152, 219, 0.2);
        transform: scale(1.01);
    }
    100% {
        background: transparent;
        transform: scale(1);
    }
}

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

.automation-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.automation-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

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

.status-enabled,
.status-disabled {
    font-size: 1rem;
}

/* Server Stats */
.server-stats {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    background: var(--bg-tertiary);
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Details Panel */
.automation-details {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.empty-state,
.empty-state-small {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state-small {
    padding: 2rem 1rem;
}

.empty-icon {
    font-size: 3rem;
    opacity: 0.5;
    display: block;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--text-primary);
    margin: 0.5rem 0;
}

.empty-state p {
    margin: 0.5rem 0;
}

.hint {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Detail Sections */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.detail-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.detail-actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons - Moved to components/buttons.css */
/* All button styles consolidated in components/buttons.css */

.detail-section {
    margin-bottom: 2rem;
}

.detail-section h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

/* Status Info */
.status-info {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.status-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.status-row:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.status-row .label {
    color: var(--text-secondary);
}

.status-row .value {
    color: var(--text-primary);
    font-weight: 600;
}

.value.status-idle { color: var(--text-secondary); }
.value.status-running { color: var(--success); }
.value.status-failed { color: var(--error); }
.value.status-success { color: var(--success); }

/* Triggers */
.triggers-container {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.trigger-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
}

.trigger-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.trigger-icon {
    font-size: 1.25rem;
}

.trigger-desc {
    flex: 1;
    color: var(--text-primary);
}

.trigger-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.trigger-item:hover .trigger-actions {
    opacity: 1;
}

/* Button styles replaced - using .btn-icon and .btn-icon.btn-danger from buttons.css */
.trigger-actions .btn-icon {
    padding: 0.25rem; /* Keep smaller padding for this context */
    font-size: 0.9rem;
}

.no-triggers {
    color: var(--text-secondary);
    font-style: italic;
    margin: 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.stat-box {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.stat-box .stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.stat-box .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Logs */
.logs-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.logs-container.expanded {
    max-height: 600px;
}

.logs-content {
    padding: 0.5rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
}

.log-line {
    padding: 0.25rem 0.5rem;
    margin: 0.125rem 0;
    border-left: 3px solid transparent;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    transition: background 0.2s ease;
}

.log-line:hover {
    background: var(--bg-tertiary);
}

.log-line.log-error {
    border-left-color: var(--error);
    background: rgba(231, 76, 60, 0.05);
    color: #e74c3c;
}

.log-line.log-success {
    border-left-color: var(--success);
    background: rgba(46, 204, 113, 0.05);
    color: #27ae60;
}

.log-line.log-info {
    border-left-color: #3498db;
    background: rgba(52, 152, 219, 0.05);
    color: #3498db;
}

.log-line.log-debug {
    border-left-color: var(--text-secondary);
    color: var(--text-secondary);
    opacity: 0.8;
}

.logs-footer {
    padding: 0.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.no-logs {
    padding: 1rem;
    color: var(--text-secondary);
    font-style: italic;
    margin: 0;
}

/* Loading States */
.loading-spinner {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.error-state {
    text-align: center;
    padding: 2rem;
    color: var(--error);
}

.error-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

/* Workflow Selector Modal */
.workflow-selector-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.workflow-selector-modal .modal-content {
    position: relative;
    width: 600px;
    max-width: 90vw;
    max-height: 70vh;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workflow-selector-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.workflow-selector-modal .modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.workflow-selector-modal .modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.workflow-selector-modal .modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.workflow-selector-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.workflow-selector-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.workflow-selector-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.workflow-selector-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

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

.workflow-selector-item .workflow-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.workflow-selector-item .workflow-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.workflow-selector-item .select-workflow {
    margin-left: 1rem;
}

/* Dark theme adjustments */
.dark-theme .automation-modal-content,
.dark-theme .workflow-selector-modal .modal-content {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.dark-theme .automation-modal-overlay,
.dark-theme .workflow-selector-modal .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

.dark-theme .workflow-selector-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Dark theme button overrides removed - buttons.css handles all themes */

/* Trigger Configuration Modal */
.trigger-config-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.trigger-config-modal .modal-content {
    position: relative;
    width: 700px;
    max-width: 90vw;
    max-height: 85vh;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.trigger-config-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.trigger-config-modal .modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.trigger-config-modal .modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.trigger-config-modal .modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.trigger-config-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.trigger-config-modal .modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background: var(--bg-secondary);
}

/* Trigger Type Grid */
.trigger-type-selection h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.trigger-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.trigger-type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.trigger-type-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.trigger-type-card.selected {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

.trigger-type-icon {
    font-size: 2rem;
}

.trigger-type-name {
    font-weight: 600;
    color: var(--text-primary);
}

.trigger-type-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Trigger Configuration Form */
.trigger-config-section h4,
.trigger-preview-section h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

/* Form styles moved to components/forms.css */

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

.input-group input {
    flex: 0 0 auto;
}

.input-group select {
    flex: 1;
}

/* Cron Helpers */
.cron-helpers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.cron-preset {
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cron-preset:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Webhook URL Box */
.webhook-url-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.webhook-url-box code {
    flex: 1;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
    word-break: break-all;
}

/* Webhook Instructions */
.webhook-instructions {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.webhook-instructions h5 {
    margin: 0.75rem 0 0.5rem 0;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.webhook-instructions h6 {
    margin: 0.5rem 0 0.25rem 0;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.trigger-method {
    margin-bottom: 1rem;
}

.code-block {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem;
    margin: 0.5rem 0;
}

.code-block pre {
    margin: 0;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.code-block .copy-code {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.code-block:hover .copy-code {
    opacity: 1;
}

.other-methods {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.other-methods summary {
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 500;
    padding: 0.25rem;
}

.other-methods[open] summary {
    margin-bottom: 0.75rem;
}

.other-methods pre {
    background: var(--bg-primary);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin: 0.25rem 0;
}

/* Day Selector */
.day-selector {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.day-selector label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-primary);
    cursor: pointer;
}

.day-selector input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

/* Trigger Preview */
.trigger-preview-box {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.trigger-preview-box strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 0.5rem;
}

.trigger-preview-box code {
    background: var(--bg-tertiary);
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-size: 0.85rem;
    color: var(--primary-color);
}

/* Dark theme adjustments */
.dark-theme .trigger-config-modal .modal-content {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.dark-theme .trigger-config-modal .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

.dark-theme .trigger-type-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.dark-theme .trigger-type-card.selected {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}