/* prompt-gen — matches v0gen design system (uses existing CSS variables) */

/* ─── Page layout ─── */
/* .pg-page sits inside v0gen's <main class="container"> which already caps
   width at 1200px and adds 2rem padding — so we just add bottom spacing here. */
.pg-page {
  max-width: 100%;
  margin: 0;
  padding: 0 0 3rem;
  color: var(--text-primary);
}

/* ─── Subnav ─── */
.pg-subnav {
  display: flex;
  justify-content: flex-start;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.pg-subnav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.pg-subnav-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

.pg-subnav-btn.pg-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: default;
}

/* ─── Card (matches v0gen .card) ─── */
.pg-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

/* ─── Slot ─── */
.pg-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  gap: 0.75rem;
}

.pg-slot-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.pg-slot-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.pg-slot-desc {
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin-top: 0.35rem;
}

.pg-slot-actions {
  display: flex;
  gap: 0.25rem;
}

.pg-icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.pg-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border);
}

.pg-icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pg-icon-btn.pg-danger:hover {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red);
}

/* ─── Fields ─── */
.pg-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
}

/* #303: 720px was too generous — typical phones are 375-480px wide.
   Bump grid collapse down to 640px so 2-column layout survives on tablets
   but true phones get comfortable single-column. Combined with larger
   touch-targets on inputs below. */
@media (max-width: 640px) {
  .pg-grid-2 { grid-template-columns: 1fr; }
  .pg-field input,
  .pg-field select,
  .pg-field textarea { padding: 0.8rem 0.9rem; font-size: 0.95rem; }
  .pg-btn { min-height: 44px; }  /* Apple HIG minimum touch target */
}

.pg-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pg-field label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pg-req {
  color: var(--red);
  font-weight: 700;
}

.pg-full-row { margin-top: 1rem; }

.pg-field input,
.pg-field select,
.pg-field textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.pg-field input:focus,
.pg-field select:focus,
.pg-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.pg-field textarea { resize: vertical; }

.pg-input-with-toggle { position: relative; }
.pg-input-with-toggle input { padding-right: 42px; }
.pg-input-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 6px 8px;
  opacity: 0.6;
  transition: opacity var(--transition);
  line-height: 1;
}
.pg-input-toggle:hover { opacity: 1; }

/* #808: red glow on a slot that failed validation. Auto-clears after 6s
   from JS so it doesn't linger once the user starts fixing the field. */
