/* Mad Science Staff Hub - Styles */
/* Brand Colors: Purple (#6B21A8), Green (#22C55E), Dark (#1E1B4B) */

:root {
  --purple-50: #faf5ff;
  --purple-100: #f3e8ff;
  --purple-200: #e9d5ff;
  --purple-300: #d8b4fe;
  --purple-400: #c084fc;
  --purple-500: #a855f7;
  --purple-600: #9333ea;
  --purple-700: #7c3aed;
  --purple-800: #6B21A8;
  --purple-900: #581c87;

  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --green-200: #bbf7d0;
  --green-300: #86efac;
  --green-400: #4ade80;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-700: #15803d;

  --dark: #1E1B4B;
  --dark-light: #312e81;

  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --danger: #dc2626;
  --warning: #f59e0b;
  --success: #22c55e;

  --font-display: 'Fredoka', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius: 8px;
  --radius-lg: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, var(--purple-50) 0%, var(--gray-100) 100%);
  min-height: 100vh;
  color: var(--gray-800);
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  background: var(--dark);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.logo-img {
  height: 45px;
  width: auto;
}

.logo-text-wrap {
  display: flex;
  flex-direction: column;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}

.logo-subtitle {
  font-size: 0.75rem;
  color: var(--purple-300);
  font-weight: 500;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
}

.nav-link {
  color: var(--purple-200);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  transition: all 0.2s;
}

.nav-link:hover {
  background: var(--dark-light);
  color: white;
}

.nav-link.active {
  background: var(--purple-700);
  color: white;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-name {
  color: var(--purple-200);
  font-weight: 500;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.875rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--purple-700);
  color: white;
}

.btn-primary:hover {
  background: var(--purple-800);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-300);
}

.btn-success {
  background: var(--green-600);
  color: white;
}

.btn-success:hover {
  background: var(--green-700);
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-logout {
  background: transparent;
  color: var(--purple-200);
  border: 1px solid var(--purple-400);
}

.btn-logout:hover {
  background: var(--purple-700);
  color: white;
}

.btn-small {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
}

.btn-full {
  width: 100%;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Dashboard */
.dashboard {
  padding: 1rem 0;
}

.dashboard-header {
  text-align: center;
  margin-bottom: 2rem;
}

.dashboard-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.dashboard-header p {
  color: var(--gray-600);
}

/* Module Cards */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.module-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  border: 2px solid transparent;
}

.module-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--purple-300);
}

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

.module-icon svg {
  width: 28px;
  height: 28px;
  color: white;
}

.module-info {
  flex: 1;
  min-width: 0;
}

.module-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.module-description {
  font-size: 0.875rem;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-arrow {
  flex-shrink: 0;
  color: var(--gray-300);
  transition: all 0.2s;
}

.module-arrow svg {
  width: 24px;
  height: 24px;
}

.module-card:hover .module-arrow {
  color: var(--purple-500);
  transform: translateX(4px);
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dark) 0%, var(--purple-900) 100%);
}

.login-container {
  background: white;
  padding: 3rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 150px;
  height: auto;
  margin-bottom: 1rem;
}

.login-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--dark);
}

.login-subtitle {
  color: var(--gray-500);
  font-size: 1rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-footer {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
  color: var(--gray-400);
  font-size: 0.875rem;
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--gray-700);
}

.form-group input,
.form-group select {
  padding: 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px var(--purple-100);
}

.form-group input[type="color"] {
  height: 42px;
  padding: 0.25rem;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.checkbox-group label {
  flex-direction: row;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--purple-600);
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.alert-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* Admin Pages */
.admin-page {
  padding: 1rem 0;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.page-header p {
  color: var(--gray-500);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card.full-width {
  grid-column: 1 / -1;
}

.card h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--dark);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--purple-100);
}

/* Tables */
.table-container {
  overflow-x: auto;
}

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

