/* ═══════════════════════════════════════════════════════════════════════════
   AI Studio — Preferences Panel
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Panel container ──────────────────────────────────────────────────────── */

.preferences-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--white);
  z-index: 6;
  overflow: hidden;
}

.prefs-scroll {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.prefs-container {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 28px 48px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

.prefs-header {
  margin-bottom: 28px;
}

.prefs-title {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--charcoal);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.prefs-subtitle {
  font-size: 0.86rem;
  color: var(--slate-500);
  line-height: 1.5;
}

/* ── Sections ─────────────────────────────────────────────────────────────── */

.prefs-section {
  margin-bottom: 28px;
}

.prefs-section-title {
  font-family: "Inter", sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--charcoal);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.prefs-section-desc {
  font-size: 0.82rem;
  color: var(--slate-500);
  line-height: 1.45;
  margin-bottom: 14px;
}

/* ── Client cards ─────────────────────────────────────────────────────────── */

.prefs-client-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prefs-client-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--slate-50);
  border: 1.5px solid var(--slate-200);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  user-select: none;
}

.prefs-client-card:hover {
  border-color: var(--slate-300);
  background: var(--white);
}

.prefs-client-card.selected {
  border-color: var(--blue);
  background: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.08);
}

/* ── Forced client (AI_STUDIO_CLIENT set) ─────────────────────────────────── */

.prefs-forced-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prefs-forced-client {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--slate-50);
  border: 1.5px solid var(--slate-200);
  border-radius: 10px;
}


.prefs-client-radio {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 2px solid var(--slate-300);
  border-radius: 50%;
  position: relative;
  transition: border-color 0.15s;
}

.prefs-client-card.selected .prefs-client-radio {
  border-color: var(--blue);
}

.prefs-client-radio::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s;
}

.prefs-client-card.selected .prefs-client-radio::after {
  transform: translate(-50%, -50%) scale(1);
}

.prefs-client-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--white);
}

.prefs-client-icon[data-client="claude-code"]  { background: #d97706; }
.prefs-client-icon[data-client="gemini-cli"]   { background: #4285f4; }
.prefs-client-icon[data-client="codex-cli"]    { background: #10a37f; }

.prefs-client-info {
  flex: 1;
  min-width: 0;
}

.prefs-client-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--charcoal);
}

.prefs-client-id {
  font-size: 0.74rem;
  color: var(--slate-400);
  font-family: "SF Mono", "Fira Code", monospace;
}

/* ── Execution mode ───────────────────────────────────────────────────────── */

.prefs-mode-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prefs-mode-option {
  cursor: pointer;
}

.prefs-mode-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.prefs-mode-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 16px;
  background: var(--slate-50);
  border: 1.5px solid var(--slate-200);
  border-radius: 10px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.prefs-mode-option:hover .prefs-mode-card {
  border-color: var(--slate-300);
  background: var(--white);
}

.prefs-mode-option input:checked + .prefs-mode-card {
  border-color: var(--blue);
  background: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.08);
}

.prefs-mode-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--charcoal);
}

.prefs-mode-desc {
  font-size: 0.78rem;
  color: var(--slate-500);
  line-height: 1.4;
}

.prefs-mode-option input:checked + .prefs-mode-card .prefs-mode-label {
  color: var(--blue);
}

/* ── API key field ────────────────────────────────────────────────────────── */

.prefs-key-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prefs-key-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.prefs-input {
  width: 100%;
  height: 44px;
  padding: 0 42px 0 14px;
  font-size: 0.88rem;
  font-family: "SF Mono", "Fira Code", "Courier New", monospace;
  color: var(--charcoal);
  background: var(--slate-50);
  border: 1.5px solid var(--slate-200);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.prefs-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
  background: var(--white);
}

.prefs-input::placeholder {
  font-family: "Inter", sans-serif;
  color: var(--slate-400);
}

.prefs-key-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--slate-400);
  transition: color 0.15s, background 0.15s;
}

.prefs-key-toggle:hover {
  color: var(--slate-600);
  background: var(--slate-100);
}

.prefs-key-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.prefs-key-status {
  font-size: 0.8rem;
  line-height: 1.4;
  min-height: 1.12em;
}

.prefs-key-status.status-set {
  color: var(--green);
}

.prefs-key-status.status-missing {
  color: var(--amber);
}

.prefs-key-status.status-error {
  color: var(--red);
}

.prefs-key-link {
  font-size: 0.8rem;
}

.prefs-key-link a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}

.prefs-key-link a:hover {
  text-decoration: underline;
}

/* ── Actions ──────────────────────────────────────────────────────────────── */

.prefs-actions {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--slate-200);
}

.prefs-message {
  min-height: 32px;
  margin-bottom: 12px;
  padding: 0;
  font-size: 0.84rem;
  line-height: 1.45;
  border-radius: 8px;
  transition: opacity 0.2s;
}

.prefs-message:empty {
  display: none;
}

.prefs-message.msg-success {
  display: block;
  padding: 10px 14px;
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.prefs-message.msg-error {
  display: block;
  padding: 10px 14px;
  color: var(--red);
  background: var(--red-light);
  border: 1px solid var(--red-border);
}

.prefs-message.msg-info {
  display: block;
  padding: 10px 14px;
  color: var(--blue);
  background: var(--blue-light);
  border: 1px solid var(--blue-mid);
}

.prefs-btn-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.prefs-btn {
  height: 40px;
  padding: 0 20px;
  font-size: 0.86rem;
  font-weight: 600;
  font-family: "Plus Jakarta Sans", sans-serif;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  white-space: nowrap;
}

.prefs-btn:active {
  transform: scale(0.98);
}

.prefs-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.prefs-btn-primary {
  color: var(--white);
  background: var(--blue);
}

.prefs-btn-primary:hover:not(:disabled) {
  background: var(--blue-hover);
}

.prefs-btn-secondary {
  color: var(--slate-600);
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
}

.prefs-btn-secondary:hover:not(:disabled) {
  background: var(--slate-200);
}

/* ── Settings button in panel header ──────────────────────────────────────── */

.panel-settings-btn {
  margin-left: auto;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  color: var(--slate-400);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.panel-settings-btn:hover {
  color: var(--slate-600);
  background: var(--slate-200);
}

.panel-settings-btn.active {
  color: var(--blue);
  background: var(--blue-light);
}

.panel-settings-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .prefs-container {
    padding: 24px 16px 36px;
  }

  .prefs-title {
    font-size: 1.15rem;
  }

  .prefs-btn-row {
    flex-direction: column;
  }

  .prefs-btn {
    width: 100%;
    text-align: center;
  }
}
