/* ============================================================
   Sale Scheduler Community Forum — app.css
   ============================================================ */

/* --- Custom Properties ------------------------------------ */
:root {
  --color-primary:   #6366f1;
  --color-primary-h: #4f52d3;
  --color-surface:   #ffffff;
  --color-bg:        #f5f5f7;
  --color-border:    #e2e2e8;
  --color-text:      #1a1a2e;
  --color-muted:     #6b7280;
  --color-danger:    #ef4444;
  --color-success:   #22c55e;
  --color-admin:     #f97316;
  --nav-height:      56px;
  --radius:          6px;
  --shadow:          0 1px 3px rgba(0,0,0,.08);
  --font:            'Inter', system-ui, -apple-system, sans-serif;
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
body   { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--color-text); background: var(--color-bg); }
h1,h2,h3 { margin: 0 0 .5rem; line-height: 1.3; }
a      { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img    { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
textarea, input, select { font-family: inherit; }

/* Material Symbols baseline */
.material-symbols-outlined {
  font-size: 18px;
  vertical-align: middle;
  line-height: 1;
  display: inline-block;
}

/* --- Layout ----------------------------------------------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}
.main {
  padding: 32px 0 64px;
  min-height: calc(100vh - var(--nav-height) - 56px);
}

/* --- Navigation ------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--nav-height);
  box-shadow: var(--shadow);
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 15px;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
}
.nav-brand:hover { text-decoration: none; color: var(--color-primary); }
.nav-brand .material-symbols-outlined { font-size: 22px; color: var(--color-primary); }
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: none;
  background: none;
  color: var(--color-text);
  font-size: 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
}
.nav-btn:hover { background: var(--color-bg); }
.nav-chevron { font-size: 16px; transition: transform .15s; }
.nav-btn[aria-expanded="true"] .nav-chevron { transform: rotate(180deg); }
.nav-admin-link { color: var(--color-admin); }

/* Dropdown */
.nav-dropdown { position: relative; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  min-width: 200px;
  z-index: 200;
}
.nav-dropdown-right { left: auto; right: 0; }
.nav-dropdown-menu.open { display: block; }
.nav-dropdown-menu li a,
.dropdown-logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: var(--color-text);
  font-size: 14px;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}
.nav-dropdown-menu li a:hover,
.dropdown-logout-btn:hover { background: var(--color-bg); text-decoration: none; }
.cat-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Search in nav */
.nav-search {
  display: flex;
  align-items: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 0 4px;
  transition: border-color .15s;
}
.nav-search:focus-within { border-color: var(--color-primary); }
.nav-search-input {
  border: none;
  background: none;
  padding: 4px 8px;
  font-size: 14px;
  width: 180px;
  outline: none;
  color: var(--color-text);
}
.nav-search-btn {
  border: none;
  background: none;
  color: var(--color-muted);
  padding: 4px 6px;
  display: flex;
}

/* --- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-h); border-color: var(--color-primary-h); }
.btn-ghost    { background: none; color: var(--color-text); border-color: var(--color-border); }
.btn-ghost:hover { background: var(--color-bg); }
.btn-danger   { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-sm       { padding: 5px 10px; font-size: 13px; }
.btn-block    { width: 100%; justify-content: center; }
.btn-admin    { background: #fff4ed; color: var(--color-admin); border-color: #fcd5b3; }
.btn-admin:hover { background: #ffe8d2; }

/* --- Flash messages --------------------------------------- */
.flash {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 14px;
  border-left: 4px solid;
}
.flash-error   { background: #fff1f1; border-color: var(--color-danger); color: #b91c1c; }
.flash-success { background: #f0fdf4; border-color: var(--color-success); color: #15803d; }
.flash-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  line-height: 1;
}
.flash-close:hover { opacity: 1; }

/* --- Page header ------------------------------------------ */
.page-header {
  margin-bottom: 24px;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-subtitle { margin: 4px 0 0; color: var(--color-muted); }
.category-header { padding-left: 12px; }

/* --- Topic table ------------------------------------------ */
.topic-table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.topic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.topic-table thead th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-muted);
  background: var(--color-bg);
}
.topic-row td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.topic-row:last-child td { border-bottom: none; }
.topic-row:hover { background: #fafafa; }
.topic-row.topic-locked .topic-link { color: var(--color-muted); }
.col-topic   { width: auto; }
.col-category{ width: 140px; }
.col-replies, .col-views { width: 60px; text-align: center; color: var(--color-muted); }
.col-activity { width: 120px; color: var(--color-muted); white-space: nowrap; }
.topic-link  { font-weight: 500; color: var(--color-text); display: flex; align-items: center; gap: 4px; }
.topic-link:hover { color: var(--color-primary); text-decoration: none; }
.topic-author { display: block; font-size: 12px; color: var(--color-muted); margin-top: 2px; }
.topic-lock-icon { font-size: 14px; color: var(--color-muted); }
.category-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.category-badge:hover { opacity: .85; text-decoration: none; }

/* --- Topic detail ----------------------------------------- */
.topic-header {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.topic-breadcrumb { font-size: 13px; color: var(--color-muted); margin-bottom: 8px; }
.topic-breadcrumb a { color: var(--color-muted); }
.breadcrumb-sep { margin: 0 6px; }
.topic-title {
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topic-meta { font-size: 13px; color: var(--color-muted); margin-top: 8px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.topic-meta .material-symbols-outlined { font-size: 14px; }
.admin-badge { margin-top: 8px; font-size: 12px; color: var(--color-muted); display: flex; align-items: center; gap: 4px; }

/* Posts */
.post {
  display: flex;
  gap: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.post-opener { border-left: 3px solid var(--color-primary); }
.post-avatar { flex-shrink: 0; }
.avatar-icon { font-size: 32px; color: var(--color-border); }
.post-content { flex: 1; min-width: 0; }
.post-author-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.post-username { font-weight: 600; font-size: 14px; }
.post-time { font-size: 12px; color: var(--color-muted); }
.post-body { font-size: 15px; line-height: 1.7; word-break: break-word; }
.post-body br { display: block; margin-bottom: .4em; }

/* Guest CTA */
.guest-cta {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 16px 0;
}
.guest-cta-icon { font-size: 36px; color: var(--color-primary); flex-shrink: 0; }
.guest-cta-text { flex: 1; }
.guest-cta-text strong { font-size: 15px; }
.guest-cta-text p { margin: 4px 0 0; font-size: 14px; color: var(--color-muted); }
.guest-cta-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* Replies section */
.replies-header { margin: 24px 0 12px; }
.replies-title  { font-size: 1rem; font-weight: 600; color: var(--color-muted); text-transform: uppercase; letter-spacing: .05em; }
.reply-list     { margin-bottom: 16px; }
.empty-replies  { color: var(--color-muted); font-size: 14px; padding: 12px 0; }

/* Reply form */
.reply-form-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 24px;
  box-shadow: var(--shadow);
}
.locked-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #fafafa;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-muted);
  font-size: 14px;
  margin-top: 16px;
}

/* Admin actions on topic */
.admin-topic-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.inline-form { display: inline; }

/* --- Forms ------------------------------------------------- */
.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.form-input  {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-textarea { resize: vertical; min-height: 120px; }
.form-select   { appearance: auto; }
.form-hint     { font-size: 12px; color: var(--color-muted); margin-top: 4px; display: block; }
.form-actions  { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.form-errors, .form-error-box {
  background: #fff1f1;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  color: #b91c1c;
  margin-bottom: 16px;
}
.form-errors p, .form-error-box p { margin: 4px 0; }

/* Topic form */
.topic-form { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }

/* --- Auth pages ------------------------------------------- */
.auth-wrap  { display: flex; justify-content: center; padding: 40px 0; }
.auth-box   { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-logo  { text-align: center; margin-bottom: 24px; }
.auth-logo-icon { font-size: 40px; color: var(--color-primary); }
.auth-title { font-size: 1.2rem; margin-top: 8px; }
.auth-form  { display: flex; flex-direction: column; gap: 4px; }
.auth-footer{ text-align: center; font-size: 13px; color: var(--color-muted); margin-top: 16px; }

/* --- Search ----------------------------------------------- */
.search-form { margin-bottom: 24px; }
.search-input-wrap { display: flex; gap: 8px; }
.search-input { flex: 1; }
.search-count { font-size: 14px; color: var(--color-muted); margin-bottom: 12px; }
.search-hint  { font-size: 14px; color: var(--color-muted); }

/* --- Admin ------------------------------------------------- */
.admin-page-header { display: flex; align-items: flex-start; flex-direction: column; gap: 12px; }
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-nav-link {
  padding: 5px 12px;
  font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  background: var(--color-surface);
}
.admin-nav-link:hover { background: var(--color-bg); text-decoration: none; }
.admin-nav-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card  {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-icon  { font-size: 28px; color: var(--color-primary); margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 13px; color: var(--color-muted); margin-top: 4px; }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: 12px; color: var(--color-muted); text-transform: uppercase; letter-spacing: .05em; }

.admin-table-wrap { overflow-x: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table thead th { padding: 10px 12px; border-bottom: 1px solid var(--color-border); text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-muted); background: var(--color-bg); white-space: nowrap; }
.admin-table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: #fafafa; }
.table-link { color: var(--color-text); font-weight: 500; }
.table-link:hover { color: var(--color-primary); }
.admin-actions { display: flex; gap: 6px; }
.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-muted);
  cursor: pointer;
  transition: background .15s;
}
.admin-btn:hover { background: var(--color-bg); color: var(--color-text); }
.admin-btn-danger { border-color: #fecaca; color: var(--color-danger); }
.admin-btn-danger:hover { background: #fff1f1; }
.admin-btn-success { border-color: #bbf7d0; color: var(--color-success); }
.admin-btn-success:hover { background: #f0fdf4; }
.admin-action-btn { border: none; background: none; color: var(--color-muted); cursor: pointer; display: inline-flex; align-items: center; padding: 2px; }
.admin-action-btn:hover { color: var(--color-danger); }

.role-badge  { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.role-admin  { background: #fef3c7; color: #92400e; }
.role-member { background: #e0e7ff; color: #3730a3; }
.status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-active { background: #f0fdf4; color: #15803d; }
.status-banned { background: #fff1f1; color: #b91c1c; }
.status-locked { background: #fef3c7; color: #92400e; }
.status-hidden { background: #f3f4f6; color: var(--color-muted); }
.table-you { font-size: 11px; color: var(--color-muted); font-style: italic; }

/* --- Pagination ------------------------------------------- */
.pagination { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 24px; }
.page-btn { padding: 6px 12px; font-size: 13px; border: 1px solid var(--color-border); border-radius: var(--radius); color: var(--color-text); background: var(--color-surface); }
.page-btn:hover { background: var(--color-bg); text-decoration: none; }
.page-info { font-size: 13px; color: var(--color-muted); }

/* --- Empty state ------------------------------------------ */
.empty-state { text-align: center; padding: 48px 16px; color: var(--color-muted); }
.empty-icon  { font-size: 48px; color: var(--color-border); display: block; margin-bottom: 12px; }

/* --- Footer ----------------------------------------------- */
.footer {
  border-top: 1px solid var(--color-border);
  padding: 16px 0;
  font-size: 13px;
  color: var(--color-muted);
  background: var(--color-surface);
}

/* --- Utility ---------------------------------------------- */
.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; }

/* --- Responsive ------------------------------------------- */
@media (max-width: 768px) {
  .nav-search-input { width: 120px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid .stat-card:last-child { grid-column: span 2; }
  .guest-cta { flex-direction: column; text-align: center; }
  .guest-cta-actions { justify-content: center; }
  .col-category, .col-views { display: none; }
  .topic-table thead .col-category,
  .topic-table thead .col-views { display: none; }
  .auth-wrap { padding: 16px; }
  .auth-box { padding: 20px; }
  .admin-table thead .col-hide-mobile,
  .admin-table td.col-hide-mobile { display: none; }
}
@media (max-width: 480px) {
  .nav-search { display: none; }
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid .stat-card:last-child { grid-column: auto; }
}
