/**
 * Automatisations CSS v2.0 — Visual Pipeline Builder
 * Uses theme vars: --bg-primary, --bg-secondary, --bg-card, --text, --text-secondary, --accent
 */

/* ── Container ────────────────────────────────────────────────────────────── */
.atm-container {
    padding: 24px 28px;
    max-width: 1320px;
    margin: 0 auto;
    min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.atm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.atm-header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.atm-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}
.atm-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text, #f1f5f9);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.atm-title-icon {
    font-size: 28px;
}
.atm-subtitle {
    font-size: 14px;
    color: var(--text-secondary, #94a3b8);
    margin: 0;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.atm-btn-create {
    background: linear-gradient(135deg, var(--accent, #10B981), #059669);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 11px 22px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(16, 185, 129, .25);
}
.atm-btn-create:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(16, 185, 129, .35); }
.atm-btn-create span { font-size: 18px; font-weight: 300; }

.atm-btn-outline {
    background: transparent;
    color: var(--text, #f1f5f9);
    border: 1px solid var(--border, rgba(255,255,255,.12));
    border-radius: 10px;
    padding: 9px 18px;
    font-size: 13px;
    cursor: pointer;
    transition: all .2s;
}
.atm-btn-outline:hover { border-color: var(--accent, #10B981); color: var(--accent, #10B981); }

.atm-btn-back {
    background: none;
    border: none;
    color: var(--text-secondary, #94a3b8);
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    margin-bottom: 4px;
    transition: color .2s;
}
.atm-btn-back:hover { color: var(--text, #f1f5f9); }

/* ── Stats Bar ────────────────────────────────────────────────────────────── */
.atm-stats-bar {
    display: flex;
    gap: 14px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.atm-stat-card {
    background: var(--bg-card, rgba(255,255,255,.04));
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 12px;
    padding: 14px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 100px;
    backdrop-filter: blur(8px);
}
.atm-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text, #f1f5f9);
}
.atm-stat-label {
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.atm-stat-active .atm-stat-value { color: #10B981; }
.atm-stat-success .atm-stat-value { color: #10B981; }
.atm-stat-fail .atm-stat-value { color: #EF4444; }

/* ── Filters ──────────────────────────────────────────────────────────────── */
.atm-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.atm-filter-btn {
    background: var(--bg-card, rgba(255,255,255,.04));
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.atm-filter-btn:hover { border-color: var(--accent, #10B981); color: var(--text, #f1f5f9); }
.atm-filter-active {
    background: var(--accent, #10B981)15;
    border-color: var(--accent, #10B981);
    color: var(--accent, #10B981);
}
.atm-filter-count {
    background: rgba(255,255,255,.08);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
}

/* ── Grid ─────────────────────────────────────────────────────────────────── */
.atm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 18px;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.atm-card {
    background: var(--bg-card, rgba(255,255,255,.04));
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(12px);
    transition: all .25s;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.atm-card:hover {
    border-color: var(--accent, #10B981)40;
    box-shadow: 0 4px 20px rgba(0,0,0,.15);
    transform: translateY(-2px);
}

.atm-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.atm-card-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid;
    font-size: 12px;
    font-weight: 500;
}
.atm-card-trigger-icon { font-size: 16px; }

.atm-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text, #f1f5f9);
    margin: 0;
}
.atm-card-desc {
    font-size: 13px;
    color: var(--text-secondary, #94a3b8);
    margin: 0;
    line-height: 1.4;
}

.atm-card-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.atm-card-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
}
.atm-meta-icon { font-size: 14px; }

.atm-card-status {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.atm-badge {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}
.atm-badge-success { background: #10B98118; color: #10B981; border: 1px solid #10B98130; }
.atm-badge-fail { background: #EF444418; color: #EF4444; border: 1px solid #EF444430; }

.atm-card-actions {
    display: flex;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border, rgba(255,255,255,.06));
}
.atm-action-btn {
    background: var(--bg-secondary, rgba(255,255,255,.06));
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all .2s;
    line-height: 1;
}
.atm-action-btn:hover { border-color: var(--accent, #10B981); transform: scale(1.05); }
.atm-action-delete:hover { border-color: #EF4444; }

/* ── Toggle ───────────────────────────────────────────────────────────────── */
.atm-toggle { position: relative; display: inline-block; cursor: pointer; }
.atm-toggle input { display: none; }
.atm-toggle-track {
    display: block;
    width: 40px;
    height: 22px;
    background: rgba(255,255,255,.12);
    border-radius: 11px;
    transition: background .25s;
    position: relative;
}
.atm-toggle input:checked + .atm-toggle-track { background: var(--accent, #10B981); }
.atm-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform .25s;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.atm-toggle input:checked + .atm-toggle-track .atm-toggle-thumb { transform: translateX(18px); }

/* ── Empty ────────────────────────────────────────────────────────────────── */
.atm-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary, #94a3b8);
}
.atm-empty-icon { font-size: 56px; margin-bottom: 16px; }
.atm-empty h3 { color: var(--text, #f1f5f9); margin: 0 0 8px; }
.atm-empty p { margin: 0 0 24px; }

/* ── Loading ──────────────────────────────────────────────────────────────── */
.atm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px;
    color: var(--text-secondary, #94a3b8);
    font-size: 15px;
}
.atm-spinner {
    width: 24px; height: 24px;
    border: 3px solid rgba(255,255,255,.1);
    border-top-color: var(--accent, #10B981);
    border-radius: 50%;
    animation: atm-spin .8s linear infinite;
}
@keyframes atm-spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════════════
   BUILDER — Visual Pipeline
   ══════════════════════════════════════════════════════════════════════════ */
.atm-builder {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    min-height: 500px;
}
@media (max-width: 900px) {
    .atm-builder { grid-template-columns: 1fr; }
}

/* Sidebar */
.atm-builder-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.atm-field { display: flex; flex-direction: column; gap: 6px; }
.atm-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #f1f5f9);
}
.atm-label-sm {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 2px;
}
.atm-input, .atm-textarea {
    background: var(--bg-secondary, rgba(255,255,255,.06));
    border: 1px solid var(--border, rgba(255,255,255,.1));
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text, #f1f5f9);
    transition: border-color .2s;
    font-family: inherit;
    resize: vertical;
}
.atm-input:focus, .atm-textarea:focus {
    outline: none;
    border-color: var(--accent, #10B981);
}
.atm-input-sm {
    background: var(--bg-secondary, rgba(255,255,255,.06));
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text, #f1f5f9);
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color .2s;
}
.atm-input-sm:focus { outline: none; border-color: var(--accent, #10B981); }
.atm-textarea-sm { resize: vertical; font-family: inherit; }
.atm-select, .atm-select-sm {
    background: var(--bg-secondary, rgba(255,255,255,.06));
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text, #f1f5f9);
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
}
.atm-select:focus, .atm-select-sm:focus { outline: none; border-color: var(--accent, #10B981); }

/* Pipeline */
.atm-builder-pipeline {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}
.atm-pipeline-section {
    width: 100%;
    max-width: 560px;
}
.atm-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent, #10B981);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 8px;
    padding-left: 4px;
}
.atm-section-opt {
    color: var(--text-secondary, #94a3b8);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

/* Pipeline Connector */
.atm-pipeline-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 36px;
    position: relative;
    width: 100%;
    max-width: 560px;
}
.atm-connector-sm { height: 24px; }
.atm-connector-line {
    width: 2px;
    flex: 1;
    background: linear-gradient(180deg, var(--accent, #10B981)60, var(--accent, #10B981)20);
}
.atm-connector-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent, #10B981);
    box-shadow: 0 0 8px var(--accent, #10B981)40;
}

/* Nodes */
.atm-node {
    background: var(--bg-card, rgba(255,255,255,.04));
    border: 1px solid var(--border, rgba(255,255,255,.1));
    border-radius: 14px;
    overflow: hidden;
    transition: all .2s;
}
.atm-node:hover { border-color: var(--accent, #10B981)30; }

.atm-node-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,.06));
}
.atm-node-header-condition { background: rgba(59, 130, 246, .08); }
.atm-node-icon { font-size: 20px; flex-shrink: 0; }
.atm-node-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text, #f1f5f9);
}
.atm-node-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.atm-node-controls {
    display: flex;
    gap: 4px;
    margin-left: auto;
}
.atm-ctrl-btn {
    background: rgba(255,255,255,.06);
    border: 1px solid transparent;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary, #94a3b8);
    font-size: 14px;
    transition: all .15s;
}
.atm-ctrl-btn:hover { border-color: var(--accent, #10B981); color: var(--text, #f1f5f9); }
.atm-ctrl-delete:hover { border-color: #EF4444; color: #EF4444; }

.atm-step-type-select {
    background: transparent;
    border: none;
    color: var(--text, #f1f5f9);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
}
.atm-step-type-select:focus { outline: none; }

/* Step delay row */
.atm-step-delay {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,.04));
    margin-bottom: 4px;
}
.atm-delay-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.atm-delay-input {
    width: 60px !important;
}
.atm-delay-unit {
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
}

/* Conditions */
.atm-condition-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    gap: 8px;
    align-items: center;
}
.atm-btn-remove-cond {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    color: #EF4444;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.atm-btn-remove-cond:hover { border-color: #EF4444; background: #EF444415; }

.atm-btn-add-condition, .atm-btn-add-action {
    background: transparent;
    border: 2px dashed var(--border, rgba(255,255,255,.12));
    border-radius: 12px;
    padding: 12px;
    width: 100%;
    max-width: 560px;
    color: var(--text-secondary, #94a3b8);
    font-size: 13px;
    cursor: pointer;
    transition: all .2s;
    margin-top: 10px;
}
.atm-btn-add-condition:hover, .atm-btn-add-action:hover {
    border-color: var(--accent, #10B981);
    color: var(--accent, #10B981);
    background: var(--accent, #10B981)08;
}
.atm-btn-add-condition { margin: 8px 0 0 0; border-radius: 0 0 14px 14px; border-top: none; }

.atm-hint {
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
    margin: 0;
    font-style: italic;
}
.atm-tc {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.atm-steps-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary, #94a3b8);
    font-size: 13px;
    border: 2px dashed var(--border, rgba(255,255,255,.08));
    border-radius: 14px;
}

.atm-wait-config {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ══════════════════════════════════════════════════════════════════════════
   LOGS TABLE
   ══════════════════════════════════════════════════════════════════════════ */
.atm-logs-wrap {
    overflow-x: auto;
}
.atm-logs-table {
    width: 100%;
    border-collapse: collapse;
}
.atm-logs-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary, #94a3b8);
    border-bottom: 1px solid var(--border, rgba(255,255,255,.1));
}
.atm-logs-table td {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text, #f1f5f9);
    border-bottom: 1px solid var(--border, rgba(255,255,255,.04));
}
.atm-log-row:hover { background: rgba(255,255,255,.02); }
.atm-log-status { font-weight: 600; font-size: 12px; }
.atm-log-status-completed { color: #10B981; }
.atm-log-status-failed { color: #EF4444; }
.atm-log-status-running { color: #3B82F6; }
.atm-log-status-skipped { color: #6B7280; }
.atm-log-error {
    color: #EF4444;
    font-size: 12px;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .atm-container { padding: 16px; }
    .atm-grid { grid-template-columns: 1fr; }
    .atm-header { flex-direction: column; align-items: flex-start; }
    .atm-stats-bar { flex-direction: column; }
    .atm-condition-row { grid-template-columns: 1fr; }
}
