/* Shot Guide — cinematography reference table.
   Palette matches shot-framer's main app (assets/css/style.css :root). */

:root {
  --bg: #EFE6E3;
  --surface: #ffffff;
  --surface-soft: #FFF0E6;
  --text: #231F20;
  --muted: #545859;
  --line: #E7E3E2;
  --primary: #FF6A14;
  --primary-dark: #CE4B00;
  --primary-soft: #FFF0E6;
  --radius: 10px;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
}

.sg-header {
  padding: 24px clamp(16px, 4vw, 40px) 8px;
}

.sg-header h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.sg-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.sg-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.sg-help-btn {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.sg-help-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.sg-back-link {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}

.sg-back-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.sg-hero-cta {
  padding: 4px clamp(16px, 4vw, 40px) 20px;
}

.sg-hero-link {
  display: inline-block;
  text-decoration: none;
}

.sg-hero-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 640px;
}

.sg-spectrum-page {
  margin: 0 clamp(16px, 4vw, 40px) 40px;
}

.sg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px clamp(16px, 4vw, 40px);
}

.sg-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sg-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.sg-chip:hover:not(.active) {
  border-color: var(--primary);
}

.sg-clear {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 6px 4px;
}

.sg-admin-toggle.active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.sg-count {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 clamp(16px, 4vw, 40px) 4px;
}

.sg-table-wrap {
  margin: 0 clamp(16px, 4vw, 40px) 32px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: auto;
  max-height: 72vh;
}

table.sg-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 980px;
}

.sg-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  text-align: left;
  padding: 10px 12px 4px;
  font-size: 0.82rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.sg-table thead th:hover {
  color: var(--primary-dark);
}

.sg-table thead th .sg-arrow {
  display: inline-block;
  width: 1em;
  opacity: 0.5;
}

.sg-table thead th.sg-sorted .sg-arrow {
  opacity: 1;
  color: var(--primary);
}

.sg-table thead tr.sg-filters th {
  position: sticky;
  top: 30px;
  cursor: default;
  padding: 4px 8px 8px;
  background: var(--surface);
}

.sg-table thead tr.sg-filters input,
.sg-table thead tr.sg-filters select {
  width: 100%;
  min-width: 90px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.82rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}

.sg-table thead tr.sg-filters input:focus,
.sg-table thead tr.sg-filters select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  background: var(--surface);
}

.sg-table tbody tr {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.sg-table tbody tr:nth-child(even) {
  background: var(--bg);
}

.sg-table tbody tr:nth-child(even) .sg-actions-cell {
  background: var(--bg);
}

.sg-table tbody tr:hover {
  background: var(--surface-soft);
}

.sg-table tbody td {
  padding: 10px 12px;
  vertical-align: top;
  font-size: 0.9rem;
  max-width: 260px;
}

.sg-table td.sg-clip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--primary-soft);
  color: var(--primary-dark);
  white-space: nowrap;
}

.sg-thumb-cell {
  width: 64px;
}

.sg-thumb {
  width: 56px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  border: 1px solid var(--line);
}

.sg-no-image {
  color: var(--muted);
  font-size: 0.85rem;
}

.sg-empty-row td {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Admin: actions column ---------- */

.sg-actions-header,
.sg-actions-cell {
  display: none;
}

body.sg-admin-mode .sg-actions-header,
body.sg-admin-mode .sg-actions-cell {
  display: table-cell;
  position: sticky;
  right: 0;
  background: var(--surface);
  box-shadow: -4px 0 6px -4px rgba(0, 0, 0, 0.18);
}

.sg-table tbody tr:hover .sg-actions-cell {
  background: var(--surface-soft);
}

.sg-actions-cell {
  white-space: nowrap;
  z-index: 1;
}

.sg-row-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  margin-right: 6px;
}

.sg-row-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.sg-row-btn-danger:hover {
  border-color: var(--danger, #9E292E);
  color: var(--danger, #9E292E);
}

/* ---------- Admin: edit/add form ---------- */

.sg-form-error {
  background: #F7E4E4;
  color: #651C32;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.sg-form-field {
  display: block;
  margin-bottom: 12px;
}

.sg-form-field > span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.sg-form-field input[type="text"],
.sg-form-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.92rem;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

.sg-form-field input[type="text"]:focus,
.sg-form-field textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  background: var(--surface);
}

.sg-form-image-preview {
  display: block;
  max-width: 160px;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
}

.sg-form-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 6px 0;
}

.sg-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.sg-btn-primary,
.sg-btn-secondary,
.sg-btn-danger {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.9rem;
  cursor: pointer;
}

.sg-btn-primary {
  background: var(--primary);
  color: #fff;
}

.sg-btn-primary:hover {
  background: var(--primary-dark);
}

.sg-btn-secondary {
  background: var(--bg);
  color: var(--text);
}

.sg-btn-danger {
  background: none;
  color: #9E292E;
  margin-right: auto;
}

.sg-btn-danger:hover {
  text-decoration: underline;
}

/* ---------- Modal ---------- */

.sg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(35, 31, 32, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px;
  overflow-y: auto;
  z-index: 100;
}

.sg-overlay[hidden] { display: none; }

.sg-modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  width: min(640px, 100%);
  padding: 20px 20px 24px;
}

.sg-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.sg-modal-head .sg-badge {
  margin-bottom: 6px;
}

.sg-modal-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
}

.sg-modal-close {
  border: none;
  background: var(--bg);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex: none;
}

.sg-modal-close:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.sg-field {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.sg-field:first-of-type {
  border-top: none;
}

.sg-field-label {
  color: var(--muted);
  font-size: 0.85rem;
  padding-top: 8px;
}

.sg-field-value {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.92rem;
  line-height: 1.4;
  word-break: break-word;
}

.sg-field-value img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  cursor: zoom-in;
}

.sg-image-caption {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.sg-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* ---------- Shot Spectrum ---------- */

.sg-spectrum-section + .sg-spectrum-section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.sg-spectrum-heading {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.sg-spectrum-intro {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 16px;
}

.sg-spectrum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  padding: 2px;
}

.sg-spectrum-cell {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  cursor: zoom-in;
  padding: 0;
  text-align: center;
  font: inherit;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.sg-spectrum-cell:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.sg-spectrum-cell img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.sg-spectrum-label {
  padding: 8px 6px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ---------- Help modal ---------- */

.sg-help-content p {
  margin: 0 0 12px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.sg-help-content ul {
  margin: 0;
  padding-left: 20px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.sg-help-content li {
  margin-bottom: 8px;
}

/* ---------- Lightbox (full-size image, on top of the detail modal) ---------- */

.sg-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
  cursor: zoom-out;
}

.sg-lightbox[hidden] { display: none; }

.sg-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

@media (max-width: 640px) {
  .sg-field {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .sg-field-label { padding-top: 0; }
}
