/* InX AI Customer Support Portal — styles
 * Phase 35: adds nav tabs, prompt-improvement runs/detail pages, candidate modal.
 */

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f7fa; color: #1a1a2e; }

.header { background: #1a1a2e; color: #fff; padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; }
.header h1 { font-size: 18px; font-weight: 600; }
.header button { background: rgba(255,255,255,0.15); border: none; color: #fff; padding: 6px 14px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.header button:hover { background: rgba(255,255,255,0.25); }

.container { max-width: 1080px; margin: 32px auto; padding: 0 24px; }

/* Login */
.login-box { max-width: 360px; margin: 120px auto; background: #fff; padding: 40px; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.login-box h2 { margin-bottom: 24px; font-size: 20px; text-align: center; }
.login-box input { width: 100%; padding: 10px 12px; border: 1px solid #d0d5dd; border-radius: 6px; font-size: 14px; margin-bottom: 16px; }
.login-box input:focus { outline: none; border-color: #4a6cf7; box-shadow: 0 0 0 3px rgba(74,108,247,0.1); }
.login-box .btn-login { width: 100%; padding: 10px; background: #4a6cf7; color: #fff; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; }
.login-box .btn-login:hover { background: #3b5de7; }
.login-error { color: #e53e3e; font-size: 13px; margin-bottom: 12px; display: none; }

/* Nav tabs */
#navTabs { background: #fff; border-bottom: 1px solid #e8e8e8; padding: 0 24px; display: flex; gap: 8px; }
#navTabs .tab { background: transparent; border: none; padding: 14px 18px; font-size: 14px; color: #555; cursor: pointer; border-bottom: 2px solid transparent; }
#navTabs .tab:hover { color: #1a1a2e; }
#navTabs .tab.active { color: #4a6cf7; border-bottom-color: #4a6cf7; font-weight: 600; }

/* List */
.page-title { font-size: 20px; font-weight: 600; margin-bottom: 20px; }
table { width: 100%; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); border-collapse: collapse; }
th { background: #f8f9fb; text-align: left; padding: 12px 16px; font-size: 13px; color: #667; font-weight: 600; border-bottom: 1px solid #e8e8e8; }
td { padding: 12px 16px; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fb; }
.cat-id { color: #888; font-family: monospace; font-size: 12px; }
.preview { color: #555; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: #999; font-size: 12px; }
.btn-edit { background: #4a6cf7; color: #fff; border: none; padding: 5px 14px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.btn-edit:hover { background: #3b5de7; }

/* Edit */
.edit-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.edit-header h2 { font-size: 18px; }
.btn-back { background: none; border: 1px solid #d0d5dd; padding: 6px 14px; border-radius: 4px; cursor: pointer; font-size: 13px; color: #555; }
.btn-back:hover { background: #f5f5f5; }
.edit-card { background: #fff; border-radius: 8px; padding: 24px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.edit-card label { display: block; font-size: 13px; font-weight: 600; color: #555; margin-bottom: 8px; }
.edit-card textarea { width: 100%; min-height: 420px; padding: 12px; border: 1px solid #d0d5dd; border-radius: 6px; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px; line-height: 1.6; resize: vertical; }
.edit-card textarea:focus { outline: none; border-color: #4a6cf7; box-shadow: 0 0 0 3px rgba(74,108,247,0.1); }
.edit-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.btn-save { background: #16a34a; color: #fff; border: none; padding: 8px 24px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.btn-save:hover { background: #15803d; }
.btn-save:disabled { background: #ccc; cursor: not-allowed; }
.save-status { font-size: 13px; color: #16a34a; }
.edit-meta { margin-top: 12px; font-size: 12px; color: #999; }

/* Phase 35: prompt-improvement runs / detail / candidate */

.run-summary { background: #fff; border-radius: 8px; padding: 16px 20px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.run-summary h2 { font-size: 16px; margin-bottom: 8px; }
.run-summary .meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; font-size: 13px; color: #555; }
.run-summary .meta-grid div { line-height: 1.5; }
.run-summary .meta-grid strong { color: #1a1a2e; }
.run-status-pill { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.run-status-running { background: #fef3c7; color: #92400e; }
.run-status-completed { background: #d1fae5; color: #065f46; }
.run-status-failed { background: #fee2e2; color: #991b1b; }

.accordion-section { background: #fff; border-radius: 8px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); overflow: hidden; }
.accordion-header { padding: 14px 20px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; background: #f8f9fb; border-bottom: 1px solid #e8e8e8; user-select: none; }
.accordion-header:hover { background: #eef1f6; }
.accordion-header.collapsed { border-bottom: none; }
.accordion-header .cat-name { font-weight: 600; font-size: 14px; }
.accordion-header .cat-counts { font-size: 12px; color: #888; }
.accordion-header .caret { font-size: 12px; color: #888; transition: transform 0.15s; }
.accordion-header.collapsed .caret { transform: rotate(-90deg); }
.accordion-body { padding: 0; }
.accordion-body.collapsed { display: none; }

.candidate-card { padding: 12px 20px; border-bottom: 1px solid #f0f0f0; display: flex; align-items: center; gap: 12px; }
.candidate-card:last-child { border-bottom: none; }
.candidate-card:hover { background: #f8f9fb; cursor: pointer; }
.candidate-card .mode-badge { background: #eef2ff; color: #4338ca; font-size: 11px; padding: 3px 8px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.candidate-card .mode-badge.knowledge-gap { background: #fef3c7; color: #92400e; }
.candidate-card .mode-badge.prompt-ambiguity { background: #ede9fe; color: #5b21b6; }
.candidate-card .mode-badge.edge-case { background: #cffafe; color: #155e75; }
.candidate-card .mode-badge.language-issue { background: #fce7f3; color: #9d174d; }
.candidate-card .mode-badge.out-of-scope { background: #f3f4f6; color: #4b5563; }
.candidate-card .mode-badge.persona-mismatch { background: #ffe4e6; color: #9f1239; }
.candidate-card .mode-badge.other { background: #e5e7eb; color: #374151; }
.candidate-card .status-badge { font-size: 11px; padding: 3px 8px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.candidate-card .status-pending { background: #f3f4f6; color: #4b5563; }
.candidate-card .status-approved { background: #d1fae5; color: #065f46; }
.candidate-card .status-deferred { background: #fef3c7; color: #92400e; }
.candidate-card .status-rejected { background: #fee2e2; color: #991b1b; }
.candidate-card .candidate-text { flex: 1; font-size: 13px; color: #555; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.confidence-bar { width: 80px; height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; position: relative; flex-shrink: 0; }
.confidence-bar > span { display: block; height: 100%; background: #4a6cf7; border-radius: 3px; }
.confidence-bar.high > span { background: #16a34a; }
.confidence-bar.med > span { background: #f59e0b; }
.confidence-bar.low > span { background: #dc2626; }
.confidence-label { font-size: 11px; color: #888; font-variant-numeric: tabular-nums; width: 36px; text-align: right; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; }
.modal-card { background: #fff; border-radius: 8px; max-width: 920px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.modal-header { padding: 16px 24px; border-bottom: 1px solid #e8e8e8; display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 16px; }
.modal-header .btn-close { background: transparent; border: none; font-size: 20px; cursor: pointer; color: #888; }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-section { margin-bottom: 18px; }
.modal-section h3 { font-size: 13px; color: #555; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }

.lang-notice { background: #fef3c7; border-left: 3px solid #f59e0b; padding: 10px 14px; font-size: 13px; color: #78350f; margin-bottom: 16px; border-radius: 4px; }

.evidence-conv { border: 1px solid #e8e8e8; border-radius: 6px; margin-bottom: 12px; overflow: hidden; }
.evidence-conv-header { background: #f8f9fb; padding: 8px 12px; font-size: 12px; color: #555; border-bottom: 1px solid #e8e8e8; font-family: monospace; }
.evidence-transcript { padding: 12px; max-height: 320px; overflow-y: auto; background: #fafbfc; }
.evidence-message { padding: 6px 12px; margin-bottom: 6px; border-radius: 6px; max-width: 80%; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.evidence-message .actor-tag { font-size: 10px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.evidence-message.customer { background: #e0f2fe; color: #0c4a6e; margin-right: auto; }
.evidence-message.ai { background: #f3f4f6; color: #1f2937; margin-left: auto; text-align: left; }
.evidence-message.agent { background: #fef3c7; color: #78350f; margin-left: auto; }
.evidence-message.system { background: #e5e7eb; color: #4b5563; font-style: italic; max-width: 100%; text-align: center; font-size: 11px; }
.evidence-message.template { background: #ede9fe; color: #4c1d95; margin-left: auto; }

.candidate-meta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; font-size: 13px; }
.candidate-meta-grid div { padding: 8px 10px; background: #f8f9fb; border-radius: 4px; }
.candidate-meta-grid strong { color: #1a1a2e; }
.candidate-meta-grid .rationale { grid-column: span 2; }

#suggestedAdditionEdit { width: 100%; min-height: 120px; padding: 10px; border: 1px solid #d0d5dd; border-radius: 6px; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px; line-height: 1.5; resize: vertical; }
#suggestedAdditionEdit:focus { outline: none; border-color: #4a6cf7; box-shadow: 0 0 0 3px rgba(74,108,247,0.1); }

.modal-footer { padding: 14px 24px; border-top: 1px solid #e8e8e8; display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.modal-footer .btn { padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; font-weight: 600; }
.modal-footer .btn-approve { background: #16a34a; color: #fff; }
.modal-footer .btn-approve:hover { background: #15803d; }
.modal-footer .btn-reject { background: #dc2626; color: #fff; }
.modal-footer .btn-reject:hover { background: #b91c1c; }
.modal-footer .btn-defer { background: #6b7280; color: #fff; }
.modal-footer .btn-defer:hover { background: #4b5563; }
.modal-footer .btn-apply { background: #4a6cf7; color: #fff; }
.modal-footer .btn-apply:disabled { background: #c7d2fe; color: #fff; cursor: not-allowed; opacity: 0.7; }

.toast { position: fixed; bottom: 24px; right: 24px; background: #1a1a2e; color: #fff; padding: 12px 18px; border-radius: 6px; font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); z-index: 200; }
.toast.error { background: #991b1b; }
.toast.success { background: #065f46; }

.empty-state { padding: 32px 20px; text-align: center; color: #888; font-size: 14px; }

.hidden { display: none !important; }
