/* ═══════════════════════════════════════════════════════
   Dashboard — Admin / Founder / Tech-Admin Panel
   ═══════════════════════════════════════════════════════ */

/* ── Stats cards ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 18px; margin-bottom: 28px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 20px;
  transition: box-shadow .2s, transform .15s;
  animation: fadeUp .4s ease both;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; margin-bottom: 14px;
}
.stat-icon.users   { background: var(--blue-bg); }
.stat-icon.online  { background: rgba(46,204,113,.15); color: #2ecc71; }
.stat-icon.invites { background: var(--green-bg); }
.stat-icon.accepted{ background: var(--purple-bg); }
.stat-icon.active  { background: var(--gold-dim); }
.stat-value {
  font-size: 1.8rem; font-weight: 700; line-height: 1; margin-bottom: 4px;
}
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; }
.stat-change {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .72rem; font-weight: 600; margin-top: 8px;
  padding: 2px 7px; border-radius: 10px;
}
.stat-change.up   { background: var(--green-bg); color: var(--green); }
.stat-change.down { background: var(--red-bg); color: var(--red); }

/* ── Charts ── */
.chart-grid {
  display: grid; grid-template-columns: 2fr 1fr;
  gap: 18px; margin-bottom: 28px;
}
.chart-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 20px;
  animation: fadeUp .4s ease both;
}
.chart-card-title {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.chart-card-title h3 {
  font-size: 1rem; font-weight: 600;
}
.chart-card-title .pill { font-size: .72rem; padding: 3px 10px; }
.chart-canvas {
  width: 100%; height: 220px;
  display: block;
}

/* ── Users table ── */
.table-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 20px;
  margin-bottom: 20px; animation: fadeUp .4s ease both;
}
.table-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.table-header h3 { font-size: 1rem; font-weight: 600; }
.table-search {
  max-width: 260px; padding: 8px 14px; font-size: .85rem;
  border-radius: var(--radius-pill);
}
/* Task 2: Wrap table for horizontal scroll on mobile portrait */
.table-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table {
  width: 100%; border-collapse: collapse; min-width: 640px;
}
.data-table th {
  text-align: left; font-size: .7rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 2px solid var(--border);
}
.data-table td {
  padding: 12px; border-bottom: 1px solid rgba(0,0,0,.04);
  font-size: .9rem; vertical-align: middle;
}
.data-table tr:hover td { background: rgba(201,146,42,.03); }
.data-table tr:last-child td { border-bottom: none; }

.role-select {
  padding: 5px 10px; font-size: .8rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--paper); cursor: pointer;
  min-width: 140px;
}

/* ── Complaints section ── */
.complaint-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px 18px;
  margin-bottom: 10px; display: flex; align-items: flex-start; gap: 14px;
  animation: fadeUp .3s ease both;
}
.complaint-card.resolved { opacity: .5; }
.complaint-icon {
  font-size: 1.2rem; flex-shrink: 0; margin-top: 2px;
}
.complaint-body { flex: 1; }
.complaint-reason { font-weight: 500; margin-bottom: 4px; }
.complaint-meta { font-size: .78rem; color: var(--muted); line-height: 1.5; }
.complaint-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ── Truncated text with show more ── */
.truncated-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.6;
  word-break: break-word;
}
.truncated-text.expanded {
  -webkit-line-clamp: unset;
}
.toggle-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(201,146,42,.1);
  border: 1px solid rgba(201,146,42,.25);
  border-radius: 20px;
  color: var(--gold);
  font-size: .75rem;
  cursor: pointer;
  padding: 3px 12px 3px 10px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.4;
  transition: background .2s, border-color .2s;
  white-space: nowrap;
}
.toggle-more-btn:hover {
  background: rgba(201,146,42,.18);
  border-color: var(--gold);
  text-decoration: none;
}
.toggle-more-btn:active {
  transform: scale(.96);
}
.toggle-more-btn i {
  font-size: 14px;
  line-height: 1;
  transition: transform .2s;
}

/* ── Dashboard-specific sidebar active states ── */
.dash-section { margin-bottom: 32px; }
.dash-section-title {
  font-size: .8rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 14px;
}

/* ── Pagination ── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; margin-top: 16px;
}
.page-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: none;
  color: var(--muted); font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s;
}
.page-btn:hover { border-color: var(--gold); color: var(--gold); }
.page-btn.active {
  background: var(--gold); color: #fff; border-color: var(--gold);
}

/* ── Responsive dashboard ── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px 14px; }
  .stat-value { font-size: 1.5rem; }
  .table-header { flex-direction: column; align-items: stretch; }
  .table-search { max-width: none; }
  .chart-grid { grid-template-columns: 1fr; gap: 12px; }
  /* Advanced stats grid collapse to single column */
  .grid2 [style*="grid-column: span 2"],
  .grid2 [style*="grid-column:span 2"] {
    grid-column: span 1;
  }
  /* Reports breakdown: stack 4 columns into 2x2 */
  .grid2 [style*="grid-column: span 2"] > div[style*="grid-template-columns"],
  .grid2 [style*="grid-column:span 2"] > div[style*="grid-template-columns"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px 10px; }
  .stat-value { font-size: 1.3rem; }
  .stat-icon { width: 36px; height: 36px; font-size: 1.1rem; margin-bottom: 10px; }
}

/* ── Complaint Original Invite Preview ── */
.complaint-invite-preview {
  background: var(--warm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 10px;
  max-width: 100%;
}
.cip-header {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--gold);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cip-content {
  line-height: 1.45;
  font-size: 0.85rem;
}
.cip-msg {
  font-family: var(--font-heading);
  font-style: italic;
  color: var(--ink);
  margin-bottom: 6px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Comment line with icon ── */
.cmt-line {
  display: inline;
}
.cmt-line + .toggle-more-btn {
  vertical-align: middle;
  margin-left: 2px;
}

/* ── Dynamic card sizing — fit within fixed viewport ── */
.complaint-card {
  max-height: 45vh;
  overflow-y: auto;
}
.complaint-card.resolved {
  max-height: none;
  overflow-y: visible;
}
.complaint-card .complaint-invite-preview {
  max-height: 30vh;
  overflow-y: auto;
}
.cip-content .toggle-more-btn {
  margin-top: 4px;
  margin-bottom: 4px;
}
