/* PachBae Studi-OS — base tokens + reset */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Serif:wght@500;600&display=swap');

:root {
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'JetBrains Mono', monospace;
  --font-serif: 'IBM Plex Serif', Georgia, serif;

  /* Warm dark neutrals - mixed in oklab */
  --bg:             oklch(0.155 0.005 65);
  --bg-rail:        oklch(0.135 0.005 65);
  --surface:        oklch(0.195 0.006 65);
  --surface-2:     oklch(0.225 0.007 65);
  --surface-3:     oklch(0.255 0.008 65);
  --border:         oklch(0.295 0.008 65);
  --border-strong:  oklch(0.36 0.009 65);

  --text-primary:   oklch(0.955 0.010 80);
  --text-secondary: oklch(0.74 0.010 80);
  --text-muted:     oklch(0.55 0.010 80);
  --text-faint:     oklch(0.42 0.010 80);

  --accent: oklch(0.78 0.14 60);
  --accent-dim: oklch(0.50 0.10 60);

  --green: oklch(0.76 0.14 145);
  --red:   oklch(0.70 0.18 25);
  --blue:  oklch(0.74 0.12 240);

  --topbar-h: 56px;
  --sidebar-w: 244px;
  --sidebar-w-collapsed: 56px;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;

  --shadow-card: 0 1px 0 oklch(0.32 0.008 65) inset, 0 1px 2px rgba(0,0,0,0.3);
}

html[data-theme="light"] {
  /* Warm paper-gray — softer than near-white to reduce eye strain */
  --bg:             oklch(0.905 0.007 78);
  --bg-rail:        oklch(0.875 0.008 76);
  --surface:        oklch(0.948 0.004 82);
  --surface-2:      oklch(0.925 0.005 80);
  --surface-3:      oklch(0.902 0.006 78);
  --border:         oklch(0.775 0.006 78);
  --border-strong:  oklch(0.675 0.007 76);

  --text-primary:   oklch(0.22 0.010 65);
  --text-secondary: oklch(0.42 0.010 65);
  --text-muted:     oklch(0.55 0.010 65);
  --text-faint:     oklch(0.70 0.010 65);

  --shadow-card: 0 1px 0 rgba(255,255,255,0.22) inset, 0 1px 3px rgba(22, 18, 12, 0.08);
}

* { box-sizing: border-box; }

html, body, #root {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle film grain across the whole app — adds analog warmth */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.025;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1 0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
}
html[data-theme="light"] body::before { opacity: 0.022; mix-blend-mode: multiply; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
}
button { cursor: pointer; border: none; background: none; padding: 0; }

/* ── Global form controls — dark + light mode aware ──────────────────── */

/* Base layer: low specificity (0,0,1) so any class override wins */
input, textarea {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, background-color 0.15s;
}
input:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, textarea:focus {
  border-color: var(--accent);
  background-color: var(--surface-2);
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

/* Inputs that live inside a styled container — transparent, no border */
.topbar-search input,
.inv-search-bar input {
  background-color: transparent;
  border: none;
  border-radius: 0;
}
.topbar-search input:hover,
.topbar-search input:focus,
.inv-search-bar input:hover,
.inv-search-bar input:focus {
  background-color: transparent;
  border: none;
  outline: none;
}

/* Checkboxes / radios / file / range — don't inherit the text-input style */
input[type="checkbox"],
input[type="radio"],
input[type="range"],
input[type="color"],
input[type="file"] {
  background-color: transparent;
  border: none;
  border-radius: 0;
  appearance: auto;
  -webkit-appearance: auto;
  transition: none;
}
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* Selects */
select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 0 28px 0 10px;
  height: 32px;
  font-size: 13px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
  transition: border-color 0.15s, background-color 0.15s;
}
select:hover { border-color: var(--border-strong); }
select:focus { border-color: var(--accent); background-color: var(--surface-2); }
select option { background: var(--surface-2); color: var(--text-primary); }

/* Checkboxes */
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px; height: 15px;
  cursor: pointer;
}

.mono { font-family: var(--font-mono); font-feature-settings: "ss01" on; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border: 2px solid var(--bg);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  z-index: 1;
}
.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
}
.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background:
    radial-gradient(80% 60% at 80% -10%, color-mix(in oklab, var(--accent) 6%, transparent) 0%, transparent 50%),
    radial-gradient(60% 60% at 10% 100%, oklch(0.20 0.006 65 / 0.6) 0%, transparent 50%),
    var(--bg);
  position: relative;
}
html[data-theme="light"] .main {
  background:
    radial-gradient(80% 60% at 80% -10%, color-mix(in oklab, var(--accent) 7%, transparent) 0%, transparent 50%),
    radial-gradient(60% 60% at 10% 100%, oklch(0.82 0.005 80 / 0.28) 0%, transparent 50%),
    var(--bg);
}

/* ── CustomSelect ─────────────────────────────────────────────────────── */
.cs-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 28px 0 10px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background-color 0.15s;
  box-sizing: border-box;
  width: 100%;
}
.cs-wrap:hover { border-color: var(--border-strong); }
.cs-wrap:focus { outline: none; border-color: var(--accent); background-color: var(--surface-2); }
.cs-wrap.cs-open { border-color: var(--accent); background-color: var(--surface-2); }
.cs-wrap.cs-disabled { opacity: 0.5; cursor: not-allowed; }

.cs-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-placeholder { color: var(--text-faint); }

.cs-arrow {
  position: absolute;
  right: 9px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  pointer-events: none;
  transition: transform 0.15s;
}
.cs-open .cs-arrow { transform: rotate(180deg); }

.cs-list {
  position: fixed;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.2);
  z-index: 9999;
  list-style: none;
  padding: 4px;
  margin: 0;
}

.cs-option {
  padding: 7px 10px;
  border-radius: calc(var(--radius) - 1px);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.1s, color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-option:hover { background-color: var(--surface-3); }
.cs-option.cs-highlighted { background-color: var(--surface-3); }
.cs-option.cs-selected {
  color: var(--accent);
  background-color: color-mix(in oklab, var(--accent) 10%, var(--surface-2));
}
.cs-option.cs-selected.cs-highlighted {
  background-color: color-mix(in oklab, var(--accent) 16%, var(--surface-2));
}
.cs-option.cs-option-disabled { color: var(--text-faint); cursor: not-allowed; }

/* Sizing variants — inherit from parent context */
.cs-wrap.mf-input { height: 32px; }
.cs-wrap.is-input  { height: 32px; }

/* Prices & gear values hidden for the previewed role — see usePriceHide in app.jsx */
[data-price-hidden] { display: none !important; }
