/* Channels & rules settings (builds on base.css tokens). */

/* -- channels list ---------------------------------------------------------------- */

.ch-group { margin-bottom: 18px; }
.ch-group-title { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 8px 2px; }
.ch-list { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.ch-row { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 4px; border-bottom: 1px solid var(--divider); min-width: 0; }
.ch-row:last-child { border-bottom: 0; }
.ch-row:hover { background: var(--surface-2); }
.ch-row.is-paused .ch-row-main { opacity: 0.6; }
.ch-row-main { display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: 0; text-align: left; padding: 2px 8px; border-radius: var(--radius-sm); }
.ch-row-main:focus-visible { outline: 2px solid var(--focus); }
.ch-type-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--accent-soft); color: var(--accent-text); }
.ch-type-sms { background: var(--green-soft); color: var(--green-text); }
.ch-type-whatsapp { background: var(--teal-soft); color: var(--teal); }
.ch-type-chat { background: var(--purple-soft); color: var(--purple-text); }
.ch-type-api { background: var(--orange-soft); color: var(--orange-text); }
.ch-row-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ch-row-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; min-width: 0; flex-wrap: wrap; }
.ch-row-sub { display: flex; flex-wrap: wrap; gap: 4px; font-size: 12.5px; color: var(--text-3); }
.ch-row-error { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--red-text); }
.ch-status { flex: none; }
.ch-footnote { margin-top: 4px; }
@media (max-width: 640px) {
  .ch-status { display: none; }
  .ch-row { padding-right: 4px; }
}

/* -- channel editor ----------------------------------------------------------------- */

