/* ═══════════════════════════════════════════════
   PI SERVICE PROFILE ADMIN — admin.css
   Dark sidebar layout — FULLY RESPONSIVE
═══════════════════════════════════════════════ */

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #3b82f6;
  --success:       #22c55e;
  --danger:        #ef4444;
  --warning:       #f59e0b;
  --bg:            #f0f4ff;
  --surface:       #ffffff;
  --surface2:      #f8faff;
  --border:        #dde5f7;
  --text:          #0f172a;
  --text-muted:    #64748b;
  --sidebar-bg:    #0c1a4d;
  --sidebar-text:  rgba(255,255,255,.75);
  --sidebar-active:#2563eb;
  --radius:        12px;
  --shadow:        0 4px 24px rgba(37,99,235,.10);
  --transition:    .22s cubic-bezier(.4,0,.2,1);
  --sidebar-w:     220px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #060e2e 0%, #0f2167 50%, #1e3a8a 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.login-wrapper { width: 100%; max-width: 400px; }

.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 20px;
  padding: 44px 40px;
  box-shadow: 0 24px 80px rgba(0,0,80,.35);
}

.login-brand {
  text-align: center; margin-bottom: 32px;
}
.login-brand svg { margin-bottom: 12px; }
.login-brand h1 {
  font-size: 1.6rem; font-weight: 700; color: var(--text); margin-bottom: 4px;
}
.login-brand p { color: var(--text-muted); font-size: .875rem; }

.login-form { display: flex; flex-direction: column; gap: 20px; }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: .85rem; font-weight: 600; color: var(--text); }

.field-group input {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit; font-size: .9rem; color: var(--text);
  background: var(--surface2); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field-group input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); display: flex; align-items: center;
  transition: color var(--transition);
}
.pw-toggle:hover { color: var(--primary); }

.btn-login {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border: none; border-radius: var(--radius);
  padding: 14px; font-family: inherit; font-size: .95rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 16px rgba(37,99,235,.3);
  transition: all var(--transition); margin-top: 4px;
}
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(37,99,235,.4); }

.back-link {
  display: block; text-align: center; margin-top: 20px;
  font-size: .85rem; color: var(--text-muted); text-decoration: none;
  transition: color var(--transition);
}
.back-link:hover { color: var(--primary); }

/* ══════════════════════════════════════════════
   ALERTS (shared)
══════════════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: 10px; margin-bottom: 16px;
  font-size: .875rem; font-weight: 500;
  border-left: 4px solid;
}
.alert-success { background: #f0fdf4; border-color: var(--success); color: #166534; }
.alert-danger   { background: #fef2f2; border-color: var(--danger);  color: #991b1b; }
.alert-warning  { background: #fffbeb; border-color: var(--warning); color: #92400e; }
.alert-info     { background: #eff6ff; border-color: var(--primary); color: #1e40af; }

/* ══════════════════════════════════════════════
   DASHBOARD LAYOUT
══════════════════════════════════════════════ */
.dashboard-page { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────── */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 50;
  box-shadow: 4px 0 24px rgba(0,0,0,.2);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
  font-weight: 700; font-size: 1.05rem; color: #fff; letter-spacing: -.01em;
}

.sidebar-nav {
  flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px;
  color: var(--sidebar-text); text-decoration: none;
  font-size: .875rem; font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }

.sidebar-footer {
  padding: 16px; border-top: 1px solid rgba(255,255,255,.08);
}
.admin-info {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.admin-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.admin-name { font-weight: 600; color: #fff; font-size: .875rem; }
.admin-role { color: var(--sidebar-text); font-size: .75rem; }

.logout-btn {
  display: block; text-align: center;
  padding: 9px; border-radius: 8px;
  background: rgba(239,68,68,.12); color: #fca5a5;
  text-decoration: none; font-size: .8rem; font-weight: 600;
  transition: background var(--transition);
}
.logout-btn:hover { background: rgba(239,68,68,.25); }

/* ── Main area ───────────────────────────── */
.dashboard-main {
  margin-left: 220px; flex: 1;
  padding: 28px; min-height: 100vh;
}

/* ════════════════════════════════════════════
   ADMIN RESPONSIVE — Tablet & Mobile
════════════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar           { width: 64px; }
  .sidebar-brand span,
  .nav-item span,
  .admin-name,
  .admin-role        { display: none; }
  .sidebar-brand     { justify-content: center; padding: 16px 10px; gap: 0; }
  .nav-item          { justify-content: center; padding: 12px; gap: 0; }
  .sidebar-footer    { padding: 10px 6px; }
  .admin-info        { justify-content: center; }
  .logout-btn        { font-size: 0; padding: 8px; display: flex; justify-content: center; }
  .logout-btn::before { content: "↗"; font-size: .9rem; color: #fca5a5; }
  .dashboard-main    { margin-left: 64px; padding: 20px 16px; }
  .dash-title        { font-size: 1.3rem; }
}

@media (max-width: 640px) {
  .sidebar           { display: none; }
  .dashboard-main    { margin-left: 0; padding: 16px 12px; }
  .dash-title        { font-size: 1.2rem; }
  .dash-subtitle     { font-size: .82rem; }
  .dash-topbar       { flex-direction: column; align-items: stretch; gap: 12px; }
  .btn-export        { text-align: center; justify-content: center; }
  .stats-grid        { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card         { padding: 14px; gap: 10px; }
  .stat-value        { font-size: 1.6rem; }
  .search-bar        { flex-wrap: wrap; gap: 6px; }
  .search-bar input  { min-width: 0; }
  .search-bar button { width: 100%; }
  .data-table        { font-size: .8rem; }
  .data-table tbody td,
  .data-table thead th { padding: 10px 10px; }
  .detail-card-header { font-size: .9rem; padding: 14px 14px; }
  .detail-item       { padding: 12px 14px; }
  .pref-list         { padding: 12px 14px; }
}

@media (max-width: 420px) {
  .stats-grid     { grid-template-columns: 1fr; }
  .login-card     { padding: 32px 20px; }
  .search-bar     { padding: 8px 12px; }
}

/* ── Topbar ──────────────────────────────── */
.dash-topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.back-nav {
  font-size: .8rem; color: var(--primary); text-decoration: none;
  font-weight: 600; display: inline-block; margin-bottom: 6px;
}
.back-nav:hover { text-decoration: underline; }
.dash-title    { font-size: 1.75rem; font-weight: 700; color: var(--text); }
.dash-subtitle { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }

.btn-export {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; text-decoration: none; border: none; cursor: pointer;
  padding: 11px 20px; border-radius: 10px;
  font-family: inherit; font-size: .875rem; font-weight: 600;
  box-shadow: 0 4px 16px rgba(37,99,235,.25);
  transition: all var(--transition); white-space: nowrap;
}
.btn-export:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,.35); }

