/* ─── Design tokens ───────────────────────────────────── */
:root {
  --c-bg:        #FAFAF9;
  --c-surface:   #FFFFFF;
  --c-surface-2: #F4F4F2;
  --c-border:    #E8E8E4;
  --c-border-2:  #DDDDD8;
  --c-text:      #18181B;
  --c-muted:     #71717A;
  --c-muted-2:   #A1A1AA;
  --c-accent:    #2563EB;
  --c-accent-2:  #3B82F6;
  --c-ok:        #16A34A;
  --c-danger:    #DC2626;
}

/* ─── Base ──────────────────────────────────────────────── */
html {
  font-size: 14px;
  height: 100%;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background-color: var(--c-bg);
  color: var(--c-text);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── App shell ─────────────────────────────────────────── */
.app-main {
  height: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

/* ─── Off-canvas panel (light) ──────────────────────────── */
.offcanvas-panel {
  background: var(--c-surface) !important;
  border-color: var(--c-border) !important;
}

.offcanvas-panel .offcanvas-header {
  border-bottom: 1px solid var(--c-border);
  padding: 14px 16px;
}

.offcanvas-panel .offcanvas-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--c-text);
}

/* ─── Editor shell ───────────────────────────────────────── */
.editor-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.editor-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.editor-studio {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ─── Gallery panel ─────────────────────────────────────── */
.gallery-folders {
  padding: 10px 8px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gallery-folder-link {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: .8rem;
  color: var(--c-muted);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.gallery-folder-link:hover {
  background: rgba(0,0,0,0.04);
  color: var(--c-text);
}

.gallery-shot-list {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 2px;
}

.gallery-shot-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  transition: background .12s;
}
.gallery-shot-item:hover {
  background: rgba(0,0,0,0.04);
}

.gallery-shot-wrapper {
  position: relative;
}
.gallery-shot-duplicate-form {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity .15s;
}
.gallery-shot-wrapper:hover .gallery-shot-duplicate-form {
  opacity: 1;
}
.gallery-shot-duplicate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-muted);
  cursor: pointer;
  padding: 0;
  transition: background .12s, color .12s;
}
.gallery-shot-duplicate-btn:hover {
  background: rgba(37,99,235,.06);
  color: var(--c-accent);
  border-color: rgba(37,99,235,.2);
}

