/* ==========================================
   Admin Panel Styles - secXplore CTF
   ========================================== */

:root {
  --primary: #00ff88;
  --secondary: #00d4ff;
  --danger: #ff4444;
  --warning: #ffaa00;
  --success: #00ff88;
  --dark-bg: #0a0e27;
  --darker-bg: #060816;
  --card-bg: rgba(15, 20, 40, 0.9);
  --border: rgba(0, 255, 136, 0.2);
  --text: #e0e0e0;
  --text-muted: #8892a6;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--dark-bg);
  color: var(--text);
  overflow-x: hidden;
}

/* Cyber Grid Background */
.cyber-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
      90deg,
      rgba(0, 255, 136, 0.03) 1px,
      transparent 1px
    ),
    linear-gradient(rgba(0, 255, 136, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  z-index: 0;
  pointer-events: none;
}

/* ==========================================
   Navigation
   ========================================== */

.admin-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 1000;
  box-shadow: var(--shadow);
}

.nav-container {
  max-width: 100%;
  height: 100%;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary);
}

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

.admin-badge {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--dark-bg);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: bold;
  margin-left: 0.5rem;
}

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

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(0, 255, 136, 0.1);
  border-radius: 25px;
  border: 1px solid var(--border);
}

.user-avatar {
  font-size: 1.5rem;
}

/* ==========================================
   Sidebar
   ========================================== */

.sidebar {
  position: fixed;
  top: 70px;
  left: 0;
  width: 260px;
  height: calc(100vh - 70px);
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 999;
  backdrop-filter: blur(10px);
}

.sidebar-menu {
  padding: 1.5rem 0;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  color: var(--text);
  text-decoration: none;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.menu-item:hover {
  background: rgba(0, 255, 136, 0.1);
  border-left-color: var(--primary);
}

.menu-item.active {
  background: rgba(0, 255, 136, 0.15);
  border-left-color: var(--primary);
  color: var(--primary);
}

.menu-icon {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
}

.menu-text {
  font-weight: 500;
}

/* ==========================================
   Main Content Area
   ========================================== */

.admin-main {
  margin-left: 260px;
  margin-top: 70px;
  padding: 2rem;
  min-height: calc(100vh - 70px);
  position: relative;
  z-index: 1;
}

.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.section-header h1 {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

/* ==========================================
   Buttons
   ========================================== */

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--dark-bg);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 255, 136, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

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

.btn-danger:hover {
  background: #ff6666;
  transform: translateY(-2px);
}

.btn-success {
  background: var(--success);
  color: var(--dark-bg);
}

/* ==========================================
   Stats Cards
   ========================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-size: 2rem; /* อันนี้สำหรับ Text emoji เดิม */
  flex-shrink: 0;
}
.stat-icon svg {
  width: 32px;
  height: 32px;
  stroke: currentColor; /* ดึงสีจาก class blue, green, etc. มาใช้โดยตรง */
}
.stat-icon.blue {
  background: rgba(0, 212, 255, 0.2);
  color: var(--secondary);
}

.stat-icon.green {
  background: rgba(0, 255, 136, 0.2);
  color: var(--primary);
}

