/* ============================================================
   Life in Progress — admin.css
   Admin Portal Styles
   ============================================================ */

/* ===== ADMIN LAYOUT ===== */
body.admin-body {
  padding-top: 0;
  display: flex;
  min-height: 100dvh;
  background: var(--bg);
}

/* ===== SIDEBAR ===== */
.admin-sidebar {
  width: 260px;
  min-height: 100dvh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 800;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 1.4rem 1.4rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 38px; height: 38px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 700;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-sub {
  font-size: .72rem;
  color: var(--text-muted);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 1rem 0;
  flex: 1;
}

.nav-group-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .8rem 1.4rem .3rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem 1.4rem;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  position: relative;
}

.sidebar-link:hover {
  background: var(--bg-2);
  color: var(--text);
}

.sidebar-link.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar-logout { color: #e05252; }
.sidebar-logout:hover { background: #fee2e2; color: #991b1b; }

.nav-icon {
  font-size: 1.05rem;
  width: 1.4em;
  text-align: center;
  flex-shrink: 0;
}

.badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 99px;
  min-width: 1.5em;
  text-align: center;
}

/* ===== MAIN AREA ===== */
.admin-main {
  margin-left: 260px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ===== TOPBAR ===== */
.admin-topbar {
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.8rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.sidebar-toggle {
  display: none;
  font-size: 1.3rem;
  color: var(--text);
  padding: .3rem .5rem;
  border-radius: 6px;
  transition: background var(--dur) var(--ease);
}
.sidebar-toggle:hover { background: var(--bg-2); }

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  font-weight: 700;
}

/* ===== CONTENT ===== */
.admin-content {
  padding: 2rem 1.8rem 3rem;
  flex: 1;
}

/* ===== FLASH ===== */
.admin-flash {
  padding: .9rem 1.4rem;
  font-size: .9rem;
  font-weight: 500;
  border-radius: var(--radius);
  margin: 1rem 1.8rem 0;
}
.admin-flash--success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.admin-flash--error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.admin-flash--info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: var(--accent);
}
.stat-card.accent-2::before { background: #52b788; }
.stat-card.accent-3::before { background: #6c63ff; }
.stat-card.accent-4::before { background: #f59e0b; }

.stat-icon {
  font-size: 1.6rem;
  margin-bottom: .2rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-trend {
  font-size: .78rem;
  color: var(--accent);
  font-weight: 500;
}

/* ===== PANEL ===== */
.admin-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.8rem;
}

.panel-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.panel-body { padding: 1.5rem; }
.panel-body--flush { padding: 0; }

/* ===== TABLES ===== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.admin-table th {
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .75rem 1rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr { transition: background var(--dur) var(--ease); }
.admin-table tbody tr:hover { background: var(--bg-2); }

/* ===== STATUS BADGES ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .25rem .65rem;
  border-radius: 99px;
}
.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-new      { background: #dbeafe; color: #1d4ed8; }
.status-read     { background: #fef3c7; color: #92400e; }
.status-resolved { background: #d1fae5; color: #065f46; }

/* ===== SEARCH & FILTERS ===== */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  align-items: center;
  margin-bottom: 1.2rem;
}

.admin-input, .admin-select {
  padding: .55rem .9rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .88rem;
  transition: border-color var(--dur) var(--ease);
}
.admin-input:focus, .admin-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.admin-input { min-width: 220px; }

/* ===== BUTTONS ===== */
.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  border: 1.5px solid transparent;
}
.admin-btn-primary  { background: var(--accent);  color: #fff; }
.admin-btn-primary:hover  { background: var(--accent-2); }
.admin-btn-ghost    { background: transparent; border-color: var(--border); color: var(--text-muted); }
.admin-btn-ghost:hover    { border-color: var(--accent); color: var(--accent); }
.admin-btn-danger   { background: transparent; border-color: #fca5a5; color: #ef4444; }
.admin-btn-danger:hover   { background: #fee2e2; }
.admin-btn-success  { background: #059669; color: #fff; }
.admin-btn-success:hover  { background: #047857; }
.admin-btn-sm { padding: .3rem .75rem; font-size: .75rem; }

/* ===== CHART CONTAINERS ===== */
.chart-wrap {
  position: relative;
  height: 280px;
  padding: .5rem;
}

.chart-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.8rem;
}

/* ===== BAR CHART (pure CSS) ===== */
.css-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  height: 200px;
  padding: 0 .5rem;
}

.css-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  height: 100%;
  justify-content: flex-end;
}

.css-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 1s var(--ease);
  position: relative;
}
.css-bar:hover { background: var(--accent-2); }
.css-bar-val {
  position: absolute;
  top: -1.4rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text);
  opacity: 0;
  transition: opacity .2s;
}
.css-bar:hover .css-bar-val { opacity: 1; }
.css-bar-label {
  font-size: .68rem;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ===== DONUT CHART (SVG) ===== */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
}
.donut-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== PROGRESS BARS ===== */
.progress-row {
  margin-bottom: .9rem;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  margin-bottom: .3rem;
}
.progress-bar {
  height: 8px;
  background: var(--bg-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width 1.2s var(--ease);
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 70% 50% at 30% 50%, var(--accent-glow), transparent),
    var(--bg);
  padding: 1rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: min(420px, 100%);
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo-mark {
  display: inline-flex;
  width: 52px; height: 52px;
  background: var(--accent);
  color: #fff;
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-style: italic;
  font-weight: 700;
  margin-bottom: .8rem;
}
.login-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: .3rem;
}
.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: .88rem;
  margin-bottom: 1.8rem;
}

.login-form .form-group { margin-bottom: 1.1rem; }
.login-form label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .35rem;
  letter-spacing: .04em;
}
.login-form input {
  width: 100%;
  padding: .75rem 1rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .95rem;
  transition: border-color var(--dur) var(--ease);
}
.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.login-error {
  background: #fee2e2;
  color: #991b1b;
  border-radius: var(--radius);
  padding: .7rem 1rem;
  font-size: .88rem;
  margin-bottom: 1rem;
}
.login-hint {
  text-align: center;
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 1.2rem;
  padding: .7rem;
  background: var(--bg-2);
  border-radius: var(--radius);
}
.login-hint code {
  font-family: monospace;
  background: var(--border);
  padding: .1rem .35rem;
  border-radius: 4px;
}

/* ===== MESSAGE DETAIL MODAL ===== */
.msg-detail-wrap {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.msg-detail-wrap.open { display: flex; }
.msg-detail-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: min(560px, 100%);
  max-height: 85dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  position: relative;
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 1rem;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px; height: 34px;
  padding: 0 .5rem;
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  transition: all var(--dur) var(--ease);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ===== DATE RANGE TABS ===== */
.range-tabs {
  display: flex;
  gap: .3rem;
  background: var(--bg-2);
  border-radius: 99px;
  padding: .2rem;
}
.range-tab {
  padding: .35rem .9rem;
  border-radius: 99px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  border: none;
  background: transparent;
}
.range-tab.active, .range-tab:hover {
  background: var(--bg-card);
  color: var(--accent);
  box-shadow: var(--shadow);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: .7rem; }
.empty-state p { font-size: .9rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .admin-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 500px) {
  .admin-content { padding: 1.2rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .chart-grid-2 { grid-template-columns: 1fr; }
}