.gallery-shot-thumb {
  width: 44px;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--c-surface-2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-shot-info {
  flex: 1;
  min-width: 0;
}

.gallery-shot-name {
  font-size: .82rem;
  font-weight: 500;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-shot-date {
  font-size: .72rem;
  color: var(--c-muted-2);
  margin-top: 1px;
}

.gallery-empty {
  padding: 32px 20px;
  text-align: center;
}

/* ─── Focus rings ───────────────────────────────────────── */
.btn:focus,
.btn:active:focus,
.form-control:focus,
.form-check-input:focus,
.form-select:focus {
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
  outline: none;
}

/* ─── Form controls ─────────────────────────────────────── */
.form-control,
.form-select {
  background-color: var(--c-surface);
  border-color: var(--c-border);
  color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
}

.form-control:hover,
.form-select:hover {
  border-color: var(--c-border-2);
}

.form-control:focus,
.form-select:focus {
  background-color: var(--c-surface);
  border-color: var(--c-accent);
  color: var(--c-text);
}

.form-control::placeholder {
  color: var(--c-muted-2);
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn-primary {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
  font-weight: 500;
}
.btn-primary:hover,
.btn-primary:focus {
  background: var(--c-accent-2);
  border-color: var(--c-accent-2);
  color: #fff;
}
.btn-primary:active {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.btn-dark {
  background: var(--c-surface-2);
  border-color: var(--c-border);
  color: var(--c-text);
}
.btn-dark:hover,
.btn-dark:focus {
  background: var(--c-border);
  border-color: var(--c-border-2);
  color: var(--c-text);
}
.btn-dark.active,
.btn-dark:active {
  background: rgba(37,99,235,.08) !important;
  border-color: rgba(37,99,235,.2) !important;
  color: var(--c-accent) !important;
}

.btn-outline-secondary {
  border-color: var(--c-border);
  color: var(--c-muted);
  background: transparent;
}
.btn-outline-secondary:hover {
  background: var(--c-surface-2);
  border-color: var(--c-border-2);
  color: var(--c-text);
}
.btn-check:checked + .btn-outline-secondary {
  background: var(--c-surface-2);
  border-color: var(--c-border-2);
  color: var(--c-text);
}

.btn-secondary {
  background: var(--c-surface-2);
  border-color: var(--c-border);
  color: var(--c-text);
}
.btn-secondary:hover {
  background: var(--c-border);
  border-color: var(--c-border-2);
  color: var(--c-text);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--c-border);
  color: var(--c-muted);
  font-size: .875rem;
}
.btn-ghost:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
  border-color: var(--c-border-2);
}

/* ─── Alerts ────────────────────────────────────────────── */
.alert-success {
  background-color: rgba(22,163,74,0.08);
  border-color: rgba(22,163,74,0.2);
  color: #15803d;
}
.alert-warning {
  background-color: rgba(234,179,8,0.08);
  border-color: rgba(234,179,8,0.2);
  color: #a16207;
}

/* ─── Badges ────────────────────────────────────────────── */
.badge-success {
  background: rgba(22,163,74,0.08);
  color: #15803d;
  border: 1px solid rgba(22,163,74,0.2);
  padding: .2em .55em;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-danger {
  background: rgba(220,38,38,0.08);
  color: var(--c-danger);
  border: 1px solid rgba(220,38,38,0.2);
  padding: .2em .55em;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-scheduled {
  background: rgba(37,99,235,0.08);
  color: var(--c-accent);
  border: 1px solid rgba(37,99,235,0.2);
  padding: .2em .55em;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-secondary {
  background: var(--c-surface-2);
  color: var(--c-muted);
  border: 1px solid var(--c-border);
  padding: .2em .55em;
  border-radius: 6px;
  font-size: .72rem;
}

/* ─── Table ─────────────────────────────────────────────── */
.table-dark-wrapper {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  overflow: hidden;
}
.table-dark {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--c-border);
  font-size: .85rem;
  color: var(--c-text);
}
.table-dark thead th {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  border-bottom-color: var(--c-border-2);
}

/* ─── Modals ────────────────────────────────────────────── */
.modal-content {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  color: var(--c-text);
}
.modal-header { border-bottom-color: var(--c-border); }
.modal-footer { border-top-color: var(--c-border); }

/* ─── Studio sidebar ────────────────────────────────────── */
.studio-sidebar {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 16px;
  padding: 20px;
}
.studio-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--c-muted);
  letter-spacing: .09em;
  margin-bottom: 8px;
}
.studio-hr {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: 14px 0;
}
.studio-color-picker {
  width: 32px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

/* ─── Range sliders ─────────────────────────────────────── */
input[type="range"] { accent-color: var(--c-accent); }
.form-range::-webkit-slider-thumb { background: var(--c-accent); }
.form-range::-webkit-slider-runnable-track { background: var(--c-surface-2); }

/* ─── Code ──────────────────────────────────────────────── */
code {
  color: var(--c-accent);
  background: rgba(37,99,235,0.06);
  padding: .1em .35em;
  border-radius: 4px;
  font-size: .88em;
}

/* ─── Dashboard / management UI ────────────────────────── */
.page-title {
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: -.02em;
  color: var(--c-text);
}
.back-link {
  font-size: .85rem;
  color: var(--c-muted);
  text-decoration: none;
}
.back-link:hover { color: var(--c-accent); }

.card-dark {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  padding: 20px;
  transition: border-color .15s;
}
.card-dark:hover { border-color: var(--c-border-2); }

.site-name {
  font-weight: 600;
  color: var(--c-text);
  text-decoration: none;
  font-size: 1rem;
}
.site-name:hover { color: var(--c-accent); }

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--c-muted);
  margin-top: .5rem;
}
.section-hr {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: 1.25rem 0;
}
.section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-muted);
  margin-bottom: .75rem;
}
.form-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 16px;
  padding: 28px;
}
.form-label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--c-muted);
  margin-bottom: .35rem;
}
.empty-state {
  background: var(--c-surface);
  border: 1px dashed var(--c-border-2);
  border-radius: 16px;
  padding: 3rem;
}

/* --- Shared top bar ----------------------------------------------------- */
.app-topbar {
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
}

.app-topbar-left,
.app-topbar-right,
.app-topbar-content {
  display: flex;
  align-items: center;
  min-width: 0;
}

.app-topbar-left {
  gap: 10px;
  flex-shrink: 0;
}

.app-topbar-content {
  flex: 1;
  justify-content: center;
  gap: 12px;
}

.app-topbar-right {
  flex-shrink: 0;
}

.app-topbar-action,
.app-topbar-account {
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

.app-topbar-action {
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border-radius: 6px;
  background: transparent;
  color: var(--c-muted);
  font-size: .78rem;
  font-weight: 600;
}

.app-topbar-action:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
}

.app-topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--c-text);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 700;
}

.app-topbar-logo {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 5px;
  background: var(--c-text);
  color: var(--c-surface);
  font-size: .68rem;
  line-height: 1;
}

.app-topbar-account {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #F472B6, #FB923C);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
}

.shot-topbar {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shot-topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.shot-topbar-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

@media (max-width: 700px) {
  .app-topbar {
    gap: 8px;
    padding: 0 10px;
  }

  .app-topbar-action span,
  .app-topbar-brand span:last-child {
    display: none;
  }

  .app-topbar-action {
    width: 30px;
    justify-content: center;
    padding: 0;
  }

  .shot-topbar {
    justify-content: flex-end;
  }

  .shot-topbar-title {
    display: none;
  }
}