.data-table th,
.data-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.data-table th {
  font-weight: 600;
  color: var(--gray-600);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.data-table tr.inactive {
  opacity: 0.6;
}

.data-table .actions {
  display: flex;
  gap: 0.5rem;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-badge.active {
  background: var(--green-100);
  color: var(--green-700);
}

.status-badge.inactive {
  background: var(--gray-100);
  color: var(--gray-600);
}

.status-badge.admin-only {
  background: var(--purple-100);
  color: var(--purple-700);
}

.status-badge.super-admin-only {
  background: #fef3c7;
  color: #92400e;
}

/* Role Badges */
.role-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.role-badge.super-admin {
  background: linear-gradient(135deg, var(--purple-600), var(--purple-800));
  color: white;
}

.role-badge.admin {
  background: var(--purple-100);
  color: var(--purple-700);
}

.role-badge.staff {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* Action Badges */
.action-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 500;
}

.action-badge.login {
  background: var(--green-100);
  color: var(--green-700);
}

.action-badge.logout {
  background: var(--gray-100);
  color: var(--gray-600);
}

.action-badge.login_failed,
.action-badge.login_blocked {
  background: #fef2f2;
  color: var(--danger);
}

.action-badge.module_access {
  background: var(--purple-100);
  color: var(--purple-700);
}

.action-badge.user_created,
.action-badge.module_created {
  background: #dbeafe;
  color: #1d4ed8;
}

.action-badge.user_updated,
.action-badge.module_updated,
.action-badge.password_reset {
  background: #fef3c7;
  color: #92400e;
}

.action-badge.module_deleted,
.action-badge.user_deleted {
  background: #fef2f2;
  color: var(--danger);
}

.action-badge.modules_reordered {
  background: var(--purple-100);
  color: var(--purple-700);
}

/* Logs Table */
.logs-table .timestamp {
  font-size: 0.875rem;
  color: var(--gray-500);
  white-space: nowrap;
}

.logs-table .details {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logs-table .ip {
  font-family: monospace;
  font-size: 0.875rem;
  color: var(--gray-500);
}

/* Module List (Admin) */
.modules-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.module-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius);
  gap: 1rem;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.module-item.inactive {
  opacity: 0.6;
}

.module-item.dragging {
  opacity: 0.5;
  background: var(--purple-100);
  box-shadow: var(--shadow-md);
}

.drag-handle {
  cursor: grab;
  color: var(--gray-400);
  font-size: 1.25rem;
  padding: 0 0.25rem;
  user-select: none;
}

.drag-handle:hover {
  color: var(--gray-600);
}

.module-item.dragging .drag-handle {
  cursor: grabbing;
}

.module-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.module-icon-small {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.module-icon-small svg {
  width: 18px;
  height: 18px;
  color: white;
}

.module-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.module-details strong {
  font-size: 0.875rem;
}

.module-url {
  font-size: 0.75rem;
  color: var(--gray-500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Module Links List (Admin) */
.module-links-list {
  margin-top: 0.5rem;
  padding-left: 1rem;
  border-left: 3px solid var(--purple-200);
  margin-left: 0.5rem;
}

.module-link-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  font-size: 0.875rem;
  background: white;
  border-radius: var(--radius);
  margin-bottom: 0.25rem;
  min-width: 0;
}

.module-link-item:last-child {
  margin-bottom: 0;
}

.link-icon-small {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--purple-600);
  flex-shrink: 0;
}

.link-icon-small svg {
  width: 16px;
  height: 16px;
}

.link-name {
  font-weight: 500;
  flex-shrink: 0;
}

.link-url {
  color: var(--gray-500);
  font-size: 0.75rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.link-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .link-url {
    display: none;
  }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 {
  font-family: var(--font-display);
  margin-bottom: 1rem;
  color: var(--dark);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Links Modal */
.links-modal {
  text-align: center;
}

.links-modal h3 {
  margin-bottom: 1.5rem;
}

.links-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.link-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 2px solid transparent;
  text-decoration: none;
  color: var(--gray-800);
  transition: all 0.2s;
}

.link-option:hover {
  background: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.link-option-icon svg {
  width: 20px;
  height: 20px;
  color: white;
}

.link-option-name {
  font-weight: 500;
  font-size: 1rem;
}

.module-card.has-links {
  cursor: pointer;
}

/* Empty State */
.empty-state,
.empty-message {
  text-align: center;
  padding: 3rem;
  color: var(--gray-500);
}

.empty-state .btn {
  margin-top: 1rem;
}

/* Error Page */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-container {
  text-align: center;
  padding: 3rem;
}

.error-icon {
  font-size: 4rem;
  color: var(--warning);
  margin-bottom: 1rem;
}

.error-container h1 {
  font-family: var(--font-display);
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.error-container p {
  color: var(--gray-600);
  margin-bottom: 1.5rem;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--gray-500);
  font-size: 0.875rem;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.contact-info {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gray-600);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.contact-item:hover {
  color: var(--purple-600);
}

.contact-item svg {
  flex-shrink: 0;
}

.social-links {
  display: flex;
  gap: 1rem;
}

.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-500);
  transition: all 0.2s;
}

.social-link:hover {
  background: var(--purple-600);
  color: white;
  transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  .nav-links {
    order: 3;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .main-content {
    padding: 1rem;
  }

  .modules-grid {
    grid-template-columns: 1fr;
  }

  .module-actions {
    flex-wrap: wrap;
  }
}
