/* ============================================
   TRIGGER POPOVER - NL-first trigger editing
   ============================================ */

.trigger-popover {
    position: fixed;
    z-index: 200;
    width: 380px;
    background: #1F2937;
    border: 1px solid #374151;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    animation: trigger-popover-in 0.2s ease;
    max-height: 80vh;
    /* overflow must stay visible so .trigger-popover-arrow (top: -7px /
       bottom: -7px) is not clipped; scrolling happens inside
       .trigger-popover-body instead. */
    overflow: visible;
}

/* Scrollable middle region — header and footer stay pinned */
.trigger-popover-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.trigger-popover.hidden {
    display: none;
}

@keyframes trigger-popover-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Arrow pointing up toward trigger node */
.trigger-popover-arrow {
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: #1F2937;
    border-left: 1px solid #374151;
    border-top: 1px solid #374151;
}

.trigger-popover.above .trigger-popover-arrow {
    top: auto;
    bottom: -7px;
    border-left: none;
    border-top: none;
    border-right: 1px solid #374151;
    border-bottom: 1px solid #374151;
}

/* ---- Header ---- */
.trigger-popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #374151;
    flex-shrink: 0;
}

.trigger-popover-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #F9FAFB;
}

.trigger-popover-close {
    background: none;
    border: none;
    color: #9CA3AF;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.trigger-popover-close:hover {
    color: #F9FAFB;
}

/* ---- Natural Language Input Section ---- */
.trigger-nl-section {
    padding: 12px 16px 8px;
}

.trigger-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #9CA3AF;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.trigger-nl-input {
    width: 100%;
    padding: 10px 12px;
    background: #111827;
    border: 1px solid #4B5563;
    border-radius: 8px;
    color: #F9FAFB;
    font-size: 14px;
    font-family: Inter, system-ui, sans-serif;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.trigger-nl-input:focus {
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

.trigger-nl-input::placeholder {
    color: #6B7280;
}

.trigger-nl-hint {
    font-size: 12px;
    margin-top: 6px;
    min-height: 18px;
    color: #6B7280;
    transition: color 0.2s;
}
.trigger-nl-hint.success { color: #22c55e; }
.trigger-nl-hint.error   { color: #EF4444; }
.trigger-nl-hint.warning { color: #F59E0B; }
.trigger-nl-hint.loading { color: #60A5FA; }

/* ---- Type Selector ---- */
.trigger-type-selector {
    display: flex;
    gap: 8px;
    padding: 8px 16px 12px;
}

.trigger-type-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    background: #111827;
    border: 2px solid #374151;
    border-radius: 8px;
    color: #9CA3AF;
    cursor: pointer;
    transition: all 0.2s;
}

.trigger-type-btn:hover {
    border-color: #4B5563;
    color: #D1D5DB;
}

.trigger-type-btn.active {
    border-color: #22c55e;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
}

.trigger-type-icon {
    font-size: 20px;
    line-height: 1;
}

.trigger-type-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Config Panels ---- */
.trigger-config-panels {
    padding: 0 16px;
}

.trigger-panel {
    padding-bottom: 8px;
}

.trigger-panel.hidden {
    display: none;
}

.trigger-panel-info {
    padding: 12px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    font-size: 13px;
    color: #D1D5DB;
    line-height: 1.5;
}

/* ---- Preset Chips ---- */
.trigger-preset-chips {
    margin-bottom: 12px;
}

.preset-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.preset-chip {
    padding: 5px 10px;
    background: #111827;
    border: 1px solid #4B5563;
    border-radius: 16px;
    color: #D1D5DB;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.preset-chip:hover {
    border-color: #22c55e;
    color: #22c55e;
}

.preset-chip.active {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #22c55e;
}

.preset-chip:focus-visible {
    outline: 2px solid #22c55e;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

.preset-chip:focus {
    border-color: #22c55e;
    color: #22c55e;
}

/* ---- Next Runs Preview ---- */
.trigger-next-runs {
    margin-bottom: 12px;
}

.next-runs-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

.next-run-item {
    padding: 6px 10px;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 6px;
    font-size: 13px;
    color: #D1D5DB;
    font-family: 'JetBrains Mono', monospace, system-ui;
}

.next-run-item.error {
    color: #EF4444;
    border-color: rgba(239, 68, 68, 0.3);
}

/* ---- Fine-tune Controls ---- */
.trigger-fine-tune {
    border: 1px solid #374151;
    border-radius: 8px;
    overflow: hidden;
}

.trigger-fine-tune summary {
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #9CA3AF;
    cursor: pointer;
    user-select: none;
    background: rgba(255,255,255,0.02);
}

.trigger-fine-tune summary:hover {
    color: #D1D5DB;
    background: rgba(255,255,255,0.04);
}

.trigger-fine-tune[open] summary {
    border-bottom: 1px solid #374151;
}

.fine-tune-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
}

.fine-tune-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fine-tune-field.hidden {
    display: none;
}

.fine-tune-field label {
    font-size: 12px;
    font-weight: 500;
    color: #9CA3AF;
}

.fine-tune-field select,
.fine-tune-field input[type="time"],
.fine-tune-field input[type="number"],
.fine-tune-field input[type="text"] {
    padding: 8px 10px;
    background: #111827;
    border: 1px solid #4B5563;
    border-radius: 6px;
    color: #F9FAFB;
    font-size: 13px;
    outline: none;
}

.fine-tune-field select:focus,
.fine-tune-field input:focus {
    border-color: #22c55e;
}

/* Day checkboxes */
.day-checkboxes {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.day-cb {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.day-cb input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.day-cb span {
    display: inline-block;
    padding: 4px 8px;
    background: #111827;
    border: 1px solid #4B5563;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #9CA3AF;
    transition: all 0.15s;
    user-select: none;
}

.day-cb input[type="checkbox"]:focus-visible + span {
    outline: 2px solid #22c55e;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

.day-cb input:checked + span {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #22c55e;
}

.day-cb span:hover {
    border-color: #6B7280;
}

/* ---- Webhook URL ---- */
.webhook-url-section {
    margin-top: 12px;
}

.composio-trigger-grid,
.composio-trigger-config {
    margin-top: 12px;
}

.composio-trigger-config input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #22c55e;
}

.webhook-url-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.webhook-url {
    flex: 1;
    padding: 8px 10px;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 6px;
    font-size: 12px;
    color: #D1D5DB;
    overflow-x: auto;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace, system-ui;
}

.copy-btn {
    background: none;
    border: 1px solid #4B5563;
    border-radius: 6px;
    padding: 6px 8px;
    color: #9CA3AF;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.copy-btn:hover {
    border-color: #22c55e;
    color: #22c55e;
}

/* ---- Footer ---- */
.trigger-popover-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #374151;
    margin-top: 4px;
    flex-shrink: 0;
    background: #1F2937;
}

.trigger-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.trigger-btn.secondary {
    background: #374151;
    color: #D1D5DB;
}
.trigger-btn.secondary:hover {
    background: #4B5563;
}

.trigger-btn.primary {
    background: #22c55e;
    color: #ffffff;
}
.trigger-btn.primary:hover {
    background: #16a34a;
}

/* ---- Mobile responsive ---- */
@media (max-width: 768px) {
    .trigger-popover {
        width: calc(100vw - 24px);
        left: 12px !important;
        right: 12px;
        max-height: 70vh;
    }
}
