/* ProImageTools panel — hand-authored design system.
   No build step by design: the rest of the project has no Composer/npm toolchain, and a
   server-rendered PHP panel does not need one. Swap for a Tailwind CLI build later if wanted. */

:root {
  --bg:          #f6f7f9;
  --surface:     #ffffff;
  --surface-2:   #fafbfc;
  --border:      #e4e7ec;
  --text:        #101828;
  --text-muted:  #667085;
  --text-subtle: #98a2b3;
  --accent:      #4f46e5;
  --accent-hover:#4338ca;
  --accent-soft: #eef2ff;
  --success:     #039855;
  --success-soft:#ecfdf3;
  --warning:     #dc6803;
  --warning-soft:#fffaeb;
  --danger:      #d92d20;
  --danger-soft: #fef3f2;
  --radius:      10px;
  --radius-lg:   14px;
  --shadow:      0 1px 2px rgba(16,24,40,.05);
  --shadow-md:   0 4px 12px rgba(16,24,40,.08);
  --sidebar:     248px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0d0f14;
    --surface:     #161920;
    --surface-2:   #1c2029;
    --border:      #2a2f3a;
    --text:        #e9ebf0;
    --text-muted:  #98a2b3;
    --text-subtle: #6c7789;
    --accent:      #7c74f0;
    --accent-hover:#8f88f5;
    --accent-soft: #1e1b3a;
    --success:     #47cd89;
    --success-soft:#0d2b1e;
    --warning:     #f5a524;
    --warning-soft:#2c1f0a;
    --danger:      #f97066;
    --danger-soft: #2d1513;
    --shadow:      0 1px 2px rgba(0,0,0,.3);
    --shadow-md:   0 4px 14px rgba(0,0,0,.4);
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 4px; line-height: 1.25; letter-spacing: -0.015em; }
h1 { font-size: 24px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 15px; font-weight: 600; }
p  { margin: 0 0 12px; }

code, .mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
}

/* ---------- Auth layout ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
}
.auth-card .brand {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 24px; font-weight: 680; font-size: 17px; color: var(--text);
}
.auth-card .brand:hover { text-decoration: none; }
.auth-sub { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }
.auth-foot { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-muted); text-align: center; }

/* ---------- App shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar .brand {
  font-weight: 680; font-size: 16px; color: var(--text);
  padding: 6px 10px 18px;
  display: flex; align-items: center; gap: 9px;
}
.sidebar .brand:hover { text-decoration: none; }
.brand img { flex: 0 0 auto; display: block; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--text-muted); font-size: 14px; font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 560; }
.nav-link .ico { width: 17px; text-align: center; opacity: .85; flex: 0 0 17px; }
.nav-sep { height: 1px; background: var(--border); margin: 12px 10px; }
.nav-label {
  padding: 16px 10px 5px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-subtle); font-weight: 680;
}
.nav-foot { margin-top: auto; padding-top: 12px; }
.nav-user { padding: 10px; font-size: 13px; color: var(--text-subtle); }
.nav-user strong { display: block; color: var(--text); font-size: 14px; font-weight: 560; }

.main { flex: 1; min-width: 0; padding: 28px 32px 64px; }
.page-head { margin-bottom: 24px; }
.page-head p { color: var(--text-muted); margin: 0; font-size: 14px; }

/* ---------- Cards & grid ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--text-muted); }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .045em; color: var(--text-subtle); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -0.02em; }
.stat .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.stat.accent .value { color: var(--accent); }

/* ---------- Forms ---------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 560; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 12.5px; color: var(--text-subtle); margin-top: 5px; }

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input::placeholder { color: var(--text-subtle); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px; font-weight: 560; font-family: inherit;
  cursor: pointer;
  transition: background .12s, opacity .12s;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 13px; }

/* ---------- Alerts ---------- */

