/* PhotoBrain by CineJera - Public CSS
 *
 * Goal: make the existing UI readable, consistent, and theme-friendly.
 * No assumptions about dark or light theme.
 *
 * Sections:
 * 1. Tokens
 * 2. Layout and typography
 * 3. Forms and buttons
 * 4. Results cards
 * 5. Alerts, badges, empty states
 * 6. Modals (Gate, My Fixes, Add camera)
 * 7. Print
 */

:root {
  --pb-radius: 14px;
  --pb-gap: 14px;

  --pb-border: rgba(0, 0, 0, 0.14);
  --pb-surface: rgba(0, 0, 0, 0.03);
  --pb-surface-2: rgba(0, 0, 0, 0.02);
  --pb-text-muted: rgba(0, 0, 0, 0.65);
  --pb-text-muted-2: rgba(0, 0, 0, 0.52);

  --pb-accent: rgba(0, 0, 0, 0.92);

  --pb-ok: rgba(0, 160, 90, 1);
  --pb-warn: rgba(255, 165, 0, 1);
  --pb-bad: rgba(220, 60, 60, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --pb-border: rgba(255, 255, 255, 0.14);
    --pb-surface: rgba(255, 255, 255, 0.06);
    --pb-surface-2: rgba(255, 255, 255, 0.04);
    --pb-text-muted: rgba(255, 255, 255, 0.72);
    --pb-text-muted-2: rgba(255, 255, 255, 0.56);
    --pb-accent: rgba(255, 255, 255, 0.92);
  }
}

/* 2) Layout and typography */
.pb-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 14px;
  box-sizing: border-box;
}

.pb-wrap * {
  box-sizing: border-box;
}

.pb-title, .pb-wrap h1, .pb-wrap h2, .pb-wrap h3 {
  letter-spacing: -0.02em;
}

.pb-muted {
  color: var(--pb-text-muted);
}

.pb-help {
  font-size: 12px;
  color: var(--pb-text-muted-2);
  margin-top: 6px;
}

.pb-card,
.pb-panel,
.pb-surface {
  border: 1px solid var(--pb-border);
  background: var(--pb-surface-2);
  border-radius: var(--pb-radius);
  padding: 14px;
}

/* 3) Forms and buttons */
.pb-field label {
  display: block;
  font-size: 13px;
  color: var(--pb-text-muted);
  margin-bottom: 6px;
}

.pb-field input,
.pb-field select,
.pb-field textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--pb-border);
  background: var(--pb-surface);
  color: inherit;
  outline: none;
}

.pb-field input:focus,
.pb-field select:focus,
.pb-field textarea:focus {
  border-color: var(--pb-accent);
}

.pb-btn {
  appearance: none;
  border: 1px solid var(--pb-border);
  background: var(--pb-surface);
  color: inherit;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1;
}

.pb-btn:hover {
  border-color: var(--pb-accent);
}

.pb-btn-primary {
  border-color: var(--pb-accent);
  background: var(--pb-surface);
}

.pb-btn-ghost {
  background: transparent;
}

.pb-linklike {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--pb-accent);
  cursor: pointer;
  text-decoration: underline;
  font-size: 13px;
}

.pb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* 4) Results cards */
.pb-result {
  border: 1px solid var(--pb-border);
  background: var(--pb-surface-2);
  border-radius: var(--pb-radius);
  padding: 14px;
  margin-top: 12px;
}

.pb-result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.pb-result-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.pb-kv-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 10px 0;
}

.pb-kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--pb-border);
  border-radius: 12px;
  background: var(--pb-surface);
}

.pb-k {
  font-size: 12px;
  color: var(--pb-text-muted);
}

.pb-v {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

/* details blocks used in JS */
.pb-block {
  border: 1px solid var(--pb-border);
  border-radius: 12px;
  background: var(--pb-surface);
  padding: 10px 12px;
  margin-top: 10px;
}

.pb-block summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--pb-accent);
}

.pb-block-body {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.6;
}

.pb-tags {
  margin-top: 12px;
  font-size: 12px;
  color: var(--pb-text-muted);
}

/* 5) Alerts, badges, empty states */
.pb-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pb-badge {
  border: 1px solid var(--pb-border);
  background: var(--pb-surface);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--pb-text-muted);
}

.pb-alert {
  border: 1px solid var(--pb-border);
  background: var(--pb-surface);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 13px;
}

.pb-alert-warn {
  border-color: rgba(255, 165, 0, 0.5);
  background: rgba(255, 165, 0, 0.08);
}

.pb-alert-danger {
  border-color: rgba(220, 60, 60, 0.55);
  background: rgba(220, 60, 60, 0.08);
}

.pb-empty {
  border: 1px dashed var(--pb-border);
  background: transparent;
  border-radius: var(--pb-radius);
  padding: 14px;
  color: var(--pb-text-muted);
}

/* Feedback block */
.pb-feedback {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--pb-border);
}

.pb-feedback-q {
  font-weight: 700;
  margin-bottom: 8px;
}

.pb-feedback-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* 6) Modals */
.pb-modal,
#pbGate,
#pbMyFixesModal,
#pbAddCameraModal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  padding: 18px;
  background: rgba(0, 0, 0, 0.45);
}

.pb-modal[aria-hidden="false"],
#pbGate[aria-hidden="false"],
#pbMyFixesModal[aria-hidden="false"],
#pbAddCameraModal[aria-hidden="false"] {
  display: grid;
  place-items: center;
}

.pb-modal-card,
.pb-gate-card,
.pb-myfixes-card,
.pb-addcamera-card {
  width: min(760px, 96vw);
  border: 1px solid var(--pb-border);
  background: var(--pb-surface-2);
  border-radius: 16px;
  padding: 16px;
}

.pb-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.pb-modal-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.pb-gate-status {
  margin-top: 10px;
  font-size: 13px;
  color: var(--pb-text-muted);
}

.pb-gate-status.is-ok {
  color: var(--pb-ok);
}

.pb-gate-status.is-bad {
  color: var(--pb-bad);
}

/* My Fixes modal mini cards */
.pb-mini-card {
  border: 1px solid var(--pb-border);
  background: var(--pb-surface);
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
}

.pb-mini-title {
  font-weight: 800;
  margin-bottom: 6px;
}

.pb-mini-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.pb-mini-meaning {
  font-size: 13px;
  color: var(--pb-text-muted);
}

/* Tabs (if present) */
.pb-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.pb-tab {
  border: 1px solid var(--pb-border);
  background: var(--pb-surface);
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.pb-tab.is-active {
  border-color: var(--pb-accent);
}

/* 7) Print */
@media print {
  #pbGate,
  #pbMyFixesModal,
  #pbAddCameraModal,
  .pb-result-actions,
  .pb-feedback,
  .pb-tabs,
  #pbMyFixesBtn,
  #pbPrintBtn {
    display: none !important;
  }

  .pb-wrap {
    max-width: none;
    padding: 0;
  }

  .pb-result {
    break-inside: avoid;
  }
}