/* ── Stats cards ────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(37,99,235,.14); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon.blue  { background: #eff6ff; color: var(--primary); }
.stat-icon.green { background: #f0fdf4; color: var(--success); }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { color: var(--text-muted); font-size: .8rem; margin-top: 4px; }

/* ── Search bar ─────────────────────────── */
.search-bar-wrap { margin-bottom: 16px; }
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 10px 16px;
  box-shadow: var(--shadow);
}
.search-bar svg { color: var(--text-muted); flex-shrink: 0; }
.search-bar input {
  flex: 1; background: none; border: none; outline: none;
  font-family: inherit; font-size: .9rem; color: var(--text);
}
.search-bar button {
  padding: 8px 18px; background: var(--primary); color: #fff;
  border: none; border-radius: 8px; font-family: inherit;
  font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: background var(--transition);
}
.search-bar button:hover { background: var(--primary-dark); }
.clear-btn {
  color: var(--danger); font-size: .82rem; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.clear-btn:hover { text-decoration: underline; }

/* ── Table card ─────────────────────────── */
.table-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  overflow: hidden;
}
.table-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.table-count { font-size: .85rem; color: var(--text-muted); font-weight: 500; }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%; border-collapse: collapse;
  font-size: .875rem;
}
.data-table thead th {
  background: var(--surface2);
  padding: 12px 16px; text-align: left;
  font-weight: 600; color: var(--text-muted);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f5f8ff; }
.data-table tbody td { padding: 13px 16px; color: var(--text); }

.id-cell     { color: var(--text-muted); font-weight: 500; width: 48px; }
.name-cell   { font-weight: 600; }
.mobile-cell { font-family: monospace; font-size: .85rem; color: var(--primary-dark); }
.date-cell   { color: var(--text-muted); white-space: nowrap; }
.action-cell { white-space: nowrap; }

.btn-view {
  display: inline-block; padding: 5px 12px;
  background: #eff6ff; color: var(--primary);
  border-radius: 6px; text-decoration: none;
  font-size: .8rem; font-weight: 600;
  transition: background var(--transition);
}
.btn-view:hover { background: #dbeafe; }

.btn-delete {
  display: inline-block; padding: 5px 12px;
  background: #fef2f2; color: var(--danger);
  border: none; border-radius: 6px;
  font-family: inherit; font-size: .8rem; font-weight: 600;
  cursor: pointer; margin-left: 6px;
  transition: background var(--transition);
}
.btn-delete:hover { background: #fee2e2; }

/* ── Empty state ─────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state p { margin-top: 12px; font-size: .95rem; }

/* ── Detail page ────────────────────────── */
.detail-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  margin-bottom: 20px; overflow: hidden;
}
.detail-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; font-weight: 700; font-size: 1rem;
  background: linear-gradient(135deg, #0f2167 0%, #1e3a8a 100%);
  color: #fff;
}
.badge-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; flex-shrink: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
}
@media (max-width: 640px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.detail-item:nth-child(2n) { border-right: none; }
.detail-item.full { grid-column: 1 / -1; border-right: none; }

.detail-label { display: block; font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.detail-value { font-size: .9rem; color: var(--text); white-space: pre-wrap; line-height: 1.5; }

.badge-tag {
  display: inline-block; background: #eff6ff; color: var(--primary);
  padding: 4px 12px; border-radius: 20px; font-weight: 600; font-size: .82rem;
}

.no-data { padding: 24px 20px; color: var(--text-muted); font-size: .875rem; }

.pref-list { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.pref-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--surface2); border-radius: 10px;
  border: 1px solid var(--border);
}
.pref-rank {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; flex-shrink: 0;
}
.pref-value { font-weight: 500; }
