/* Workflows Page - Modern Colorful Design */
/* Following UI Style Guide principles */

/* ===== Page Header ===== */
#page-workflows .page-header {
    margin-bottom: 24px;
}

#page-workflows .page-title {
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#page-workflows .header-actions {
    display: flex;
    gap: 10px;
}

#page-workflows .header-actions .btn-primary {
    background: linear-gradient(135deg, #a855f7, #8b5cf6);
    border: none;
    color: white;
    box-shadow: 0 4px 16px #a855f740;
}

#page-workflows .header-actions .btn-primary:hover {
    box-shadow: 0 6px 24px #a855f760;
    transform: translateY(-1px);
}

/* ===== Workflow Cards Container ===== */
#page-workflows .card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 20px;
    overflow: hidden;
}

#page-workflows .card h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-card) 100%);
}

/* Active Workflows Card */
#page-workflows .card:first-of-type h3::before {
    content: '';
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #22c55e25, #22c55e10);
    border: 1px solid #22c55e30;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px #22c55e30;
}

/* Workflow History Card */
#page-workflows .card:nth-of-type(2) h3::before {
    content: '';
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f625, #3b82f610);
    border: 1px solid #3b82f630;
    border-radius: 8px;
    box-shadow: 0 0 16px #3b82f630;
}

/* ===== Active Workflows Section ===== */
#active-workflows {
    padding: 20px;
}

.active-workflow-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.active-workflow-card:hover {
    border-color: #22c55e40;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.active-workflow-card:last-child {
    margin-bottom: 0;
}

.workflow-status-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.workflow-status-icon.running {
    background: linear-gradient(135deg, #22c55e25, #22c55e10);
    border: 1px solid #22c55e30;
    color: #22c55e;
    box-shadow: 0 0 20px #22c55e30;
    animation: pulseGlow 2s infinite;
}

.workflow-status-icon.pending {
    background: linear-gradient(135deg, #f59e0b25, #f59e0b10);
    border: 1px solid #f59e0b30;
    color: #f59e0b;
}

.workflow-status-icon.failed {
    background: linear-gradient(135deg, #ef444425, #ef444410);
    border: 1px solid #ef444430;
    color: #ef4444;
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 20px #22c55e30;
    }
    50% {
        box-shadow: 0 0 30px #22c55e50;
    }
}

.workflow-info {
    flex: 1;
}

.workflow-info h4 {
    margin: 0 0 4px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.workflow-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.workflow-progress {
    width: 120px;
    text-align: right;
}

.workflow-progress-bar {
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.workflow-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #3b82f6);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.workflow-progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Workflow History Table ===== */
#page-workflows .table {
    width: 100%;
    border-collapse: collapse;
}

#page-workflows .table thead {
    background: var(--bg-dark);
}

#page-workflows .table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

#page-workflows .table td {
    padding: 14px 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

#page-workflows .table tbody tr {
    transition: background 0.15s ease;
}

#page-workflows .table tbody tr:hover {
    background: var(--bg-hover);
}

#page-workflows .table tbody tr:last-child td {
    border-bottom: none;
}

/* Workflow ID column */
#page-workflows .table td:first-child {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.8rem;
    color: #a855f7;
}

/* Workflow Type badges */
.workflow-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
}

.workflow-type-badge.daily_optimization {
    background: #3b82f620;
    color: #3b82f6;
    border: 1px solid #3b82f630;
}

.workflow-type-badge.full_analysis {
    background: #a855f720;
    color: #a855f7;
    border: 1px solid #a855f730;
}

.workflow-type-badge.report_generation {
    background: #06b6d420;
    color: #06b6d4;
    border: 1px solid #06b6d430;
}

.workflow-type-badge.optimization {
    background: #22c55e20;
    color: #22c55e;
    border: 1px solid #22c55e30;
}

/* Status Badges */
#page-workflows .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

#page-workflows .status-badge.running,
#page-workflows .status-badge.completed,
#page-workflows .status-badge.success {
    background: #22c55e20;
    color: #22c55e;
    border: 1px solid #22c55e30;
}

#page-workflows .status-badge.running::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 1.5s infinite;
}

#page-workflows .status-badge.pending,
#page-workflows .status-badge.queued {
    background: #f59e0b20;
    color: #f59e0b;
    border: 1px solid #f59e0b30;
}

#page-workflows .status-badge.failed,
#page-workflows .status-badge.error {
    background: #ef444420;
    color: #ef4444;
    border: 1px solid #ef444430;
}

#page-workflows .status-badge.cancelled {
    background: var(--bg-hover);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

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

/* Progress column */
.progress-cell {
    width: 120px;
}

.progress-mini {
    height: 4px;
    background: var(--bg-dark);
    border-radius: 2px;
    overflow: hidden;
}

.progress-mini-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #3b82f6);
    border-radius: 2px;
}

/* ===== Workflows List (alternate layout) ===== */
#workflows-list {
    padding: 0;
}

#workflows-list table {
    width: 100%;
    border-collapse: collapse;
}

#workflows-list thead {
    background: var(--bg-dark);
}

#workflows-list th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

#workflows-list td {
    padding: 14px 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

#workflows-list tbody tr {
    transition: background 0.15s ease;
}

#workflows-list tbody tr:hover {
    background: var(--bg-hover);
}

/* ===== Empty State ===== */
#page-workflows .empty-state {
    padding: 60px 20px;
    text-align: center;
}

#page-workflows .empty-state .icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

#page-workflows .empty-state p {
    color: var(--text-secondary);
}

/* ===== Start Workflow Modal ===== */
#page-workflows .form-group {
    margin-bottom: 16px;
}

#page-workflows .form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

#page-workflows .form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

#page-workflows .form-group select:focus {
    outline: none;
    border-color: #a855f7;
    box-shadow: 0 0 0 3px #a855f720;
}

/* ===== Card Animations ===== */
#page-workflows .card {
    animation: cardAppear 0.4s ease forwards;
    opacity: 0;
}

#page-workflows .card:nth-child(1) {
    animation-delay: 0ms;
}

#page-workflows .card:nth-child(2) {
    animation-delay: 100ms;
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .active-workflow-card {
        flex-direction: column;
        text-align: center;
    }

    .workflow-progress {
        width: 100%;
        text-align: center;
    }

    #page-workflows .table {
        font-size: 0.8rem;
    }

    #page-workflows .table th,
    #page-workflows .table td {
        padding: 10px 12px;
    }
}
