/*
 * app.css — shared styles for all app pages
 * (dashboard, discussion, admin, profile, login, register)
 * Depends on: style.css (CSS variables)
 */

/* ── Base ───────────────────────────────────────────────────────────── */
body { font-family: 'DM Sans', system-ui, sans-serif; }

/* ── App header ─────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg); border-bottom: 1px solid var(--border);
  height: 56px; display: flex; align-items: center;
}
.app-header-inner {
  width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between;
}
.app-logo {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 300; font-size: 1.1rem;
  color: var(--text); letter-spacing: -0.02em;
  text-decoration: none; flex-shrink: 0;
}
.header-right { display: flex; align-items: center; gap: 16px; }

/* ── Header elements (consistent 36px touch target) ────────────────── */
.nav-link {
  font-family: 'DM Mono', monospace; font-size: 0.72rem;
  color: var(--text-2); text-decoration: underline;
  text-decoration-color: var(--border); text-underline-offset: 3px;
  line-height: 36px;
}
.nav-link:hover { color: var(--text); text-decoration-color: var(--text); }

.logout-btn {
  font-family: 'DM Mono', monospace; font-size: 0.72rem;
  color: var(--text-2); background: none; border: none;
  cursor: pointer; height: 36px; padding: 0 2px;
}
.logout-btn:hover { color: var(--text); }

.user-chip {
  font-family: 'DM Mono', monospace; font-size: 0.72rem;
  color: var(--text-2); line-height: 36px;
}
.quota-chip {
  font-family: 'DM Mono', monospace; font-size: 0.72rem; color: var(--text-2);
  padding: 3px 10px; border: 1px solid var(--border); border-radius: 20px;
  line-height: 1;
}
.admin-link {
  font-family: 'DM Mono', monospace; font-size: 0.72rem;
  color: var(--text-2); text-decoration: underline;
  text-decoration-color: var(--border); text-underline-offset: 3px;
  line-height: 36px;
}
.admin-link:hover { color: var(--text); text-decoration-color: var(--text); }

/* ── Page layout ────────────────────────────────────────────────────── */
.app-page {
  max-width: 1100px; margin: 0 auto; padding: 40px 32px 80px;
}
.app-page-sm {
  max-width: 680px; margin: 0 auto; padding: 48px 32px 80px;
}
.app-page-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 300; font-size: 1.6rem; color: var(--text);
  margin-bottom: 28px;
}

/* ── Section card ───────────────────────────────────────────────────── */
.app-section {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 20px; overflow: hidden;
}
.app-section-head {
  padding: 12px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: 'DM Mono', monospace; font-size: 0.65rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-2);
}
.app-section-body { padding: 20px; }

/* ── Typography scale ───────────────────────────────────────────────── */
/* 0.65rem — uppercase labels, meta */
/* 0.72rem — secondary (nav, logout) */
/* 0.78rem — mono table values */
/* 0.875rem — body, inputs */
/* 1.1rem — logo, small headings */
/* 1.6rem — page titles */

.label-caps {
  font-family: 'DM Mono', monospace; font-size: 0.65rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-2);
}
.mono-sm { font-family: 'DM Mono', monospace; font-size: 0.78rem; }

/* ── Button system ──────────────────────────────────────────────────── */
/* Heights: 28px (xs), 32px (sm), 36px (md/default), 40px (lg) */