.pg-slot-invalid {
  outline: 2px solid var(--red, #ef4444);
  outline-offset: 4px;
  border-radius: 8px;
  animation: pg-slot-invalid-pulse 0.6s ease-in-out 2;
}
@keyframes pg-slot-invalid-pulse {
  0%, 100% { outline-color: var(--red, #ef4444); }
  50%      { outline-color: rgba(239, 68, 68, 0.35); }
}

/* #621: small ⓘ next to field labels — cursor:help nudges the browser to
   show the label's `title=` on hover. Muted so it doesn't compete with the
   required-star. */
.pg-info-icon {
  color: var(--text-muted, #6b7280);
  font-size: 0.75rem;
  cursor: help;
  opacity: 0.7;
}
.pg-field label { cursor: help; }  /* whole label triggers tooltip on hover */

/* #612: inline loading spinner used in Settings dialog "Завантаження..." rows
   so the dark background doesn't swallow the loading state. */
.pg-inline-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid var(--accent, #6366f1);
  border-top-color: transparent;
  border-radius: 50%;
  animation: pg-spin 0.7s linear infinite;
  vertical-align: -3px;
}
@keyframes pg-spin { to { transform: rotate(360deg); } }

.pg-field .pg-muted,
.pg-field small {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

/* ─── Combobox ─── */
.pg-combobox {
  position: relative;
  width: 100%;
}

.pg-combobox-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.35rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 260px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.pg-combobox-item {
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
}

.pg-combobox-item:hover {
  background: var(--bg-hover);
}

.pg-combobox-item.pg-active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-hover);
}

.pg-combobox-item .pg-check {
  color: var(--accent);
  font-weight: 700;
  visibility: hidden;
  width: 14px;
}

.pg-combobox-item.pg-active .pg-check { visibility: visible; }

/* ─── Buttons (match v0gen .btn) ─── */
.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}

.pg-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

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

.pg-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pg-btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.pg-btn-outline {
  background: transparent;
}

.pg-btn-outline:hover:not(:disabled) {
  background: var(--bg-hover);
}

.pg-btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.pg-btn-danger:hover:not(:disabled) {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.pg-full-width { width: 100%; }
.pg-large { padding: 0.85rem 2rem; font-size: 1rem; }
.pg-dashed {
  border-style: dashed;
  color: var(--text-secondary);
}

/* Extra spacing above dashed "Add slot" and above "Generate" button */
#pg-add-slot { margin-top: 1.5rem; }
#pg-generate { margin-top: 1.25rem; }

/* ─── Template combobox — colored swatch in each list item ────── */
.pg-tmpl-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-right: 0.55rem;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  vertical-align: middle;
}
.pg-combobox-item .pg-tmpl-swatch { vertical-align: -1px; }
.pg-tmpl-meta {
  color: var(--text-secondary);
  font-size: 0.78rem;
  margin-left: 0.4rem;
}

/* ─── Alerts ─── */
.pg-alert {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.pg-alert-error {
  background: var(--red-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* ─── Lite Preview badge ─── */
.pg-lite-badge {
  padding: 0.15rem 0.5rem;
  background: var(--orange-bg);
  color: var(--orange);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-left: 0.5rem;
}

/* ─── Overlays ─── */
.pg-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.pg-overlay-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.pg-overlay-card h3 {
  margin: 1rem 0 0.6rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pg-overlay-card p {
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.pg-overlay-card p.pg-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.pg-spinner {
  width: 70px;
  height: 70px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: pg-spin 0.85s linear infinite;
  margin: 0 auto;
}

@keyframes pg-spin { to { transform: rotate(360deg); } }

.pg-overlay-success {
  border-color: rgba(34, 197, 94, 0.45);
}

.pg-check-badge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--green-bg);
  color: var(--green);
  font-size: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.pg-overlay-success h3 { color: var(--green); }

.pg-success-stats {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin: 1.25rem 0;
  flex-wrap: wrap;
}

.pg-stat-box {
  padding: 0.75rem 1.25rem;
  background: var(--bg-input);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-sm);
  min-width: 100px;
}

.pg-stat-box b {
  font-size: 1.5rem;
  color: var(--green);
  display: block;
  font-weight: 700;
}

.pg-stat-box small {
  color: var(--text-secondary);
  font-size: 0.7rem;
  display: block;
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pg-keys-note {
  width: 100%;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: 0.35rem;
}

/* ─── Settings / Users dialogs ─── */
.pg-settings-card,
.pg-users-card {
  max-width: 640px;
  width: 100%;
  text-align: left;
  padding: 1.5rem;
}

.pg-settings-card,
.pg-users-card {
  position: relative;
}

.pg-dialog-head {
  margin-bottom: 1.25rem;
  padding-right: 2rem; /* room for close X */
  text-align: left;
}

.pg-dialog-head h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pg-dialog-desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0.4rem 0 0;
}

/* Close X — absolute top-right */
.pg-settings-card > .pg-dialog-head > .pg-icon-btn,
.pg-users-card > .pg-dialog-head > .pg-icon-btn,
#pg-settings-close,
#pg-users-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  border-radius: 8px;
}

/* Tabs — shadcn-style pill in bg-input container */
.pg-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  padding: 0.3rem;
  background: var(--bg-input);
  border-radius: 10px;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
}

.pg-tab {
  padding: 0.55rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  text-align: center;
}

.pg-tab:hover:not(.pg-tab-active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.pg-tab-active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--border-focus);
}

/* Outer tabs — bigger, main categories */
.pg-tabs-outer .pg-tab {
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.pg-outer-panel { min-height: 260px; }

/* ─── v0 keys table ─── */
.pg-v0-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.pg-v0-stat {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  text-align: center;
}

.pg-v0-stat b {
  font-size: 1.5rem;
  font-weight: 700;
  display: block;
}

.pg-v0-stat small {
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-top: 0.15rem;
}

.pg-v0-stat-green b { color: var(--green); }
.pg-v0-stat-yellow b { color: #eab308; }
.pg-v0-stat-blue b { color: var(--blue); }

.pg-v0-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.pg-v0-list {
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.pg-v0-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.pg-v0-table th,
.pg-v0-table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.pg-v0-table th {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  position: sticky;
  top: 0;
}

.pg-v0-table code {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.75rem;
  color: var(--text-primary);
  background: var(--bg-hover);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.pg-v0-row-green { background: rgba(34, 197, 94, 0.04); }
.pg-v0-row-yellow { background: rgba(234, 179, 8, 0.05); }
.pg-v0-row-red { opacity: 0.55; }

.pg-v0-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
}

.pg-v0-badge-green { background: var(--green); }
.pg-v0-badge-yellow { background: #eab308; color: #1a1a1a; }
.pg-v0-badge-red { background: var(--red); }

/* ─── proxy-ipv4.com cloud section ─── */
.pg-cloud-section {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  margin-bottom: 1rem;
}

.pg-cloud-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pg-cloud-head b { color: var(--text-primary); }
.pg-cloud-head .pg-muted { margin-left: 0.5rem; font-size: 0.8rem; }

.pg-cloud-balance {
  background: var(--bg);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.pg-cloud-balance b { color: var(--green); font-size: 1.05rem; }

.pg-cloud-buy {
  background: var(--bg);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
}
.pg-cloud-buy-grid {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.pg-cloud-buy-grid .pg-field label { font-size: 0.75rem; }
.pg-cloud-buy-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.pg-cloud-buy-foot b { color: var(--accent); }

.pg-cloud-list-head {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.pg-cloud-list-head b { color: var(--text-primary); }

/* Cloud proxies list — bounded height, scrollable, compact rows */
#pg-pi-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
}
#pg-pi-list .pg-key-item {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
}
#pg-pi-list .pg-key-item:last-child { border-bottom: none; }
#pg-pi-list .pg-key-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
}
#pg-pi-list .pg-key-name code {
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
}
#pg-pi-list .pg-key-meta {
  font-size: 0.7rem;
  color: var(--text-muted, var(--text-secondary));
  margin-top: 2px;
}
.pg-cloud-proxy-expires {
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.pg-cloud-proxy-expires.pg-expiring { color: #eab308; font-weight: 600; }
.pg-cloud-proxy-expires.pg-expired { color: var(--red); font-weight: 600; }

.pg-pool-status {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}
.pg-pool-status b { color: var(--accent); margin: 0 0.25rem; }

.pg-forecast {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue, #3b82f6);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}
.pg-forecast-warn-box {
  border-left-color: #eab308;
  background: rgba(234, 179, 8, 0.08);
}
.pg-forecast-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.pg-forecast-line { margin: 2px 0; }
.pg-forecast-line b { color: var(--accent); }
.pg-forecast-warn {
  color: #eab308;
  font-weight: 600;
  margin-left: 0.35rem;
}

/* ─── Autolaunch checkbox (generator page) ─── */
.pg-autolaunch {
  display: block;
  padding: 0.7rem 0.85rem;
  margin: 0.75rem 0 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  color: var(--text-primary);
}
.pg-autolaunch input[type="checkbox"] {
  margin-right: 0.5rem;
  cursor: pointer;
}
.pg-autolaunch small {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.pg-autolaunch:hover { border-color: var(--border-focus, var(--accent)); }

/* ─── Custom in-app dialogs (PG.alert / PG.confirm) ─── */
.pg-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: pg-dlg-fade-in 0.15s ease-out;
}
.pg-dialog-overlay.pg-dialog-closing {
  animation: pg-dlg-fade-out 0.12s ease-in forwards;
}
@keyframes pg-dlg-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pg-dlg-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.pg-dialog-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.25rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: pg-dlg-slide-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes pg-dlg-slide-in {
  from { transform: translateY(8px) scale(0.97); opacity: 0.6; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.pg-dialog-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
  font-size: 1.7rem;
  background: rgba(99, 102, 241, 0.12);
}
.pg-dialog-success .pg-dialog-icon { background: rgba(34, 197, 94, 0.14); }
.pg-dialog-warning .pg-dialog-icon { background: rgba(234, 179, 8, 0.14); }
.pg-dialog-error   .pg-dialog-icon { background: rgba(239, 68, 68, 0.14); }
.pg-dialog-info    .pg-dialog-icon { background: rgba(59, 130, 246, 0.14); }

.pg-dialog-title {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pg-dialog-body {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 1.25rem;
  word-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
  text-align: left;
  white-space: pre-wrap;
}
.pg-dialog-card.pg-dialog-info .pg-dialog-body,
.pg-dialog-card.pg-dialog-success .pg-dialog-body { text-align: center; }

.pg-dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}
.pg-dialog-actions .pg-btn { min-width: 100px; }

.pg-dialog-danger {
  background: var(--red, #ef4444) !important;
  border-color: var(--red, #ef4444) !important;
  color: #fff !important;
}
.pg-dialog-danger:hover { filter: brightness(1.1); }

/* ─── Toast (PG.toast) ─── */
.pg-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 350;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(90vw, 380px);
  pointer-events: none;
}

.pg-toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  padding: 0.7rem 0.85rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--text-primary);
  font-size: 0.87rem;
  line-height: 1.35;
  transform: translateX(110%);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease-out;
  pointer-events: auto;
}
.pg-toast.pg-toast-in { transform: translateX(0); opacity: 1; }
.pg-toast.pg-toast-out { transform: translateX(20%); opacity: 0; }

.pg-toast-success { border-left-color: #22c55e; }
.pg-toast-warning { border-left-color: #eab308; }
.pg-toast-error   { border-left-color: #ef4444; }
.pg-toast-info    { border-left-color: #3b82f6; }

.pg-toast-icon { font-size: 1.05rem; flex-shrink: 0; line-height: 1.3; }
.pg-toast-msg  { flex: 1; word-wrap: break-word; }
.pg-toast-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 4px;
  line-height: 1;
  align-self: flex-start;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.pg-toast-close:hover { opacity: 1; }

/* Theme picker CSS removed 2026-08-18 — theme toggle lives in user dropdown
   (base.html); the standalone picker was deleted from _global_dialogs.html. */

.pg-tab-panel { min-height: 200px; }

.pg-btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* ─── Gemini keys list ─── */
.pg-key-add { margin-bottom: 1rem; }

.pg-keys-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.75rem 0 0.5rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.pg-keys-list {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pg-keys-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.pg-key-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  gap: 0.75rem;
}

.pg-key-info { flex: 1; min-width: 0; }

.pg-key-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.pg-key-meta {
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-top: 0.2rem;
  font-family: 'JetBrains Mono', monospace;
}

.pg-key-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
}

.pg-badge-red    { background: #ef4444; }
.pg-badge-orange { background: #f97316; }
.pg-badge-yellow { background: #eab308; color: #1a1a1a; }
.pg-badge-green  { background: #22c55e; }
.pg-badge-blue   { background: #3b82f6; }
.pg-badge-purple { background: #a855f7; }

/* ─── Users list ─── */
.pg-user-add {
  padding: 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.pg-user-add h4 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.pg-users-header {
  margin-bottom: 0.5rem;
}

.pg-users-header h4 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pg-users-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
}

.pg-user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.pg-user-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.9rem;
}

/* ─── #29 Mobile responsive (max 640px) ─── */
@media (max-width: 640px) {
  .pg-page { padding: 0 0 2rem; }
  .pg-grid-2 { grid-template-columns: 1fr !important; gap: 0.5rem !important; }
  .pg-subnav { flex-wrap: wrap; gap: 0.35rem; }
  .pg-subnav-btn { flex: 1 1 auto; font-size: 0.85rem; padding: 0.5rem 0.6rem; }

  /* Cloud-buy grid stacks on mobile */
  .pg-cloud-buy-grid { grid-template-columns: 1fr 1fr !important; }
  .pg-cloud-head { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .pg-cloud-head > div:last-child { flex-wrap: wrap; }

  /* Settings modal wider on small screens */
  .pg-settings-card, .pg-users-card { padding: 1rem !important; max-width: 100% !important; }
  .pg-outer-panel { min-height: unset; }
  .pg-tabs-outer, .pg-tabs-inner { flex-wrap: wrap; }
  .pg-tab { flex: 1 1 auto; font-size: 0.8rem; padding: 0.5rem 0.6rem; }

  /* Dialog card fills more of the screen */
  .pg-dialog-card { padding: 1.25rem 1rem 1rem; }

  /* v0 keys table — hide less-critical columns */
  .pg-v0-table th:nth-child(4),
  .pg-v0-table td:nth-child(4),   /* Created */
  .pg-v0-table th:nth-child(6),
  .pg-v0-table td:nth-child(6) {  /* Usage */
    display: none;
  }
  .pg-v0-table { font-size: 0.72rem; }
  .pg-v0-table th, .pg-v0-table td { padding: 0.35rem 0.4rem; }

  /* Toast slightly narrower / larger on mobile */
  .pg-toast-container { bottom: 12px; right: 12px; left: 12px; max-width: none; }
}

/* ─── #36 Smooth collapse animation for history blocks ─── */
.pg-hist-body {
  transition: max-height 0.22s ease-out, opacity 0.15s;
  overflow: hidden;
}
.pg-hist-collapsed .pg-hist-body {
  max-height: 0 !important;
  opacity: 0;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
