/* ============================================================
   KwikDoors — Admin Dashboard Styles
   ============================================================ */

/* ── Admin Layout ── */
.admin-layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--navbar-height);
  background: var(--bg-secondary);
}

/* ── Sidebar ── */
.admin-sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem 1rem;
  position: fixed;
  top: var(--navbar-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 30;
  transition: transform var(--transition-slow), background var(--transition-slow);
}

.admin-sidebar-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
  margin-top: 1.25rem;
}
.admin-sidebar-label:first-child { margin-top: 0; }

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font-display);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  position: relative;
  border: 1.5px solid transparent;
}

.admin-nav-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.admin-nav-item.active {
  background: var(--blue-50);
  color: var(--blue-600);
  font-weight: 600;
  border-color: var(--blue-100);
}

[data-theme="dark"] .admin-nav-item.active {
  background: rgba(30,111,190,0.12);
  color: var(--blue-300);
  border-color: rgba(30,111,190,0.2);
}

.admin-nav-badge {
  margin-left: auto;
  background: var(--orange-500);
  color: white;
  border-radius: var(--radius-full);
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.admin-nav-item:not(.active) .admin-nav-badge {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

/* ── Admin Main Content ── */
.admin-main {
  margin-left: 260px;
  flex: 1;
  padding: 2rem;
  min-width: 0;
}

/* ── Admin Header ── */
.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.admin-page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.admin-page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

/* ── Stats Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
}

.stat-card.stat-blue::before { background: var(--gradient-blue); }
.stat-card.stat-orange::before { background: var(--gradient-orange); }
.stat-card.stat-green::before { background: linear-gradient(135deg, #22C55E, #16A34A); }
.stat-card.stat-purple::before { background: linear-gradient(135deg, #8B5CF6, #7C3AED); }

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
}

.stat-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon-blue   { background: var(--blue-50);   color: var(--blue-500); }
.stat-icon-orange { background: var(--orange-50);  color: var(--orange-500); }
.stat-icon-green  { background: #F0FDF4; color: #16A34A; }
.stat-icon-purple { background: #FAF5FF; color: #7C3AED; }

[data-theme="dark"] .stat-icon-blue   { background: rgba(30,111,190,0.15); }
[data-theme="dark"] .stat-icon-orange { background: rgba(244,121,32,0.12); }
[data-theme="dark"] .stat-icon-green  { background: rgba(22,163,74,0.12); }
[data-theme="dark"] .stat-icon-purple { background: rgba(124,58,237,0.12); }

/* ── Table Panel ── */
.table-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

.table-panel-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}

/* Search Box */
.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  min-width: 220px;
  transition: all var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--blue-500);
  background: var(--bg-primary);
  box-shadow: 0 0 0 3px rgba(30,111,190,0.1);
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.search-box input::placeholder { color: var(--text-muted); }

/* Filter Select */
.filter-select {
  padding: 0.5rem 0.875rem;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-select:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(30,111,190,0.1);
}

/* ── Data Table ── */
.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 0.875rem 1rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td {
  background: var(--bg-secondary);
}

.data-table tr { transition: background var(--transition-fast); }

.td-name {
  font-weight: 600;
  color: var(--text-primary);
}

.td-phone {
  font-family: monospace;
  color: var(--blue-500);
  font-weight: 500;
}

.td-date {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.td-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.action-btn:hover { transform: scale(1.05); }

.action-btn.view:hover   { background: var(--blue-50); color: var(--blue-500); border-color: var(--blue-200); }
.action-btn.delete:hover { background: #FEF2F2; color: #DC2626; border-color: #FECACA; }

[data-theme="dark"] .action-btn.view:hover   { background: rgba(30,111,190,0.15); }
[data-theme="dark"] .action-btn.delete:hover { background: rgba(220,38,38,0.1); }

/* Status Select in Table */
.status-select {
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-display);
  outline: none;
}

.status-select.status-new      { background: var(--orange-50); color: var(--orange-600); border-color: var(--orange-100); }
.status-select.status-reviewed { background: var(--blue-50); color: var(--blue-600); border-color: var(--blue-100); }
.status-select.status-contacted { background: #F0FDF4; color: #15803D; border-color: #DCFCE7; }
.status-select.status-closed   { background: var(--bg-tertiary); color: var(--text-muted); border-color: var(--border-color); }

[data-theme="dark"] .status-select.status-new { background: rgba(244,121,32,0.12); }
[data-theme="dark"] .status-select.status-reviewed { background: rgba(30,111,190,0.12); }
[data-theme="dark"] .status-select.status-contacted { background: rgba(22,163,74,0.12); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: var(--text-muted);
}

.empty-title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.25rem; }
.empty-desc  { font-size: 0.875rem; }

/* ── Pagination ── */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-footer-info { font-size: 0.8rem; color: var(--text-muted); }

.pagination {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.page-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.page-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.page-btn.active { background: var(--blue-500); color: white; border-color: var(--blue-500); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Detail Drawer ── */
.detail-drawer {
  position: fixed;
  top: var(--navbar-height);
  right: 0;
  bottom: 0;
  width: 420px;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  z-index: 50;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
}

.detail-drawer.open { transform: translateX(0); }

.detail-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.detail-drawer-body { padding: 1.5rem; }

.detail-section { margin-bottom: 1.5rem; }
.detail-section-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-key { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; flex-shrink: 0; }
.detail-val { font-size: 0.875rem; color: var(--text-primary); font-weight: 600; text-align: right; }

/* ── Login Screen (for admin) ── */
.admin-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  padding: 1rem;
}

.admin-login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-xl);
  text-align: center;
}

.admin-login-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  box-shadow: var(--shadow-blue);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-main { margin-left: 0; }
  .detail-drawer { width: 100%; max-width: 400px; }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .admin-page-header { flex-direction: column; align-items: flex-start; }
  .table-actions { width: 100%; }
  .search-box { min-width: unset; flex: 1; }
}