/* Primary: dark bg */
.app-btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'DM Mono', monospace; font-size: 0.75rem;
  padding: 0 18px; height: 36px; border-radius: var(--radius);
  border: 1px solid var(--text); background: var(--text); color: var(--bg);
  cursor: pointer; white-space: nowrap; transition: opacity .15s;
  text-decoration: none;
}
.app-btn:hover { opacity: .82; }
.app-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Outline: border only */
.app-btn-outline {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'DM Mono', monospace; font-size: 0.72rem;
  padding: 0 12px; height: 32px; border-radius: var(--radius);
  border: 1px solid var(--border); background: none; color: var(--text-2);
  cursor: pointer; white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.app-btn-outline:hover { border-color: var(--text); color: var(--text); }
.app-btn-outline:disabled { opacity: .3; cursor: not-allowed; pointer-events: none; }

/* Danger variant */
.app-btn-outline.danger:hover { border-color: #c00; color: #c00; }

/* Ghost: no border */
.app-btn-ghost {
  display: inline-flex; align-items: center;
  font-family: 'DM Mono', monospace; font-size: 0.72rem;
  color: var(--text-2); background: none; border: none;
  cursor: pointer; padding: 0; height: 36px;
  transition: color .15s;
}
.app-btn-ghost:hover { color: var(--text); }

/* Full-width primary (forms) */
.app-btn-full {
  width: 100%; height: 40px;
  background: var(--text); color: var(--bg);
  border: none; border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif; font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: opacity .15s;
}
.app-btn-full:hover { opacity: .85; }
.app-btn-full:disabled { opacity: .4; cursor: not-allowed; }

/* ── Form components ────────────────────────────────────────────────── */
.app-field { margin-bottom: 16px; }
.app-label {
  display: block;
  font-family: 'DM Mono', monospace; font-size: 0.65rem;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 6px;
}
.app-input {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px; height: 38px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 0.875rem;
  outline: none; transition: border-color .15s; appearance: none;
}
.app-input:focus { border-color: var(--text); }
.app-input::placeholder { color: var(--text-3); }
textarea.app-input { height: auto; resize: vertical; min-height: 90px; }
select.app-input { cursor: pointer; }

/* ── Badge ──────────────────────────────────────────────────────────── */
.app-badge {
  display: inline-block;
  font-family: 'DM Mono', monospace; font-size: 0.62rem;
  padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--border); color: var(--text-2);
}
.app-badge.on  { border-color: var(--text); color: var(--text); }
.app-badge.off { color: var(--text-3); }
.app-badge.hi  { border-color: var(--text-2); background: var(--surface); }

/* ── Search input ───────────────────────────────────────────────────── */
.app-search {
  width: 100%; box-sizing: border-box;
  padding: 8px 12px; height: 36px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-family: 'DM Mono', monospace; font-size: 0.78rem;
  outline: none; transition: border-color .15s;
}
.app-search:focus { border-color: var(--text); }
.app-search::placeholder { color: var(--text-3); }

/* ── Table ──────────────────────────────────────────────────────────── */
.app-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.app-table th {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-2); font-weight: 400;
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.app-table td {
  padding: 11px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.app-table tr:hover td { background: var(--surface); }
.app-table .actions-cell { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Inline number input (table quota) ──────────────────────────────── */
.app-inline-input {
  width: 90px; padding: 4px 8px; height: 28px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-family: 'DM Mono', monospace; font-size: 0.78rem;
  outline: none; transition: border-color .15s;
}
.app-inline-input:focus { border-color: var(--text); }

/* ── Loading / empty states ─────────────────────────────────────────── */
.app-loading {
  padding: 48px 0; text-align: center;
  font-size: 0.875rem; color: var(--text-2);
}

/* ── Toast ──────────────────────────────────────────────────────────── */
.app-toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9000;
  padding: 10px 18px; border-radius: var(--radius);
  background: var(--text); color: var(--bg);
  font-family: 'DM Mono', monospace; font-size: 0.78rem;
  opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: 320px;
}
.app-toast.show { opacity: 1; }

/* ── Modal ──────────────────────────────────────────────────────────── */
.app-modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.app-modal-overlay.open { opacity: 1; pointer-events: auto; }
.app-modal {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 28px;
  width: 100%; max-width: 420px;
  transform: translateY(8px); transition: transform .2s;
}
.app-modal-overlay.open .app-modal { transform: translateY(0); }
.app-modal-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 300; font-size: 1.15rem; color: var(--text);
  margin-bottom: 20px;
}
.app-modal-footer {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px;
}

/* ── Inline form feedback ───────────────────────────────────────────── */
.app-form-msg {
  font-family: 'DM Mono', monospace; font-size: 0.72rem;
  margin-top: 10px; min-height: 1.2em;
}
.app-form-msg.ok  { color: var(--text-2); }
.app-form-msg.err { color: #c00; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .app-header-inner { padding: 0 16px; }
  .app-page, .app-page-sm { padding: 24px 16px 60px; }
}
