/* PIP-OS base — custom properties, reset, typography */

:root {
  color-scheme: dark;
  --bg: #000000;
  --fg: #f2f2f2;
  --dim: #8a8a8a;
  --bright: #ffffff;
  --accent: #f2f2f2;
  --border: #4a4a4a;
  --invert-bg: #f2f2f2;
  --invert-fg: #000000;
  --glow: rgba(242,242,242,0.15);
  --glow-strong: rgba(242,242,242,0.35);

  --font: "JetBrains Mono","Cascadia Mono",ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  --ui-scale: 0.8;
  --fs: calc(14px * var(--ui-scale));
  --fs-sm: calc(var(--fs) * 0.85);
  --fs-lg: calc(var(--fs) * 1.25);
  --fs-xl: calc(var(--fs) * 1.6);

  --tab-h: calc(36px * var(--ui-scale));
  --status-h: calc(32px * var(--ui-scale));
  --panel-pad: calc(0.75rem * var(--ui-scale));
  --border-r: 0;

  --transition-color: color 0.15s, background-color 0.15s, border-color 0.15s, opacity 0.15s, box-shadow 0.15s;

  /* scan + glow are controlled by fx.js via data-fx attribute */
  --scan-opacity: 0;
  --glow-text: none;
}

[data-density="compact"] {
  --fs: calc(12px * var(--ui-scale));
  --tab-h: calc(28px * var(--ui-scale));
  --panel-pad: calc(0.5rem * var(--ui-scale));
}

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

html, body {
  width: 100%; height: 100%;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  background: #000;
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.5;
  overflow: hidden;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
}

/* Date/time inputs: prevent iOS overflow and weird native styling */
input[type="date"], input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

button { cursor: pointer; }

a { color: inherit; text-decoration: none; }

ul, ol { list-style: none; }

/* scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); }

/* selection */
::selection { background: var(--fg); color: var(--bg); }

/* focus */
:focus-visible { outline: 1px solid var(--fg); outline-offset: 1px; }

/* utility */
.dim { color: var(--dim); }
.bright { color: var(--bright); }
.accent { color: var(--accent); }
.mono { font-family: var(--font); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* inverse video (selected row) */
.inv {
  background: var(--fg);
  color: var(--bg);
}

.overdue-flag {
  color: var(--dim);
}

/* priority marker — kept out of .row-title so it never gets truncated */
.priority-flag {
  color: var(--bright);
  font-weight: bold;
}

/* toast */
#toast-container {
  position: fixed;
  bottom: calc(var(--status-h) + 8px);
  left: 50%; transform: translateX(-50%);
  z-index: 9999;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.toast {
  background: var(--fg);
  color: var(--bg);
  padding: 4px 14px;
  font-size: var(--fs-sm);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--bg); color: var(--fg); border: 1px solid var(--fg); }

/* modal overlay */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 800;
  display: none;
  align-items: center;
  justify-content: center;
}
#modal-overlay.open { display: flex; }

.modal {
  background: var(--bg);
  border: 1px solid var(--fg);
  padding: 1rem;
  max-width: min(480px, 90vw);
  width: 100%;
  max-height: 80dvh;
  overflow-y: auto;
}

.modal h2 {
  font-size: var(--fs);
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

.modal .field { margin-bottom: 0.6rem; }
.modal label { display: block; color: var(--dim); font-size: var(--fs-sm); margin-bottom: 2px; }
.modal input, .modal textarea, .modal select,
.auth-box input, .auth-box textarea, .auth-box select {
  width: 100%;
  border: 1px solid var(--border);
  padding: 4px 6px;
  background: transparent;
  font-family: var(--font);
  font-size: var(--fs);
  color: var(--fg);
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}
.modal textarea { resize: vertical; min-height: 80px; }

.modal input[type="checkbox"] {
  width: auto;
  height: 1.2em;
  aspect-ratio: 1;
  appearance: auto;
  -webkit-appearance: auto;
  border: none;
  padding: 0;
}

/* Kill browser autofill styling (yellow bg + system font) so fields stay on-theme */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--fg);
  -webkit-box-shadow: 0 0 0px 1000px var(--bg) inset;
  box-shadow: 0 0 0px 1000px var(--bg) inset;
  caret-color: var(--fg);
  font-family: var(--font) !important;
  font-size: var(--fs) !important;
  transition: background-color 9999s ease-in-out 0s;
}

.modal .actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 0.75rem; padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* box-drawing panel */
.panel {
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.panel-header {
  padding: 2px var(--panel-pad);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.panel-body {
  flex: 1; overflow-y: auto;
  padding: var(--panel-pad);
}

/* buttons */
.btn {
  border: 1px solid var(--border);
  padding: 2px 10px;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: var(--transition-color);
  white-space: nowrap;
}
.btn:focus-visible, .btn:active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    background: var(--fg);
    color: var(--bg);
    border-color: var(--fg);
  }
}
.btn.danger { border-color: var(--fg); }
.btn.danger:hover { background: var(--fg); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.primary:hover { opacity: 0.8; }

/* inline input */
.inline-input {
  width: 100%;
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
  background: transparent;
  outline: none;
}
.inline-input:focus { border-bottom-color: var(--fg); }

/* connection lost banner */
#connection-banner {
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--fg); color: var(--bg);
  text-align: center;
  padding: 4px;
  font-size: var(--fs-sm);
  z-index: 9000;
  display: none;
}
#connection-banner.show { display: block; }

/* empty state */
.empty-state {
  text-align: center;
  color: var(--dim);
  padding: 2rem;
  font-size: var(--fs-sm);
}

/* confirm dialog */
.confirm-msg { margin-bottom: 0.75rem; }