.stat-icon.purple {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

.stat-icon.orange {
  background: rgba(255, 170, 0, 0.2);
  color: var(--warning);
}

.stat-info h3 {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.stat-info p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.stat-trend {
  margin-left: auto;
  font-size: 0.85rem;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}

.stat-trend.positive {
  background: rgba(0, 255, 136, 0.2);
  color: var(--success);
}

/* ==========================================
   Dashboard Cards
   ========================================== */

.dashboard-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.dashboard-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.dashboard-card h3 {
  color: var(--primary);
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

/* ==========================================
   Activity List
   ========================================== */

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(0, 255, 136, 0.05);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
}

.activity-icon {
  font-size: 1.5rem;
}

.activity-content {
  flex: 1;
}

.activity-text {
  color: var(--text);
  margin-bottom: 0.25rem;
}

.activity-time {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ==========================================
   Filters Bar
   ========================================== */

.filters-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input,
.filter-select {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  transition: all 0.3s ease;
}

.search-input {
  flex: 1;
  min-width: 250px;
}

.search-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
}

.filter-select {
  min-width: 150px;
  cursor: pointer;
}

/* ==========================================
   Tables
   ========================================== */

.table-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

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

.admin-table thead {
  background: rgba(0, 255, 136, 0.1);
}

.admin-table th {
  padding: 1rem;
  text-align: left;
  color: var(--primary);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

.admin-table td {
  padding: 1rem;
  border-bottom: 1px solid rgba(0, 255, 136, 0.1);
}

.admin-table tbody tr {
  transition: all 0.3s ease;
}

.admin-table tbody tr:hover {
  background: rgba(0, 255, 136, 0.05);
}
.admin-table th:nth-child(4), /* Role Header */
.admin-table td:nth-child(4), /* Role Data */
.admin-table th:nth-child(5), /* Score Header */
.admin-table td:nth-child(5), /* Score Data */
.admin-table th:nth-child(7) {
  /* Status Header */
  text-align: center;
}

.admin-table td:nth-child(7) {
  /* Status Data */
  text-align: center;
}

/* Ensure the final Actions column is centered (already added, but confirming) */
.admin-table th:last-child {
  text-align: center;
}
.badge-role-admin {
  background: rgba(255, 0, 128, 0.2);
  color: #ff0080;
  border: 1px solid rgba(255, 0, 128, 0.3);
  box-shadow: 0 0 10px rgba(255, 0, 128, 0.1);
}

/* สีสำหรับ Role: Player (สีฟ้า/เขียว ดูเป็นมิตร) */
.badge-role-player {
  background: rgba(0, 255, 136, 0.15);
  color: #00ff88;
  border: 1px solid rgba(0, 255, 136, 0.3);
}
/* Badge Styles */
.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-block;
  text-transform: capitalize;
}

.badge-easy {
  background: rgba(0, 255, 0, 0.2);
  color: #00ff00;
}

.badge-medium {
  background: rgba(255, 170, 0, 0.2);
  color: var(--warning);
}

.badge-hard {
  background: rgba(255, 68, 68, 0.2);
  color: var(--danger);
}

.badge-expert {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

.badge-active {
  background: rgba(0, 255, 136, 0.2);
  color: var(--success);
}

.badge-inactive {
  background: rgba(128, 128, 128, 0.2);
  color: #888;
}

.badge-create {
  background: rgba(0, 255, 136, 0.2);
  color: var(--success);
}

.badge-update {
  background: rgba(0, 212, 255, 0.2);
  color: var(--secondary);
}

.badge-delete {
  background: rgba(255, 68, 68, 0.2);
  color: var(--danger);
}

/* Action Buttons in Tables */
.action-btn {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-right: 0.5rem;
}

.action-btn.edit {
  background: rgba(0, 212, 255, 0.2);
  color: var(--secondary);
}

.action-btn.delete {
  background: rgba(255, 68, 68, 0.2);
  color: var(--danger);
}

.action-btn:hover {
  transform: translateY(-2px);
}

/* ==========================================
   Hints Container
   ========================================== */

.hints-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  height: calc(100vh - 250px);
}

.hints-sidebar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  overflow-y: auto;
}

.hints-sidebar h3 {
  color: var(--primary);
  margin-bottom: 1rem;
}

.hints-challenge-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.hint-challenge-item {
  padding: 0.75rem;
  background: rgba(0, 255, 136, 0.05);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.hint-challenge-item:hover {
  background: rgba(0, 255, 136, 0.1);
  border-color: var(--primary);
}

.hint-challenge-item.selected {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--primary);
}

.hints-main {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  overflow-y: auto;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.hint-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.hints-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hint-item {
  background: rgba(0, 255, 136, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.hint-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.hint-item-title {
  font-weight: 600;
  color: var(--primary);
}

.hint-item-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ==========================================
   Modals
   ========================================== */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
}

.modal-content {
  position: relative;
  background: var(--darker-bg);
  border: 2px solid var(--primary);
  border-radius: 16px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 255, 136, 0.3);
  animation: modalSlideIn 0.3s ease;
}

.modal-content.large {
  max-width: 900px;
}

@keyframes modalSlideIn {
  from {
    transform: scale(0.9) translateY(-20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.modal-header h2 {
  color: var(--primary);
  font-size: 1.75rem;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 2rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.close-btn:hover {
  background: rgba(255, 68, 68, 0.2);
  color: var(--danger);
  transform: rotate(90deg);
}

/* ==========================================
   Forms
   ========================================== */

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--primary);
  font-weight: 600;
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-file {
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s ease;
}

.form-file:hover {
  border-color: var(--primary);
  background: rgba(0, 255, 136, 0.05);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ==========================================
   Settings
   ========================================== */

.settings-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}

.settings-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.settings-card h3 {
  color: var(--primary);
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid rgba(0, 255, 136, 0.1);
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-item label {
  color: var(--text);
  font-weight: 500;
}

.setting-value {
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: 0.4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

input:checked + .slider:before {
  transform: translateX(26px);
}

/* ==========================================
   Stats Tabs
   ========================================== */

.stats-tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  padding: 1rem 2rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.stats-tab-content {
  display: none;
}

.stats-tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ==========================================
   File Grid
   ========================================== */

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.file-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.file-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.file-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.file-name {
  color: var(--text);
  font-weight: 600;
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.file-size {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ==========================================
   Upload Area
   ========================================== */

.upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 3rem;
  text-align: center;
  transition: all 0.3s ease;
}

.upload-area:hover {
  border-color: var(--primary);
  background: rgba(0, 255, 136, 0.05);
}

.upload-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.upload-progress {
  margin-top: 1.5rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.3s ease;
}

/* ==========================================
   Responsive Design
   ========================================== */

@media (max-width: 1024px) {
  .admin-main {
    margin-left: 0;
    padding: 1.5rem;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .dashboard-row {
    grid-template-columns: 1fr;
  }

  .hints-container {
    grid-template-columns: 1fr;
    height: auto;
  }

  .settings-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .nav-container {
    padding: 0 1rem;
  }

  .section-header {
    flex-direction: column;
    gap: 1rem;
  }

  .filters-bar {
    flex-direction: column;
  }

  .search-input,
  .filter-select {
    width: 100%;
  }

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

  .modal-content {
    width: 95%;
    padding: 1.5rem;
  }

  .admin-table {
    font-size: 0.85rem;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.75rem 0.5rem;
  }
}

/* ==========================================
   Scrollbar Styling
   ========================================== */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--darker-bg);
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 136, 0.3);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 255, 136, 0.5);
}

/* ==========================================
   Image Preview
   ========================================== */

.image-preview {
  margin-top: 1rem;
  max-width: 300px;
}

.image-preview img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.uploaded-files-list {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.uploaded-file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: rgba(0, 255, 136, 0.05);
  border-radius: 6px;
}

/* ==========================================
   Loading State
   ========================================== */

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(0, 255, 136, 0.3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================
   Toast Notifications
   ========================================== */

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 3000;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}

/* ==========================================
   Activity Statistics Table
   ========================================== */

.stats-table-container {
  overflow-x: auto;
  margin-top: 1rem;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(10, 14, 39, 0.5);
  border-radius: 8px;
  overflow: hidden;
}

.stats-table thead {
  background: rgba(0, 255, 136, 0.1);
  border-bottom: 2px solid var(--border);
}

.stats-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--primary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stats-table tbody tr {
  border-bottom: 1px solid rgba(0, 255, 136, 0.1);
  transition: background 0.2s ease;
}

.stats-table tbody tr:hover {
  background: rgba(0, 255, 136, 0.05);
}

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

.stats-table td {
  padding: 1rem;
  color: var(--text);
}

.stats-table td:first-child {
  font-weight: 500;
}

.stat-number {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  text-align: center;
}

.trend-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.trend-badge.positive {
  background: rgba(0, 255, 136, 0.2);
  color: var(--success);
  border: 1px solid var(--success);
}

.trend-badge.negative {
  background: rgba(255, 68, 68, 0.2);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.trend-badge.neutral {
  background: rgba(136, 146, 166, 0.2);
  color: var(--text-muted);
  border: 1px solid var(--text-muted);
}

/* ==========================================
   Mobile Responsive Styles
   ========================================== */

/* Tablet and below */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
    padding: 1.5rem;
  }

  .nav-container {
    padding: 0 1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-row {
    grid-template-columns: 1fr;
  }

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

  .admin-table {
    min-width: 800px;
  }
}

/* Mobile devices */
@media (max-width: 768px) {
  .nav-container {
    padding: 0 1rem;
  }

  .logo {
    font-size: 1.2rem;
  }

  .logo-text {
    display: none;
  }

  .user-info span:not(.user-avatar) {
    display: none;
  }

  .btn-secondary {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .filters-bar {
    flex-direction: column;
    gap: 0.75rem;
  }

  .filters-bar input,
  .filters-bar select {
    width: 100%;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .modal-content {
    width: 95%;
    max-width: none;
    margin: 1rem;
  }

  .form-row {
    flex-direction: column;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions button {
    width: 100%;
  }

  /* Stats Table Responsive */
  .stats-table {
    font-size: 0.85rem;
  }

  .stats-table th,
  .stats-table td {
    padding: 0.75rem 0.5rem;
  }

  .stat-number {
    font-size: 1rem;
  }

  .trend-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  .admin-nav {
    height: 60px;
  }

  .admin-main {
    margin-top: 60px;
    padding: 1rem;
  }

  .section-header h1 {
    font-size: 1.5rem;
  }

  .stat-card h3 {
    font-size: 1.5rem;
  }

  .dashboard-card {
    padding: 1rem;
  }

  .dashboard-card h3 {
    font-size: 1.1rem;
  }
}

/* Landscape orientation for tablets */
@media (max-width: 1024px) and (orientation: landscape) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Print styles */
@media print {
  .sidebar,
  .admin-nav,
  .btn-primary,
  .btn-secondary,
  .btn-danger {
    display: none;
  }

  .admin-main {
    margin: 0;
    padding: 0;
  }
}

@media (max-width: 768px) {
  /* 1. Main Layout Collapse */
  /* Remove the grid container effect on the main body */
  .cyber-grid {
    display: none;
  }

  /* Adjust the main content to take up full width, stacked vertically */
  .admin-main {
    margin-left: 0; /* Clear space for the sidebar */
    padding: 1rem;
    width: 100%;
  }

  /* 2. Sidebar Hiding and Overlay */
  .sidebar {
    /* Start off-screen */
    transform: translateX(-100%);
    width: 250px;
    z-index: 1000;
    position: fixed; /* Fix the sidebar position */
    height: 100%;
    top: 0;
    left: 0;
    transition: transform 0.3s ease-in-out;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
  }

  /* A simple class you can toggle with JS to show the sidebar */
  .sidebar.open {
    transform: translateX(0);
  }

  /* 3. Navigation simplification */
  .admin-nav .nav-container {
    padding: 0.5rem 1rem;
  }
  .admin-badge {
    display: none; /* Hide admin badge to save space */
  }
  .nav-actions {
    /* Ensure user info and buttons stack or wrap if necessary */
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
  }
  .user-info {
    font-size: 0.8rem;
  }
}

/* ==========================================
   MOBILE COLLAPSE (768px and Down)
   ========================================== */

/* --- เพิ่มหรือแก้ไขใน admin.css --- */

/* 1. ปรับแต่งปุ่ม Hamburger ให้เป็นแบบโปร่งใสและสวยงาม */
#hamburgerBtn {
  background: transparent !important; /* พื้นหลังใส */
  border: 1px solid rgba(0, 255, 136, 0.2) !important; /* กรอบจางๆ (ถ้าชอบ) หรือใส่ border: none; เพื่อเอาออก */
  border-radius: 8px;
  cursor: pointer;
  padding: 8px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary) !important; /* สีเขียวตามธีม */
  transition: all 0.3s ease;
  outline: none;
}

/* Effect ตอนเอาเมาส์ชี้หรือกด */
#hamburgerBtn:hover,
#hamburgerBtn:active {
  background: rgba(0, 255, 136, 0.1) !important;
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.2) !important;
  transform: scale(1.05);
}

/* จัดการ SVG ภายในปุ่ม */
#hamburgerBtn svg {
  stroke: currentColor;
  width: 28px;
  height: 28px;
}

/* 2. บังคับตำแหน่งใน Mobile ให้ชิดขวา */
@media (max-width: 900px) {
  /* ซ่อน User Info และปุ่ม User View ในมือถือ */
  .user-info, 
  .nav-actions .btn-secondary {
    display: none !important; 
  }

  /* แสดงปุ่ม Menu */
  .hamburger-menu {
    display: block !important;
  }
  
  /* จัด Layout ให้ Logo อยู่ซ้าย และ Menu อยู่ขวา */
  .nav-container {
    display: flex;
    justify-content: space-between; /* ซ้าย-ขวา */
    align-items: center;
    width: 100%;
  }

  /* ตัวกล่องปุ่ม Menu */
  .nav-actions {
    display: flex;
    justify-content: flex-end; /* ดันไปขวาสุด */
    gap: 0;
    margin-left: auto; /* เทคนิคดันตัวเองไปขวาสุด */
  }
}

/* ==========================================
   MOBILE COLLAPSE (900px and Down)
   ========================================== */

@media (max-width: 900px) {
  /* --- A. NAVIGATION & ACTIONS --- */

  /* Show the hamburger button on mobile (for narrow screens) */
  .hamburger-menu {
    display: block !important;
  }

  /* On narrow screens, hide the desktop actions (Admin Name and User View) */
  .user-info,
  .admin-nav .nav-actions .btn-secondary {
    display: none !important;
  }

  /* --- B. SIDEBAR & MAIN LAYOUT COLLAPSE --- */

  /* 1. Reset the main content flow */
  .admin-main {
    margin-left: 0;
    width: 100%;
    padding: 1rem;
    padding-top: 60px;
  }

  /* 2. Hide the sidebar by default and prepare for toggle */
  .sidebar {
    transform: translateX(-100%);
    width: 250px;
    z-index: 1000;
    position: fixed;
    height: 100%;
    top: 0;
    left: 0;
    padding-top: 60px;
    transition: transform 0.3s ease-in-out;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
  }

  /* Toggled class to open the sidebar */
  .sidebar.open {
    transform: translateX(0);
  }

  /* 3. Show sidebar actions (Logout) when the sidebar is open */
  .sidebar-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    padding: 1rem;
    gap: 0.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--sidebar-bg-color);
  }

  /* --- C. TABLE AND GRID RESPONSIVENESS --- */
  /* (Use 2 columns for smaller mobile screens) */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .table-container {
    overflow-x: auto;
  }
  .admin-table {
    min-width: 800px;
  }
}

/* ==========================================
   DESKTOP/IPAD PRO BASE (901px and Up)
   ========================================== */

@media (min-width: 901px) {
  /* DESKTOP/IPAD VIEW: Hide hamburger menu */
  .hamburger-menu {
    display: none !important;
  }

  /* Hide mobile sidebar actions */
  .sidebar-actions {
    display: none !important;
  }

  /* Ensure sidebar is visible and main content is shifted */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    padding-top: 60px;
    transform: translateX(0) !important; /* Ensure it's always visible */
  }
  .admin-main {
    margin-left: 250px;
  }
}
