@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('/styles/playabl-tokens.css');
@import url('/styles/fonts.css');

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

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

button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: none; background: none; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ── Top nav ──────────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 56px;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 clamp(1rem, 4vw, 2rem);
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-blue) 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-nordique);
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.topnav-title {
  font-family: var(--font-nordique);
  font-size: 1rem;
  color: var(--text-h);
  letter-spacing: 0.02em;
}

.topnav-spacer { flex: 1; }

.topnav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-h);
  font-size: 0.8rem;
  font-weight: 500;
}

/* ── Page shell ───────────────────────────────────────────── */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem clamp(1rem, 4vw, 2rem) 4rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-h);
  flex: 1;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0 0.9rem;
  height: 34px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm { height: 28px; padding: 0 0.65rem; font-size: 0.8rem; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 85%, #fff);
}

.btn-secondary {
  background: var(--surface-elevated);
  color: var(--text-h);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--glass-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--glass-hover); color: var(--text-h); }

.btn-danger {
  background: color-mix(in srgb, var(--error) 15%, var(--surface));
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 30%, transparent);
}
.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--error) 25%, var(--surface));
}

.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-size: 1.1rem;
  line-height: 1;
}
.btn-icon:hover { background: var(--glass-hover); color: var(--text-h); border-color: var(--border); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-open {
  background: color-mix(in srgb, var(--accent-blue) 18%, transparent);
  color: var(--accent-blue);
}
.badge-in_progress {
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  color: var(--warning);
}
.badge-completed {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
}
.badge-admin {
  background: color-mix(in srgb, var(--purple-500) 18%, transparent);
  color: var(--purple-500);
}

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ── Project table ────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.project-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.project-table thead {
  background: var(--surface-sunken);
}

.project-table th {
  padding: 0.65rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.project-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.project-table tbody tr:last-child td { border-bottom: none; }

.project-table tbody tr {
  transition: background 0.1s;
}
.project-table tbody tr:hover { background: color-mix(in srgb, var(--glass-hover) 50%, transparent); }

.col-title { width: 34%; }
.col-notes { width: 28%; }
.col-status { width: 10%; }
.col-assigned { width: 12%; }
.col-updated { width: 10%; }
.col-actions { width: 6%; text-align: right; }

.project-title {
  color: var(--text-h);
  font-weight: 600;
  font-size: 0.9rem;
}

.notes-preview {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
  cursor: pointer;
}

.notes-preview.expanded {
  -webkit-line-clamp: unset;
}

.notes-expand-btn {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
  margin-top: 0.2rem;
  display: block;
}

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 0.8rem; }

/* ── 3-dot dropdown ───────────────────────────────────────── */
.dropdown-wrap {
  display: inline-flex;
}

.dropdown-menu {
  position: fixed;
  min-width: 192px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  z-index: 500;
  overflow: hidden;
  animation: dropdown-in 0.1s ease;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  color: var(--text-h);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.dropdown-item:hover { background: var(--glass-hover); }
.dropdown-item.danger { color: var(--error); }
.dropdown-item.danger:hover { background: color-mix(in srgb, var(--error) 12%, transparent); }

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

.dropdown-icon {
  font-size: 0.8rem;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.6;
  font-style: normal;
}

/* ── Modals ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 100;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  width: min(100%, 560px);
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  animation: modal-in 0.15s ease;
}

.modal-lg { width: min(100%, 720px); }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-header h2 {
  flex: 1;
  font-size: 1rem;
  color: var(--text-h);
  font-weight: 600;
}

.modal-body { padding: 1.25rem; }

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

/* ── Forms ────────────────────────────────────────────────── */
.field + .field { margin-top: 1rem; }

.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--dim);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  color: var(--text-h);
  transition: border-color 0.12s;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.field textarea { min-height: 90px; resize: vertical; }

.field-hint {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--dim);
  cursor: pointer;
  margin-top: 0.75rem;
}

/* ── Drop zone ────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface-sunken);
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--surface-sunken));
}

.drop-zone input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-zone-icon { font-size: 1.5rem; margin-bottom: 0.5rem; opacity: 0.5; }

.drop-zone-label {
  font-size: 0.9rem;
  color: var(--dim);
  font-weight: 500;
}

.drop-zone-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.drop-zone.has-file {
  border-style: solid;
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 6%, var(--surface-sunken));
}

.drop-zone.has-file .drop-zone-icon::before { content: '✓ '; color: var(--success); }

/* ── Upload history ───────────────────────────────────────── */
.history-list { display: grid; gap: 0.65rem; margin-top: 0.75rem; }

.history-item {
  padding: 0.85rem 1rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.version-chip {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-h);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-family: monospace;
}

