/* AI Theme Editor — Admin Settings Page Styles */

:root {
  --aite-bg: #111111;
  --aite-surface: #1a1a1a;
  --aite-surface2: #222222;
  --aite-surface3: #2a2a2a;
  --aite-border: #333333;
  --aite-text: #eeeeee;
  --aite-dim: #777777;
  --aite-accent: #0099ff;
  --aite-red: #ef4444;
  --aite-green: #22c55e;
  --aite-orange: #f59e0b;
  --aite-radius: 10px;
}

/* ─── Page wrapper ────────────────────────────────────────────────────── */
.aite-settings {
  max-width: 860px;
  margin: 24px 20px 60px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--aite-text);
}

.aite-settings *,
.aite-settings *::before,
.aite-settings *::after {
  box-sizing: border-box;
}

/* ─── Page header ─────────────────────────────────────────────────────── */
.aite-settings .aite-page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--aite-text);
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.aite-settings .aite-page-subtitle {
  font-size: 13px;
  color: var(--aite-dim);
  margin: 0 0 28px;
}

/* ─── Cards ───────────────────────────────────────────────────────────── */
.aite-card {
  background: var(--aite-surface);
  border: 1px solid var(--aite-border);
  border-radius: var(--aite-radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.aite-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--aite-border);
  background: var(--aite-surface2);
  display: flex;
  align-items: center;
  gap: 10px;
}

.aite-card-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--aite-text);
  margin: 0;
  padding: 0;
  border: none;
}

.aite-card-header .aite-card-icon {
  font-size: 16px;
  line-height: 1;
}

.aite-card-body {
  padding: 20px;
}

/* ─── Form rows ───────────────────────────────────────────────────────── */
.aite-field {
  margin-bottom: 18px;
}

.aite-field:last-child {
  margin-bottom: 0;
}

.aite-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--aite-text);
  margin-bottom: 6px;
}

.aite-description {
  font-size: 11.5px;
  color: var(--aite-dim);
  margin-top: 5px;
  line-height: 1.5;
}

/* ─── Inputs ──────────────────────────────────────────────────────────── */
.aite-settings input[type="text"],
.aite-settings input[type="password"],
.aite-settings input[type="number"],
.aite-settings select,
.aite-settings textarea {
  width: 100%;
  max-width: 480px;
  background: var(--aite-surface2);
  border: 1px solid var(--aite-border);
  border-radius: 7px;
  color: var(--aite-text);
  font-size: 13px;
  padding: 8px 11px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.aite-settings input:focus,
.aite-settings select:focus,
.aite-settings textarea:focus {
  border-color: var(--aite-accent);
  box-shadow: 0 0 0 2px rgba(0, 153, 255, 0.15);
}

.aite-settings input::placeholder,
.aite-settings textarea::placeholder {
  color: var(--aite-dim);
}

.aite-settings select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23777' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

/* API key row with inline button */
.aite-input-with-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 480px;
}

.aite-input-with-btn input {
  flex: 1;
  max-width: none;
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.aite-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
  outline: none;
  font-family: inherit;
}

.aite-btn--primary {
  background: var(--aite-accent);
  color: #ffffff;
}

.aite-btn--primary:hover {
  background: #0088ee;
}

.aite-btn--secondary {
  background: var(--aite-surface2);
  color: var(--aite-text);
  border: 1px solid var(--aite-border);
}

.aite-btn--secondary:hover {
  background: var(--aite-surface3);
}

.aite-btn--danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--aite-red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.aite-btn--danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.aite-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Save button row */
.aite-save-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
}

.aite-btn--save {
  background: var(--aite-accent);
  color: #ffffff;
  height: 40px;
  padding: 0 24px;
  font-size: 14px;
}

.aite-btn--save:hover {
  background: #0088ee;
}

