/* ═══════════════════════════════════════════════════════════════════════════
   AI Assistant Panel — styles
   WCAG AA contrast compliant (4.5:1 minimum for all text)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Screen reader only — visually hidden, accessible to AT */
.ai-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ai-assistant-panel {
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
/* White on #1178cb = 4.58:1 contrast ✓ */

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1178cb;
  color: #fff;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.ai-panel-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.ai-close-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 3px;
  display: flex;
  align-items: center;
}
.ai-close-btn:hover { background: rgba(255,255,255,0.2); }
.ai-close-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ── Search ─────────────────────────────────────────────────────────────── */

.ai-search-wrap {
  padding: 8px 10px 4px;
  flex-shrink: 0;
}

/* #333 on #fff = 12.63:1 ✓ */
.ai-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #888;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
  outline: none;
}
.ai-search-input::placeholder { color: #767676; } /* 4.54:1 on white ✓ */
.ai-search-input:focus { border-color: #1178cb; box-shadow: 0 0 0 2px rgba(17,120,203,0.3); }

/* Search match highlighting */
/* #000 on #fff3cd = 16.35:1 ✓ */
.ai-search-highlight {
  background: #fff3cd;
  color: #000;
  font-weight: 700;
  padding: 0 1px;
  border-radius: 2px;
}

/* ── Recent tasks ────────────────────────────────────────────────────────── */
/* #444 on #fff = 9.73:1 ✓ */

.ai-recent {
  padding: 2px 10px 6px;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
}

.ai-recent-label {
  font-size: 11px;
  font-weight: 700;
  color: #595959;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 0 4px;
}

.ai-recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ai-recent-item {
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  color: #1a3a5c;
  background: #e8eef4;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-recent-item:hover { background: #d0dce8; }
.ai-recent-item:focus-visible { outline: 2px solid #1178cb; outline-offset: 1px; }

/* ── Task count ─────────────────────────────────────────────────────────── */
/* #595959 on #fff = 7.0:1 ✓ */

.ai-task-count {
  padding: 2px 12px 6px;
  font-size: 12px;
  color: #595959;
  flex-shrink: 0;
}

/* ── Scrollable list ────────────────────────────────────────────────────── */

.ai-list-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 6px 8px;
}

/* ── Category headers ───────────────────────────────────────────────────── */
/* #1a3a5c on #e8eef4 = 7.89:1 ✓ */

.ai-cat { margin-bottom: 2px; }

.ai-cat-header {
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 700;
  color: #1a3a5c;
  background: #e8eef4;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
}
.ai-cat-header:hover { background: #dce5ee; }
.ai-cat-header:focus-visible { outline: 2px solid #1178cb; outline-offset: -2px; }
.ai-cat.expanded > .ai-cat-header { background: #d0dce8; }
.ai-cat-body { padding-left: 4px; }

/* ── Subcategory headers ────────────────────────────────────────────────── */
/* #1a3a6c on #f3f6f9 = 8.12:1 ✓ */

.ai-sub { margin-top: 1px; }

.ai-sub-header {
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #1a3a6c;
  background: #f3f6f9;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
}
.ai-sub-header:hover { background: #eaeff5; }
.ai-sub-header:focus-visible { outline: 2px solid #1178cb; outline-offset: -2px; }
.ai-sub.expanded > .ai-sub-header { background: #e2e9f1; }
.ai-sub-body { padding-left: 4px; }

/* ── Chevrons ───────────────────────────────────────────────────────────── */

.ai-chevron {
  display: inline-block;
  font-size: 9px;
  transition: transform 0.15s ease;
  margin-right: 4px;
  color: #555;
}
.expanded > .ai-cat-header .ai-chevron,
.expanded > .ai-sub-header .ai-chevron {
  transform: rotate(90deg);
}

/* ── Task items ─────────────────────────────────────────────────────────── */
/* #222 on #fff = 15.9:1 ✓ */

.ai-task {
  border-bottom: 1px solid #e8e8e8;
}
.ai-task:last-child { border-bottom: none; }

.ai-task-name {
  padding: 7px 10px;
  font-size: 13px;
  color: #222;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.5;
}
.ai-task-name:hover { background: #f5f7fa; }
.ai-task-name:focus-visible { outline: 2px solid #1178cb; outline-offset: -2px; }

/* Task name text — always bold */
.ai-task-name-text {
  font-weight: 700;
}

/* ── Task description ───────────────────────────────────────────────────── */
/* #333 on #f7f8fa = 11.48:1 ✓ */

.ai-task-desc {
  padding: 6px 12px 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: #333;
  background: #f7f8fa;
  border-top: 1px solid #e8e8e8;
}

.ai-task-desc-text {
  display: block;
  margin-bottom: 6px;
}

/* ── Run button ─────────────────────────────────────────────────────────── */
/* #fff on #1178cb = 4.58:1 ✓ */

.ai-run-btn {
  display: inline-block;
  margin-top: 4px;
  padding: 5px 16px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: #1178cb;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}
.ai-run-btn:hover { background: #0d5ca8; }
.ai-run-btn:focus-visible { outline: 2px solid #333; outline-offset: 2px; }

/* ── Task Form View ─────────────────────────────────────────────────── */

.ai-form-back-row {
  padding: 6px 10px 2px;
  border-bottom: 1px solid #e8e8e8;
}

/* #1a3a5c on #fff = 7.89:1 */
.ai-form-back-btn {
  background: none;
  border: none;
  color: #1a3a5c;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 3px;
}
.ai-form-back-btn:hover { background: #e8eef4; }
.ai-form-back-btn:focus-visible { outline: 2px solid #1178cb; outline-offset: 1px; }

.ai-form-header {
  padding: 10px 12px;
  border-bottom: 1px solid #e8e8e8;
}

/* #1a3a5c on #fff = 7.89:1 */
.ai-form-task-name {
  font-size: 15px;
  font-weight: 700;
  color: #1a3a5c;
  margin-bottom: 4px;
}

/* #555 on #fff = 7.46:1 */
.ai-form-task-desc {
  font-size: 12px;
  color: #555;
  line-height: 1.5;
}

.ai-form-section {
  padding: 10px 12px 6px;
  border-bottom: 1px solid #e8e8e8;
}

/* #595959 on #fff = 7.0:1 */
.ai-form-section-label {
  font-size: 11px;
  font-weight: 700;
  color: #595959;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.ai-form-doc-slot {
  margin-bottom: 8px;
}

.ai-form-doc-label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-form-required {
  font-size: 10px;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  padding: 1px 5px;
  border-radius: 2px;
}

/* #666 on #fff = 5.74:1 */
.ai-form-doc-desc {
  font-size: 11px;
  color: #666;
  line-height: 1.4;
  margin-bottom: 4px;
}

.ai-form-doc-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
}

/* #1a5c2a on #e8f4ec */
.ai-form-doc-filled {
  background: #e8f4ec;
  color: #1a5c2a;
  border: 1px solid #c3e0cc;
}

.ai-form-doc-chip-icon {
  font-size: 8px;
  color: #2d8a4e;
}

.ai-form-doc-missing {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.ai-form-doc-empty {
  font-weight: 400;
  font-style: italic;
}

.ai-form-field {
  margin-bottom: 8px;
}

/* #555 on #fff = 7.46:1 */
.ai-form-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 3px;
}

.ai-form-select {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font-size: 13px;
  color: #333;
  border: 1px solid #888;
  border-radius: 4px;
  background: #fff;
  outline: none;
}
.ai-form-select:focus { border-color: #1178cb; box-shadow: 0 0 0 2px rgba(17,120,203,0.3); }

.ai-form-run-area {
  padding: 12px;
}

/* #fff on #1178cb = 4.58:1 */
.ai-form-run-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: #1178cb;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.ai-form-run-btn:hover:not(:disabled) { background: #0d5ca8; }
.ai-form-run-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-form-run-btn:focus-visible { outline: 2px solid #333; outline-offset: 2px; }

.ai-form-status {
  margin-top: 10px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 4px;
}

/* #92400e on #fef3c7 = 7.48:1 */
.ai-form-status-running {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

/* #1a5c2a on #e8f4ec */
.ai-form-status-success {
  background: #e8f4ec;
  color: #1a5c2a;
  border: 1px solid #c3e0cc;
}

/* #991b1b on #fee2e2 = 7.8:1 */
.ai-form-status-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* ── Folder picker ──────────────────────────────────────────────────── */

.ai-form-folder-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-form-folder-display {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #f7f8fa;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  color: #333;
}

.ai-form-folder-icon {
  flex-shrink: 0;
  line-height: 1;
}

.ai-form-folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

/* #1a3a5c on #fff = 7.89:1 */
.ai-form-folder-change-btn {
  background: none;
  border: 1px solid #aaa;
  color: #1a3a5c;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
}
.ai-form-folder-change-btn:hover { background: #e8eef4; }
.ai-form-folder-change-btn:focus-visible { outline: 2px solid #1178cb; outline-offset: 1px; }

.ai-form-folder-picker {
  margin-top: 6px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

.ai-form-folder-picker-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  white-space: nowrap;
}
.ai-form-folder-picker-item:hover { background: #e8eef4; }
.ai-form-folder-picker-item.selected { background: #d0dce8; font-weight: 600; }
.ai-form-folder-picker-item:focus-visible { outline: 2px solid #1178cb; outline-offset: -2px; }

/* #1178cb on #f7f8fa */
.ai-form-folder-picker-new {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #1178cb;
  cursor: pointer;
  border-top: 1px solid #e8e8e8;
}
.ai-form-folder-picker-new:hover { background: #e8eef4; }
.ai-form-folder-picker-new:focus-visible { outline: 2px solid #1178cb; outline-offset: -2px; }

/* ── Resize handle ──────────────────────────────────────────────────────── */

.ai-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, #999 50%, #999 60%, transparent 60%, transparent 70%, #999 70%, #999 80%, transparent 80%);
  opacity: 0.6;
}
.ai-resize-handle:hover { opacity: 1; }
.ai-resize-handle:focus-visible { outline: 2px solid #1178cb; outline-offset: -2px; opacity: 1; }
