/* ==========================================================================
   ISTQB CT-GenAI Master - Dedicated Admin Dashboard Styles
   ========================================================================== */

:root {
  --admin-primary: #4f46e5;
  --admin-primary-hover: #4338ca;
  --admin-dark-bg: #0f172a;
  --admin-sidebar-bg: #1e1b4b;
  --admin-card-bg: #ffffff;
  --admin-border: #e2e8f0;
  --admin-text-main: #0f172a;
  --admin-text-muted: #64748b;
}

[data-theme="dark"] {
  --admin-card-bg: #1e293b;
  --admin-border: #334155;
  --admin-text-main: #f8fafc;
  --admin-text-muted: #94a3b8;
}

body.admin-body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #f8fafc;
  color: var(--admin-text-main);
  min-height: 100vh;
}

[data-theme="dark"] body.admin-body {
  background-color: #0b1120;
}

/* --------------------------------------------------------------------------
   1. Admin Login View (When Not Authenticated)
   -------------------------------------------------------------------------- */
.admin-login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #312e81 0%, #0f172a 100%);
  padding: 20px;
  box-sizing: border-box;
}

.admin-login-card {
  width: 440px;
  max-width: 95vw;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-login-header {
  background: linear-gradient(135deg, #1e1b4b 0%, #3730a3 100%);
  color: #ffffff;
  padding: 30px 24px;
  text-align: center;
}

.admin-login-icon {
  font-size: 2.8rem;
  margin-bottom: 8px;
  display: inline-block;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.admin-login-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 4px 0;
}

.admin-login-subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
}

.admin-login-body {
  padding: 28px 24px;
}

.admin-quick-fill-btn {
  width: 100%;
  margin-bottom: 20px;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  color: #475569;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.admin-quick-fill-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
  border-color: #94a3b8;
}

/* --------------------------------------------------------------------------
   2. Main Admin Dashboard Layout
   -------------------------------------------------------------------------- */
.admin-layout {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}

.admin-layout.active {
  display: flex;
}

/* Header Navbar */
.admin-navbar {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: #ffffff;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.15rem;
  font-weight: 800;
}

.admin-nav-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-nav-viewsite {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 9999px;
  transition: all 0.2s;
}

.btn-nav-viewsite:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.btn-admin-logout {
  background: #ef4444;
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}

.btn-admin-logout:hover {
  background: #dc2626;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.35);
}

/* Dashboard Container */
.admin-main-content {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  box-sizing: border-box;
}

/* KPI Metric Cards */
.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.kpi-card.pending {
  border-left: 5px solid #f59e0b;
}

.kpi-card.active-users {
  border-left: 5px solid #10b981;
}

.kpi-card.answers {
  border-left: 5px solid #3b82f6;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--admin-text-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--admin-text-main);
  line-height: 1.1;
}

.kpi-icon {
  font-size: 2.2rem;
  opacity: 0.85;
}

/* Section Header & Toolbar */
.section-panel {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #fdfdfe;
}

[data-theme="dark"] .panel-header {
  background: #182234;
}

.panel-title-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0;
}

.panel-badge {
  background: #e0e7ff;
  color: #3730a3;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-batch-approve {
  background: #10b981;
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-batch-approve:hover {
  background: #059669;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

.btn-refresh {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  color: var(--admin-text-main);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}

.btn-refresh:hover {
  background: #f1f5f9;
}

/* Filter & Search Bar */
.filter-toolbar {
  padding: 14px 20px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--admin-card-bg);
}

.search-box-wrapper {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--admin-text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--admin-border);
  border-radius: 9999px;
  font-size: 0.85rem;
  background: #f8fafc;
  outline: none;
  box-sizing: border-box;
}