.alert { padding: 11px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 18px; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-error   { background: var(--danger-soft);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-info    { background: var(--accent-soft);  color: var(--accent);  border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin: 0 -20px -20px; padding: 0 20px 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 8px 12px;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .045em;
  color: var(--text-subtle); font-weight: 620;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 560; white-space: nowrap;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-accent  { background: var(--accent-soft);  color: var(--accent);  border-color: transparent; }

/* ---------- Key display ---------- */

.key-reveal {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
}
.key-reveal .label { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.key-value {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px;
}
.key-value code { flex: 1; word-break: break-all; color: var(--text); }

.inline-form { display: inline; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: 13px; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mb-16 { margin-bottom: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Model cards (preview section) ---------- */

.model-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .15s, transform .15s;
}
.model-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.model-thumb {
  position: relative; display: block; aspect-ratio: 4 / 3;
  background: var(--surface-2); overflow: hidden;
}
.model-thumb:hover { text-decoration: none; }
.model-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.model-thumb-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700; color: var(--text-subtle); opacity: .5;
}
.model-flag, .model-lock {
  position: absolute; top: 10px; left: 10px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--accent); color: #fff;
}
.model-lock { background: var(--warning); }
.model-body { padding: 14px 16px 16px; }
.model-body h3 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.model-body a:hover { text-decoration: none; }
.model-body a:hover h3 { color: var(--accent); }
.model-body p { margin: 0 0 10px; min-height: 34px; }
.model-meta { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }

.sample-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sample-grid a { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.sample-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Non-image outputs (gallery, playground) ---------- */
/* Generations are not all stills. A clip or a track pushed through <img> renders as a broken
   icon, so each output gets the element that can actually play it. */

.model-thumb.is-media { display: block; background: var(--surface-2); }
.model-thumb video {
  width: 100%; height: 100%; display: block;
  /* contain, not cover: cropping a generated clip hides the part the customer is judging. */
  object-fit: contain; background: #000;
}
.model-thumb.is-glyph { display: flex; align-items: center; justify-content: center; }
.media-glyph { font-size: 40px; line-height: 1; color: var(--text-subtle); opacity: .5; }
.media-audio { width: 100%; display: block; margin-bottom: 10px; height: 40px; }

.sample-grid video { width: 100%; display: block; border-radius: 8px; background: #000; }
.sample-grid audio { width: 100%; align-self: center; }
.sample-grid .is-glyph {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; border-radius: 8px; background: var(--surface-2);
}
/* Clips and tracks need room a 150px thumbnail cell does not give them. */
.sample-grid.is-media-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.sample-grid.is-media-grid a { aspect-ratio: auto; }

/* ---------- Code block ---------- */

pre.code {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px; overflow-x: auto; margin: 0;
  font-size: 12.5px; line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- Bar chart (usage) ---------- */

.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; margin-top: 8px; }
.bars > div { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; }
.bars > div:hover { opacity: 1; }
.bars.bars-mini { height: 44px; }

/* ---------- Dashboard product cards ---------- */

.mini-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-thumbs a {
  display: block; width: 72px; height: 72px;
  border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-2);
}
.mini-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Tabs (admin sections) ---------- */

.tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin: -8px 0 22px;
}
.tab {
  padding: 9px 14px;
  font-size: 14px; font-weight: 540;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Meter ---------- */

.meter { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .2s; }
.meter.warn > span { background: var(--warning); }
.meter.full > span { background: var(--danger); }

/* ---------- Filter bar ---------- */

.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filters .field { margin-bottom: 0; }
.filters input[type=text], .filters select { min-width: 160px; }

/* ---------- Pagination ---------- */

.pager { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 16px; flex-wrap: wrap; }
.pager .info { font-size: 13px; color: var(--text-muted); }

/* ---------- Plan strip ---------- */

.plan-strip { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.plan-meta { display: flex; gap: 26px; flex-wrap: wrap; }
.plan-meta div .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-subtle); font-weight: 620; }
.plan-meta div .v { font-size: 15px; font-weight: 560; margin-top: 2px; }

/* ---------- Mobile ---------- */

.mobile-bar { display: none; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 10px 12px; gap: 2px;
    overflow-x: auto;
  }
  .sidebar .brand { padding: 0 12px 0 4px; }
  .nav-sep, .nav-label { display: none; }
  .nav-foot { margin-top: 0; padding-top: 0; margin-left: auto; }
  .nav-user { display: none; }
  .nav-link { padding: 7px 10px; font-size: 13.5px; }
  .main { padding: 20px 16px 48px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { font-size: 21px; }
}

/* --- Playground searchable model picker (combobox + favourites + tag filter) --- */
.combo { position: relative; }
.combo-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-align: left;
}
.combo-btn:hover { border-color: var(--accent); }
.combo-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-caret { color: var(--text-subtle); flex: none; }
.combo-pop {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 10px; max-width: 100%;
}
.combo-search { margin-bottom: 8px; }
.combo-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; max-height: 92px; overflow-y: auto; }
.combo-chip {
  font-size: 12px; line-height: 1; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer;
}
.combo-chip:hover { border-color: var(--accent); color: var(--text); }
.combo-chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.combo-list { max-height: 320px; overflow-y: auto; margin: 0 -4px; }
.combo-item { display: flex; align-items: center; gap: 4px; border-radius: var(--radius); }
.combo-item:hover { background: var(--surface-2); }
.combo-item.is-selected { background: var(--accent-soft); }
.combo-star {
  flex: none; border: 0; background: none; cursor: pointer; font-size: 16px; line-height: 1;
  padding: 8px 6px 8px 8px; color: var(--text-subtle);
}
.combo-star:hover { color: var(--warning); }
.combo-item.is-fav .combo-star { color: var(--warning); }
.combo-pick {
  flex: 1 1 auto; display: block; padding: 8px 10px 8px 2px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.combo-pick:hover { text-decoration: none; color: var(--text); }
.combo-pick-locked { color: var(--text-subtle); cursor: default; }
.combo-empty { padding: 14px 8px; color: var(--text-subtle); text-align: center; font-size: 13.5px; }