.history-note {
  font-size: 0.83rem;
  color: var(--dim);
  line-height: 1.45;
  white-space: pre-wrap;
  margin-bottom: 0.5rem;
}

/* ── Notifications (toast) ────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: grid;
  gap: 0.5rem;
  max-width: 360px;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: toast-in 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast-success {
  background: color-mix(in srgb, var(--success) 15%, var(--surface-elevated));
  border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
  color: var(--success);
}

.toast-error {
  background: color-mix(in srgb, var(--error) 15%, var(--surface-elevated));
  border: 1px solid color-mix(in srgb, var(--error) 30%, transparent);
  color: var(--error);
}

/* ── Login ────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--background-deep);
}

.login-card {
  width: min(100%, 400px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.login-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent-blue));
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-nordique);
  font-size: 1.1rem;
  font-weight: 700;
}

.login-brand h1 {
  font-family: var(--font-nordique);
  font-size: 1.4rem;
  color: var(--text-h);
}

.login-brand p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.login-error {
  padding: 0.65rem 0.85rem;
  background: color-mix(in srgb, var(--error) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--error) 30%, transparent);
  color: var(--error);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}

.empty-state-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.9rem; }

/* ── Detail section inside modal ─────────────────────────── */
.detail-section + .detail-section {
  border-top: 1px solid var(--border-subtle);
  margin-top: 1.25rem;
  padding-top: 1.25rem;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.detail-notes {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  color: var(--dim);
  line-height: 1.55;
  white-space: pre-wrap;
}

.assignee-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.assignee-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-blue));
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ── Help modal ───────────────────────────────────────────── */
.help-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 520px;
}

.help-nav {
  border-right: 1px solid var(--border);
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.help-nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 1rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--dim);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.1s, color 0.1s;
}

.help-nav-btn:hover { background: var(--glass-hover); color: var(--text-h); }
.help-nav-btn.active { color: var(--text-h); background: color-mix(in srgb, var(--primary) 12%, transparent); font-weight: 600; }

.help-content {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: 620px;
}

.help-content h3 {
  font-size: 1rem;
  color: var(--text-h);
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.help-content h4 {
  font-size: 0.85rem;
  color: var(--text-h);
  margin: 1.25rem 0 0.4rem;
  font-weight: 600;
}

.help-content p {
  font-size: 0.85rem;
  color: var(--dim);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.help-content ul, .help-content ol {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.help-content li {
  font-size: 0.85rem;
  color: var(--dim);
  line-height: 1.6;
  margin-bottom: 0.25rem;
}

.help-content strong { color: var(--text-h); font-weight: 600; }

.help-content code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  background: var(--code-bg);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  color: var(--accent-blue);
}

.help-codeblock {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin: 0.5rem 0 0.9rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  color: var(--dim);
  line-height: 1.65;
  white-space: pre;
  overflow-x: auto;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1rem;
  font-size: 0.82rem;
}

.help-table th {
  text-align: left;
  padding: 0.45rem 0.75rem;
  background: var(--surface-sunken);
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

.help-table td {
  padding: 0.5rem 0.75rem;
  color: var(--dim);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.help-table tr:last-child td { border-bottom: none; }

.help-table td:first-child { color: var(--text-h); font-weight: 500; white-space: nowrap; }

.help-checklist {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1rem;
}

.help-checklist li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  color: var(--dim);
  border-bottom: 1px solid var(--border-subtle);
}

.help-checklist li:last-child { border-bottom: none; }

.help-checklist li::before {
  content: '○';
  color: var(--muted);
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.help-tip {
  background: color-mix(in srgb, var(--accent-blue) 10%, var(--surface-sunken));
  border: 1px solid color-mix(in srgb, var(--accent-blue) 25%, transparent);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  font-size: 0.83rem;
  color: var(--dim);
  margin: 0.5rem 0 1rem;
  line-height: 1.5;
}

.help-tip strong { color: var(--accent-blue); }

.fix-category {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}

.fix-category-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.fix-category-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-h);
  margin-bottom: 0.35rem;
}

.fix-category-desc {
  font-size: 0.82rem;
  color: var(--dim);
  line-height: 1.5;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 760px) {
  .table-wrap { border-radius: 0; border-left: 0; border-right: 0; }

  .project-table { min-width: unset; }
  .project-table thead { display: none; }

  .project-table tr {
    display: block;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
  }

  .project-table td {
    display: block;
    border: none;
    padding: 0.2rem 0;
  }

  .project-table td::before {
    content: attr(data-label) ': ';
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.05em;
  }

  .col-actions { text-align: left; }
}