.ch-tab-body { min-height: 220px; }
.ch-subhead { font-size: 12px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }
.ch-port-row { display: grid; grid-template-columns: 96px 1fr; gap: 12px; }
.ch-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-preset { height: 32px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; font-weight: 550; color: var(--text-2); }
.ch-preset:hover { border-color: var(--text-3); color: var(--text); }
.ch-preset.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.ch-editor, .rl-editor { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.ch-editor:focus-within, .rl-editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.ch-copy { display: flex; gap: 6px; align-items: flex-start; }
.ch-copy .input { flex: 1; min-width: 0; font-size: 12.5px; }
.ch-copy-text { resize: vertical; line-height: 1.5; }

.ch-chat-setup { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 20px; align-items: start; }
@media (max-width: 760px) { .ch-chat-setup { grid-template-columns: 1fr; } }
.ch-preview { position: relative; padding-bottom: 62px; }
.ch-preview-panel { border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-2); border: 1px solid var(--border); background: #fff; color: #1d2433; }
.ch-preview-head { color: #fff; padding: 12px 14px; font-size: 13.5px; }
.ch-preview-status { font-size: 11.5px; opacity: 0.9; margin-top: 2px; }
.ch-preview-status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #9be7a8; margin-right: 5px; }
.ch-preview-body { background: #f6f7f9; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 150px; }
.ch-preview-greeting { background: #fff; border: 1px solid #e3e6ec; border-radius: 10px; padding: 8px 10px; font-size: 12.5px; line-height: 1.4; max-width: 92%; white-space: pre-wrap; }
.ch-preview-msg { align-self: flex-end; color: #fff; border-radius: 12px 12px 4px 12px; padding: 7px 10px; font-size: 12.5px; }
.ch-preview-input { border-top: 1px solid #e3e6ec; padding: 9px 12px; font-size: 12.5px; color: #9aa2b4; }
.ch-preview-launcher { position: absolute; right: 4px; bottom: 0; width: 48px; height: 48px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-2); }

/* -- rules list ----------------------------------------------------------------------- */

.rl-list { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.rl-list-row { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 4px; border-bottom: 1px solid var(--divider); min-width: 0; }
.rl-list-row:last-child { border-bottom: 0; }
.rl-list-row:hover { background: var(--surface-2); }
.rl-list-row.is-paused .rl-list-main { opacity: 0.55; }
.rl-order { display: flex; flex-direction: column; }
.rl-order .icon-btn-sm { height: 18px; }
.rl-list-main { flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 2px 4px; border-radius: var(--radius-sm); }
.rl-list-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.rl-list-summary { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 12.5px; color: var(--text-2); }
.rl-when { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); }
.rl-then { color: var(--accent-text); }
.rl-list-stats { font-size: 12px; color: var(--text-3); }

.rl-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.rl-template { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; text-align: left; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); transition: border-color 0.12s, box-shadow 0.12s; }
.rl-template:hover { border-color: var(--accent); box-shadow: var(--shadow-1); }
.rl-template-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }

/* -- rule editor ---------------------------------------------------------------------- */

.rl-block { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.rl-block-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rl-step { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-text); }
.rl-always { padding: 2px 0; }
.rl-row { display: flex; align-items: flex-start; gap: 6px; padding: 8px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.rl-row-fields { display: grid; grid-template-columns: 170px 150px minmax(0, 1fr); gap: 6px; flex: 1; min-width: 0; align-items: start; }
.rl-row-fields > .rl-field:only-child { grid-column: 1 / -1; }
.rl-action-fields { grid-template-columns: 210px minmax(0, 1fr); }
.rl-row-fields .rl-value:nth-child(2) { grid-column: 2 / -1; }
.rl-value { min-width: 0; }
.rl-row-tools { display: flex; gap: 0; }
.rl-params { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.rl-snooze { grid-template-columns: 90px 1fr; }
.rl-pick { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-height: 34px; height: auto; padding: 4px 28px 4px 8px; text-align: left; position: relative; cursor: pointer; }
.rl-pick-caret { position: absolute; right: 9px; top: 11px; color: var(--text-3); }
.rl-days { display: flex; flex-wrap: wrap; gap: 4px; }
.rl-day { height: 30px; min-width: 42px; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.rl-day.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 760px) {
  .rl-row-fields, .rl-action-fields, .rl-params { grid-template-columns: 1fr; }
  .rl-row-fields .rl-value:nth-child(2) { grid-column: auto; }
}

.rl-test-wrap { border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 10px 12px; }
.rl-test-wrap > summary { cursor: pointer; display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; list-style: none; }
.rl-test-wrap > summary::-webkit-details-marker { display: none; }
.rl-test-wrap[open] > summary { margin-bottom: 8px; }
.rl-tester { display: flex; flex-direction: column; gap: 8px; }
.rl-tester-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); max-height: 220px; overflow-y: auto; background: var(--surface); }
.rl-tester-item { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--divider); min-width: 0; }
.rl-tester-item:last-child { border-bottom: 0; }
.rl-tester-item:hover, .rl-tester-item.is-active { background: var(--selected); }
.rl-outcome { border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.rl-outcome.is-match { background: var(--green-soft); }
.rl-outcome.is-miss { background: var(--surface-3); }
.rl-outcome-head { display: flex; align-items: center; gap: 6px; font-weight: 650; }
.rl-outcome.is-match .rl-outcome-head { color: var(--green-text); }
.rl-outcome-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.rl-outcome-list li { display: flex; align-items: center; gap: 6px; }
.rl-outcome-list .is-ok { color: var(--green-text); }
.rl-outcome-list .is-no { color: var(--text-3); }

@media (max-width: 640px) {
  .ch-settings .section-header, .rl-settings .section-header { flex-direction: column; align-items: stretch; }
  .ch-settings .section-actions, .rl-settings .section-actions { justify-content: flex-end; }
}

/* Sign in with Google / Microsoft */
.ch-signin { display: flex; flex-direction: column; gap: 8px; }
.ch-signin-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.ch-signin-option:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.ch-signin-option:disabled { opacity: 0.6; }
.ch-signin-option > .icon:last-child, .ch-signin-option > svg:last-child { margin-left: auto; color: var(--text-3); }
.ch-signin-logo { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: none;
  border-radius: 50%; border: 1px solid var(--border); font-weight: 700; font-size: 15px; color: var(--text-2); }
.ch-signin-logo.is-google { color: #4285f4; }
.ch-signin-logo.is-microsoft { color: #00a4ef; }
.ch-signin-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ch-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--text-2); line-height: 1.5; }
.ch-steps .field { margin-top: 6px; }