.search-input:focus {
  border-color: var(--admin-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.status-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.status-tab {
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.status-tab:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.status-tab.active {
  background: #1e1b4b;
  color: #ffffff;
}

/* User Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.86rem;
}

.admin-table th {
  padding: 12px 16px;
  background: #f8fafc;
  color: var(--admin-text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  border-bottom: 1px solid var(--admin-border);
  white-space: nowrap;
}

[data-theme="dark"] .admin-table th {
  background: #131d2e;
}

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

.admin-table tr:hover {
  background: #f8fafc;
}

[data-theme="dark"] .admin-table tr:hover {
  background: #1e293b;
}

/* User Row Components */
.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-meta-name {
  font-weight: 700;
  color: var(--admin-text-main);
  line-height: 1.2;
}

.user-meta-username {
  font-size: 0.75rem;
  color: var(--admin-text-muted);
}

.phone-link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.phone-link:hover {
  text-decoration: underline;
}

/* Status Pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill-pending {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  animation: pulseAmber 1.8s infinite;
}

.pill-active {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.pill-blocked {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.pill-expired {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

/* Action Button Grid in Cell */
.actions-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-action {
  padding: 4px 9px;
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn-action-green {
  background: #10b981;
  color: #ffffff;
}

.btn-action-green:hover {
  background: #059669;
}

.btn-action-purple {
  background: #e0e7ff;
  color: #3730a3;
}

.btn-action-purple:hover {
  background: #c7d2fe;
}

.btn-action-red {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.btn-action-red:hover {
  background: #ef4444;
  color: #ffffff;
}

.btn-action-blue {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.btn-action-blue:hover {
  background: #dbeafe;
}

/* Detail Modal */
.admin-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.admin-modal-backdrop.active {
  display: flex;
}

.detail-modal-box {
  width: 720px;
  max-width: 95vw;
  max-height: 85vh;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.detail-modal-header {
  padding: 16px 22px;
  background: #1e1b4b;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

@keyframes popIn {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulseAmber {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* ==========================================================================
   Mobile Phone & Touch Optimization (ISTQB CT-GenAI Admin)
   Supports automatic device detection (body.is-mobile, [data-device="mobile"])
   and responsive media queries (max-width: 768px).
   ========================================================================== */

@media (max-width: 768px), (pointer: coarse) and (max-width: 900px) {
  /* Prevent iOS Safari auto-zoom on inputs */
  input[type="text"],
  input[type="password"],
  input[type="search"],
  .search-input {
    font-size: 16px !important;
  }

  /* Admin Header */
  .admin-navbar {
    height: auto !important;
    padding: 12px 14px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .admin-brand {
    justify-content: space-between;
    width: 100%;
    font-size: 1.05rem;
  }

  .admin-nav-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .btn-nav-viewsite,
  .btn-admin-logout {
    padding: 8px 12px;
    font-size: 0.8rem;
    min-height: 38px;
    box-sizing: border-box;
  }

  /* Main Container */
  .admin-main-content {
    padding: 14px 10px 40px !important;
  }

  /* 2x2 KPI Cards on Phone */
  .admin-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
  }

  .kpi-card {
    padding: 12px 14px !important;
  }

  .kpi-label {
    font-size: 0.7rem !important;
  }

  .kpi-value {
    font-size: 1.45rem !important;
  }

  .kpi-icon {
    font-size: 1.6rem !important;
  }

  /* Panel Header & Batch Actions */
  .panel-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 14px !important;
  }

  .panel-title-area {
    justify-content: space-between;
    width: 100%;
  }

  .panel-title {
    font-size: 1rem !important;
  }

  .panel-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .btn-batch-approve,
  .btn-refresh {
    width: 100% !important;
    justify-content: center !important;
    min-height: 42px !important;
    font-size: 0.8rem !important;
  }

  /* Filter & Search Bar */
  .filter-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 12px 14px !important;
  }

  .search-box-wrapper {
    min-width: 100% !important;
    max-width: 100% !important;
  }

  .search-input {
    min-height: 42px;
    padding-left: 38px;
  }

  /* Scrollable Filter Tabs on Mobile */
  .status-tabs {
    display: flex !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    gap: 8px !important;
  }

  .status-tab {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    min-height: 34px !important;
    padding: 6px 14px !important;
    font-size: 0.8rem !important;
  }

  /* Table Smooth Touch Scroll */
  .table-responsive {
    -webkit-overflow-scrolling: touch;
  }

  .admin-table th,
  .admin-table td {
    padding: 10px 12px !important;
    font-size: 0.82rem !important;
  }

  .btn-action-emerald,
  .btn-action-amber,
  .btn-action-purple,
  .btn-action-red,
  .btn-action-blue {
    min-height: 36px !important;
    padding: 6px 12px !important;
    font-size: 0.82rem !important;
    margin: 2px 0;
  }

  /* Modal Dialog on Mobile */
  .admin-modal-backdrop {
    padding: 10px !important;
  }

  .detail-modal-box {
    width: 100% !important;
    max-width: 100vw !important;
    max-height: 92vh !important;
    border-radius: 12px !important;
  }

  .detail-modal-header {
    padding: 14px 16px !important;
  }

  .detail-modal-body {
    padding: 16px 14px !important;
  }
}
