/* Admin Panel Styles */

.admin-view {
  padding: 2rem;
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid #e9ecef;
}

.admin-tab {
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  color: #6c757d;
  transition: all 0.2s;
  margin-bottom: -2px;
}

.admin-tab:hover {
  color: #495057;
  background: #f8f9fa;
}

.admin-tab.active {
  color: #6366f1;
  border-bottom-color: #6366f1;
  background: transparent;
}

.admin-tab-content {
  /* Content is shown/hidden via hidden class */
}

/* Status badges for migration history */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
}

.status-badge.status-success {
  background: #d4edda;
  color: #155724;
}

.status-badge.status-failed {
  background: #f8d7da;
  color: #721c24;
}

.status-badge.status-progress {
  background: #fff3cd;
  color: #856404;
}

.status-badge.status-cancelled {
  background: #e2e3e5;
  color: #383d41;
}

/* Admin Header */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.admin-header-title {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-icon {
  font-size: 2rem;
}

/* Users Table */
.users-table-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table thead {
  background: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
}

.users-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: #495057;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.users-table td {
  padding: 1rem;
  border-bottom: 1px solid #e9ecef;
  vertical-align: middle;
}

.users-table tbody tr:hover {
  background: #f8f9fa;
}

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

/* User Info in Table */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar-small {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.user-avatar-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-avatar-small span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.user-avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  font-weight: 600;
  font-size: 1.25rem;
}

.user-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-avatar-large span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Avatar Upload */
.avatar-upload-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  font-weight: 600;
  font-size: 1rem;
  border: 2px solid #e5e7eb;
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-preview span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
}

.user-name {
  font-weight: 600;
  color: #212529;
}

.user-email {
  font-size: 0.875rem;
  color: #6c757d;
}

/* Role Badges */
.role-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.role-admin {
  background: #e3f2fd;
  color: #1976d2;
}

.role-user {
  background: #f3e5f5;
  color: #7b1fa2;
}

.role-viewer {
  background: #e8f5e9;
  color: #388e3c;
}

/* Permissions List */
.permissions-list {
  font-size: 0.875rem;
  color: #6c757d;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-icon:hover {
  background: #f8f9fa;
  transform: scale(1.1);
}

.btn-icon.btn-danger:hover {
  background: #fff5f5;
}

.btn-icon:hover svg path {
  stroke-width: 2.5;
}

/* User Modal */
#userModal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#userModal .modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

#userModal .modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#userModal .modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: #212529;
}

#userModal .modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #6c757d;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

#userModal .modal-close:hover {
  background: #f8f9fa;
  color: #212529;
}

#userModal .modal-body {
  padding: 1.5rem;
}

/* User Details View */
.user-details-view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-row {
  display: flex;
  gap: 1rem;
}

.detail-row label {
  font-weight: 600;
  min-width: 120px;
  color: #495057;
}

.detail-row span {
  color: #212529;
}

/* Permissions Grid */
.permissions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.permission-tag {
  padding: 0.25rem 0.75rem;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #495057;
}

/* Permissions Checkboxes */
.permissions-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.permissions-checkboxes .checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.permissions-checkboxes .checkbox-label:hover {
  background: #f8f9fa;
}

.permissions-checkboxes input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Form */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #495057;
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: #6c757d;
  font-size: 0.875rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.required {
  color: #dc3545;
}

/* Modal Actions */
.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e9ecef;
}

/* Admin Stats */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.admin-stat-card {
  background: white;
  padding: 1rem;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-stat-icon {
  flex-shrink: 0;
}

.admin-stat-icon svg {
  width: 24px;
  height: 24px;
}

.admin-stat-content {
  flex: 1;
  min-width: 0;
}

.admin-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #212529;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.admin-stat-label {
  font-size: 0.8125rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Empty State */
.empty-row td {
  padding: 3rem !important;
  text-align: center;
}

.empty-state {
  color: #6c757d;
}

.empty-state p {
  margin: 0;
  font-size: 1.125rem;
}

/* Responsive */
@media (max-width: 768px) {
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .users-table-container {
    overflow-x: auto;
  }
  
  .users-table {
    min-width: 800px;
  }
  
  .admin-stats {
    grid-template-columns: 1fr;
  }
  
  #userModal .modal-content {
    width: 95%;
    margin: 1rem;
  }
  
  .permissions-checkboxes {
    grid-template-columns: 1fr;
  }
}

/* Error Message in Admin Forms (only inside user modal) */
#userModal .error-message,
#userFormError {
  background: #f8d7da !important;
  color: #721c24 !important;
  padding: 12px 16px !important;
  border-radius: 4px !important;
  margin-bottom: 1rem !important;
  border: 1px solid #f5c6cb !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  display: block !important;
  line-height: 1.5 !important;
}

#userModal .error-message.hidden,
#userFormError.hidden {
  display: none !important;
}

/* Hidden class */
.hidden {
  display: none !important;
}

