/* AppContextPanel — collapsible goals/gradient/readiness panel
 *
 * Drop-in alongside app-context-panel.js. Reuses starcontrol's CSS variables
 * (--bg, --bg2, --fg, --brand, --border, --good).
 */

.ctx-panel {
  border-bottom: 1px solid var(--border, #2a2a4a);
  flex-shrink: 0;
}

/* --- Header --- */

.ctx-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  cursor: pointer;
  user-select: none;
}

.ctx-panel-header:hover {
  background: rgba(255, 255, 255, 0.02);
}

.ctx-panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg, #e0e0e0);
}

.ctx-readiness-badge {
  font-size: 10px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 10px;
  letter-spacing: 0.3px;
}

.ctx-readiness-badge.ready {
  background: rgba(53, 196, 111, 0.15);
  color: var(--good, #35c46f);
  border: 1px solid rgba(53, 196, 111, 0.25);
}

.ctx-readiness-badge.not-ready {
  background: rgba(255, 107, 107, 0.15);
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.25);
}

.ctx-loss-badge {
  font-size: 10px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.25);
  font-family: monospace;
}

.ctx-edit-btn,
.ctx-refresh-btn,
.ctx-collapse-btn {
  background: none;
  border: none;
  color: rgba(224, 224, 224, 0.4);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  line-height: 1;
}

.ctx-edit-btn:hover,
.ctx-refresh-btn:hover,
.ctx-collapse-btn:hover {
  color: var(--fg, #e0e0e0);
}

.ctx-collapse-btn {
  margin-left: auto;
}

/* --- Body --- */

.ctx-panel-body {
  padding: 2px 14px 10px;
  max-height: 340px;
  overflow-y: auto;
}

.ctx-panel.collapsed .ctx-panel-body {
  display: none;
}

/* --- Sections --- */

.ctx-section {
  margin-bottom: 8px;
}

.ctx-section:last-child {
  margin-bottom: 0;
}

.ctx-section-title {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(224, 224, 224, 0.4);
  margin-bottom: 3px;
}

/* --- Goals table --- */

.ctx-goals-table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
}

.ctx-goals-table th {
  text-align: left;
  color: rgba(224, 224, 224, 0.5);
  font-weight: 500;
  padding: 2px 6px;
  border-bottom: 1px solid var(--border, #2a2a4a);
}

.ctx-goals-table td {
  padding: 2px 6px;
}

.ctx-goals-table tr.ctx-met td {
  color: var(--good, #35c46f);
}

.ctx-goals-table tr.ctx-unmet td {
  color: var(--fg, #e0e0e0);
}

.ctx-status-icon {
  text-align: center;
  font-size: 8px;
}

/* --- Gradient entries --- */

.ctx-gradient-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ctx-gradient-entry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg2, #16213e);
  border: 1px solid var(--border, #2a2a4a);
}

.ctx-grad-element {
  font-weight: 600;
  color: var(--fg, #e0e0e0);
}

.ctx-grad-metric {
  color: rgba(224, 224, 224, 0.5);
}

.ctx-grad-value {
  font-family: monospace;
  color: #eab308;
}

.ctx-grad-dir {
  font-size: 10px;
  color: rgba(224, 224, 224, 0.4);
}

/* --- Readiness details --- */

.ctx-readiness-details {
  font-size: 11px;
  color: rgba(224, 224, 224, 0.6);
}

/* --- Status metrics --- */

.ctx-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.ctx-metric-card {
  min-width: 0;
  border: 1px solid var(--border, #2a2a4a);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.025);
  padding: 6px;
}

.ctx-metric-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.ctx-metric-label {
  min-width: 0;
  overflow: hidden;
  color: rgba(224, 224, 224, 0.5);
  font-size: 10px;
  font-weight: 600;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.ctx-metric-value {
  color: var(--fg, #e0e0e0);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ctx-chart-spark {
  width: 100%;
  height: 24px;
  margin-top: 4px;
}

.ctx-chart-empty {
  height: 24px;
  margin-top: 4px;
  border-bottom: 1px solid var(--border, #2a2a4a);
  opacity: 0.5;
}

/* --- Suggestions --- */

.ctx-suggestions {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  color: rgba(224, 224, 224, 0.6);
  line-height: 1.5;
}

.ctx-suggestions li {
  margin-bottom: 2px;
}

/* --- Info / Error --- */

.ctx-info {
  font-size: 11px;
  color: rgba(224, 224, 224, 0.4);
  font-style: italic;
  padding: 4px 0;
}

.ctx-error {
  font-size: 11px;
  color: #ff6b6b;
  padding: 4px 0;
}

.ctx-error a {
  color: var(--brand, #4a6cf7);
  text-decoration: underline;
  cursor: pointer;
}

/* --- Edit mode --- */

.ctx-edit-input,
.ctx-edit-select {
  font-size: 11px;
  font-family: inherit;
  padding: 2px 4px;
  background: var(--bg, #0a0e27);
  color: var(--fg, #e0e0e0);
  border: 1px solid var(--border, #2a2a4a);
  border-radius: 3px;
  outline: none;
}

.ctx-edit-input:focus,
.ctx-edit-select:focus {
  border-color: var(--brand, #4a6cf7);
}

.ctx-edit-table .ctx-edit-input {
  width: 100%;
  box-sizing: border-box;
}

.ctx-ed-metric { min-width: 80px; }
.ctx-ed-target { width: 60px !important; }

.ctx-btn-save {
  font-size: 11px;
  padding: 2px 10px;
  background: var(--brand, #4a6cf7);
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

.ctx-btn-save:hover { opacity: 0.85; }
.ctx-btn-save:disabled { opacity: 0.5; cursor: default; }

.ctx-btn-cancel {
  font-size: 11px;
  padding: 2px 10px;
  background: none;
  color: rgba(224, 224, 224, 0.6);
  border: 1px solid var(--border, #2a2a4a);
  border-radius: 3px;
  cursor: pointer;
}

.ctx-btn-cancel:hover { color: var(--fg, #e0e0e0); }
.ctx-btn-cancel:disabled { opacity: 0.5; cursor: default; }

.ctx-btn-remove {
  background: none;
  border: none;
  color: #ff6b6b;
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  line-height: 1;
}

.ctx-btn-remove:hover { color: #ff4444; }

.ctx-btn-add {
  font-size: 11px;
  padding: 3px 8px;
  margin-top: 4px;
  background: none;
  color: var(--brand, #4a6cf7);
  border: 1px dashed var(--border, #2a2a4a);
  border-radius: 3px;
  cursor: pointer;
  width: 100%;
}

.ctx-btn-add:hover {
  border-color: var(--brand, #4a6cf7);
  background: rgba(74, 108, 247, 0.05);
}

.ctx-lr-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 8px;
  align-items: center;
}

.ctx-lr-label {
  font-size: 11px;
  color: rgba(224, 224, 224, 0.5);
}

.ctx-lr-input {
  width: 70px;
}

.ctx-save-error {
  font-size: 11px;
  color: #ff6b6b;
  padding: 4px 0;
  margin-top: 4px;
}

/* --- Loading skeleton --- */

.ctx-skeleton {
  height: 10px;
  background: var(--bg2, #16213e);
  border-radius: 4px;
  animation: ctx-pulse 1.5s infinite;
}

@keyframes ctx-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* --- Scrollbar --- */

.ctx-panel-body::-webkit-scrollbar {
  width: 4px;
}

.ctx-panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.ctx-panel-body::-webkit-scrollbar-thumb {
  background: rgba(224, 224, 224, 0.1);
  border-radius: 2px;
}
