/* ============================================================
   Student Help Desk — Admin CSS
   Styles specific to the admin dashboard and login.
   ============================================================ */

/* Admin Body & Reset */
body.admin-body {
  background-color: #f3f4f6;
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-text);
}

/* ---------------------------------------------------
   Admin Login
--------------------------------------------------- */
.admin-login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.admin-login-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 400px;
  padding: 32px;
  text-align: center;
}

.admin-login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  margin-bottom: 16px;
}

.admin-login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-text);
}

.admin-login-subtitle {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-bottom: 24px;
}

.admin-login-form {
  text-align: left;
}

/* ---------------------------------------------------
   Admin Layout (Sidebar + Content)
--------------------------------------------------- */
.admin-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.admin-sidebar {
  width: 250px;
  background: white;
  border-right: 1px solid var(--color-border-light);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform 0.3s ease;
}

.admin-sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--color-border-light);
}

.admin-sidebar-logo {
  color: var(--color-primary);
}

.admin-sidebar-brand {
  font-weight: 600;
  font-size: 1.1rem;
}

.admin-nav {
  padding: 16px 12px;
  flex-grow: 1;
  overflow-y: auto;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

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

.admin-nav-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.admin-sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--color-border-light);
}

.admin-signed-in-as {
  padding: 0 12px 10px;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  overflow-wrap: break-word;
}
.admin-signed-in-as strong {
  display: block;
  color: var(--color-text);
  font-size: 0.85rem;
  font-weight: 600;
}

/* Content Area */
.admin-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-header {
  background: white;
  height: 64px;
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.admin-header-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-mobile-menu {
  display: none;
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
}

.admin-content-scroll {
  flex-grow: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Responsive Admin Layout */
@media (max-width: 768px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-mobile-menu {
    display: block;
  }
}

.admin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.admin-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ---------------------------------------------------
   Dashboard Cards & Stats
--------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-info .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}
.stat-info .stat-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ---------------------------------------------------
   Admin Tables & Lists
--------------------------------------------------- */
.admin-section {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  display: none; /* sections are hidden by default, JS toggles them */
}
.admin-section.active {
  display: block;
}

.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-table-container {
  overflow-x: auto;
}

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

.admin-table th, .admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
}

.admin-table th {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-bg-secondary);
}

.admin-table td {
  font-size: 0.95rem;
  vertical-align: middle;
}

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

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

/* Keep the Actions column reachable without horizontal scrolling —
   every admin table ends with an actions column, so pinning the
   last column keeps Edit/Delete visible on narrow phone screens
   while the rest of the row's data can still scroll under it. */
.admin-table th:last-child,
.admin-table td:last-child {
  position: sticky;
  right: 0;
  white-space: nowrap;
  box-shadow: -6px 0 6px -6px rgba(0,0,0,0.15);
}
.admin-table th:last-child {
  background: var(--color-bg-secondary);
}
.admin-table td:last-child {
  background: white;
}
.admin-table tr:hover td:last-child {
  background: #f9fafb;
}
.admin-table th:first-child,
.admin-table td:first-child {
  min-width: 110px;
}

.table-actions {
  display: flex;
  gap: 8px;
}
.action-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
}
.action-btn:hover {
  background: var(--color-bg-secondary);
  color: var(--color-primary);
}
.action-btn.danger:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.success { background: #dcfce7; color: #166534; }
.badge.warning { background: #fef9c3; color: #854d0e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.info { background: #dbeafe; color: #1e40af; }

/* ---------------------------------------------------
   Section toolbar heading + form section headings
--------------------------------------------------- */
.admin-form-heading {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 24px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}
.admin-form-heading:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* ---------------------------------------------------
   File upload rows + thumbnails (Settings, Documents, Gallery)
--------------------------------------------------- */
.admin-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

/* ---------------------------------------------------
   Gallery photo management grid
--------------------------------------------------- */
.admin-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.admin-photo-tile {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--color-bg-secondary);
  box-shadow: var(--shadow-sm);
}
.admin-photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.admin-photo-tile .admin-photo-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.admin-photo-tile .admin-photo-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.65));
  color: white;
  font-size: 0.72rem;
  padding: 12px 8px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------
   Settings → Banner Images manager (reuses the photo tile look)
--------------------------------------------------- */
.admin-banner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.admin-banner-grid:empty {
  display: none;
}
.admin-banner-grid .admin-photo-tile {
  aspect-ratio: 16/9;
}

/* ---------------------------------------------------
   Modals
--------------------------------------------------- */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  padding: 20px;
}
.admin-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.admin-modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: scale(0.95);
  transition: transform 0.2s;
}
.admin-modal-overlay.open .admin-modal {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover { color: var(--color-text); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border-light);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #f9fafb;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
