/**
 * Automations Tab Styles
 * CSS for the N8N-style automation hub
 */

/* Container */
.automations-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Header */
.automations-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.automations-header-content {
    flex: 1;
}

.automations-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    margin: 0 0 0.5rem;
}

.automations-subtitle {
    color: var(--text-secondary, #64748b);
    font-size: 0.95rem;
    margin: 0;
}

.create-workflow-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(var(--color-primary-rgb), 0.25);
}

.create-workflow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(var(--color-primary-rgb), 0.35);
}

/* Stats Overview */
.automation-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

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

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
}

/* Section */
.automations-section {
    margin-bottom: 2.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin: 0;
}

.section-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    background: rgba(var(--color-primary-rgb), 0.15);
    color: var(--color-primary);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Workflows Grid */
.workflows-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.workflow-card {
    position: relative;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.workflow-card:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(var(--color-primary-rgb), 0.25);
    transform: translateY(-2px);
}

.workflow-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.workflow-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(var(--color-primary-rgb), 0.15) 0%, rgba(var(--color-accent-rgb), 0.08) 100%);
    border-radius: 12px;
    font-size: 1.5rem;
    flex-shrink: 0;
}

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

.workflow-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin: 0 0 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workflow-card-trigger {
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.workflow-status {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.status-dot.paused {
    background: #f59e0b;
}

.status-dot.draft {
    background: #6b7280;
}

.status-dot.error {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.workflow-card-stats {
    display: flex;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.workflow-stat {
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
}

.workflow-stat-value {
    font-weight: 600;
    color: var(--text-primary, #334155);
}

/* Empty State */
.workflows-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 2rem;
    background: rgba(0, 0, 0, 0.01);
    border: 1px dashed rgba(0, 0, 0, 0.1);
    border-radius: 16px;
}

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

.workflows-empty-state p {
    color: var(--text-secondary, #64748b);
    margin: 0.25rem 0;
}

.empty-hint {
    font-size: 0.85rem;
}

/* Template Cards */
.workflow-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.workflow-template-card {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.workflow-template-card:hover {
    background: rgba(var(--color-primary-rgb), 0.08);
    border-color: rgba(var(--color-primary-rgb), 0.25);
    transform: translateY(-2px);
}

.template-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.template-icon {
    font-size: 2rem;
}

.template-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin: 0;
}

.template-description {
    font-size: 0.9rem;
    color: var(--text-secondary, #64748b);
    margin: 0 0 1rem;
    line-height: 1.5;
}

.template-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.template-category {
    padding: 0.35rem 0.75rem;
    background: rgba(var(--color-primary-rgb), 0.12);
    color: var(--color-primary);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.template-trigger-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
}

.template-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary, #64748b);
}

/* Modal Styles */
.modal-overlay[aria-hidden="true"] {
    display: none;
}

.modal-overlay[aria-hidden="false"] {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.workflow-modal,
.workflow-detail-modal {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    background: linear-gradient(180deg, rgba(30, 30, 40, 0.98) 0%, rgba(20, 20, 30, 0.98) 100%);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.04);
    border: none;
    border-radius: 10px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: white;
}

.workflow-modal-header {
    padding: 2rem 2rem 1.5rem;
    text-align: center;
    background: linear-gradient(135deg, rgba(var(--color-primary-rgb), 0.12) 0%, rgba(var(--color-accent-rgb), 0.06) 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.workflow-preview-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.75rem;
}

.workflow-preview-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    margin: 0 0 0.5rem;
}

.workflow-preview-description {
    color: var(--text-secondary, #64748b);
    font-size: 0.9rem;
    margin: 0;
}

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

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary, #475569);
    margin-bottom: 0.5rem;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    color: var(--text-primary, #1e293b);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s ease;
}

.form-group input[type="text"]:focus {
    border-color: rgba(var(--color-primary-rgb), 0.4);
    background: rgba(0, 0, 0, 0.03);
}

.trigger-info {
    padding: 1rem;
    background: rgba(var(--color-primary-rgb), 0.08);
    border-radius: 12px;
}

.trigger-badge {
    font-size: 0.9rem;
    color: var(--color-primary);
    font-weight: 500;
}

.workflow-steps-preview {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.01);
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary, #475569);
}

.step-number {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--color-primary-rgb), 0.15);
    color: var(--color-primary);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.workflow-modal-footer {
    padding: 1.5rem 2rem;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(var(--color-primary-rgb), 0.35);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary, #1e293b);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Detail Modal */
.workflow-detail-modal {
    max-width: 600px;
}

.detail-modal-header {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.01);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.detail-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.detail-icon {
    font-size: 2rem;
}

.detail-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    margin: 0 0 0.25rem;
}

.detail-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    font-weight: 500;
}

.detail-status.active {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.detail-status.paused {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.detail-status.draft {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
}

.detail-modal-body {
    padding: 1.5rem 2rem;
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-stat {
    text-align: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.01);
    border-radius: 12px;
}

.detail-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    margin-bottom: 0.25rem;
}

.detail-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
}

.detail-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary, #475569);
    margin: 0 0 1rem;
}

.executions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.execution-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.01);
    border-radius: 10px;
}

.execution-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.execution-time {
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
}

.no-executions {
    color: var(--text-secondary, #64748b);
    font-size: 0.9rem;
    text-align: center;
    padding: 1.5rem;
}

.detail-modal-footer {
    padding: 1.5rem 2rem;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-right {
    display: flex;
    gap: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .automations-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .create-workflow-btn {
        width: 100%;
        justify-content: center;
    }

    .automation-stats {
        grid-template-columns: 1fr;
    }

    .workflows-grid,
    .workflow-templates-grid {
        grid-template-columns: 1fr;
    }

    .workflow-modal,
    .workflow-detail-modal {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .detail-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .detail-stat-value {
        font-size: 1.1rem;
    }
}