/* ─── Radio group ─────────────────────────────────────────────────────── */
.aite-radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.aite-radio-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--aite-border);
  background: var(--aite-surface2);
  transition: border-color 0.15s, background 0.15s;
}

.aite-radio-label:hover {
  border-color: var(--aite-accent);
  background: var(--aite-surface3);
}

.aite-radio-label input[type="radio"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  max-width: 16px;
  margin-top: 2px;
  accent-color: var(--aite-accent);
  cursor: pointer;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
}

.aite-radio-label.aite-radio-selected {
  border-color: var(--aite-accent);
  background: rgba(0, 153, 255, 0.07);
}

.aite-radio-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--aite-text);
  margin-bottom: 2px;
}

.aite-radio-text span {
  font-size: 12px;
  color: var(--aite-dim);
}

/* ─── Own-key section (hidden/shown via JS) ───────────────────────────── */
#aite-own-key-section {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--aite-border);
  border-radius: 8px;
  background: var(--aite-surface2);
  display: none;
}

#aite-own-key-section.aite-visible {
  display: block;
  animation: aite-fade-in-down 0.2s ease;
}

/* ─── Verify status ───────────────────────────────────────────────────── */
.aite-verify-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  margin-left: 4px;
}

.aite-verify-status--ok    { color: var(--aite-green); }
.aite-verify-status--error { color: var(--aite-red); }
.aite-verify-status--busy  { color: var(--aite-dim); }

/* ─── Checkboxes / Permissions ────────────────────────────────────────── */
.aite-perm-section {
  margin-bottom: 18px;
}

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

.aite-perm-category {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--aite-dim);
  margin-bottom: 8px;
}

.aite-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.aite-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--aite-text);
  padding: 7px 10px;
  border-radius: 7px;
  background: var(--aite-surface2);
  border: 1px solid var(--aite-border);
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}

.aite-check-label:hover {
  background: var(--aite-surface3);
  border-color: #444;
}

.aite-check-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  min-width: 15px;
  accent-color: var(--aite-accent);
  cursor: pointer;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  max-width: 15px;
}

.aite-perm-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.aite-perm-actions button {
  font-size: 11.5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 5px;
  background: var(--aite-surface2);
  border: 1px solid var(--aite-border);
  color: var(--aite-dim);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.aite-perm-actions button:hover {
  color: var(--aite-text);
  background: var(--aite-surface3);
}

/* ─── Demo counter progress bar ──────────────────────────────────────── */
.aite-demo-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.aite-demo-label {
  font-size: 12.5px;
  color: var(--aite-text);
}

.aite-demo-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--aite-green);
}

.aite-demo-count.aite-warn   { color: var(--aite-orange); }
.aite-demo-count.aite-danger { color: var(--aite-red); }

.aite-progress-track {
  width: 100%;
  height: 6px;
  background: var(--aite-surface3);
  border-radius: 3px;
  overflow: hidden;
}

.aite-progress-fill {
  height: 100%;
  background: var(--aite-green);
  border-radius: 3px;
  transition: width 0.4s ease, background 0.3s;
}

.aite-progress-fill.aite-warn   { background: var(--aite-orange); }
.aite-progress-fill.aite-danger { background: var(--aite-red); }

/* ─── Toast notification ──────────────────────────────────────────────── */
.aite-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--aite-surface);
  border: 1px solid var(--aite-border);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--aite-text);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.aite-toast.aite-toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.aite-toast--success { border-color: rgba(34, 197, 94, 0.4); }
.aite-toast--error   { border-color: rgba(239, 68, 68, 0.4); }

.aite-toast__icon { font-size: 15px; }

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .aite-settings {
    margin: 16px 12px 40px;
  }

  .aite-checkbox-grid {
    grid-template-columns: 1fr 1fr;
  }

  .aite-input-with-btn {
    flex-wrap: wrap;
  }

  .aite-save-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .aite-checkbox-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Animations ──────────────────────────────────────────────────────── */
@keyframes aite-fade-in-down {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
