/**
 * CTF Dashboard Styles
 */

:root {
  --primary-color: #3b82f6;
  --secondary-color: #8b5cf6;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --bg-color: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-color: #f1f5f9;
  --text-secondary: #94a3b8;
  --border-color: #475569;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --radius: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

/* Navigation */
nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
}

nav .container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

nav ul {
  list-style: none;
  display: flex;
  gap: 2rem;
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

nav a:hover, nav a.active {
  color: var(--primary-color);
}

/* Hamburger Menu (Hidden on Desktop) */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.menu-toggle span {
  display: block;
  width: 24px;
  height: 3px;
  background: var(--text-color);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Main Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

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

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

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
}

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

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

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

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

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

/* Form Elements */
input, select, textarea {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  color: var(--text-color);
  font-size: 1rem;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
}

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

/* Filters */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Expandable Filter Content */
.filter-content {
  max-height: 400px;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out;
  border-bottom: 1px solid var(--border-color);
}

.filter-content.collapsed {
  max-height: 0;
  padding: 0;
  border-bottom: none;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--bg-tertiary);
}

th, td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-transform: uppercase;
}

tbody tr:hover {
  background: var(--bg-tertiary);
}

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

.badge-primary { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.badge-success { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.badge-error { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.badge-secondary { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.badge-info { background: rgba(14, 165, 233, 0.2); color: #0ea5e9; }

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

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* Loading Spinner */
.spinner {
  border: 3px solid var(--bg-tertiary);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Alert */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error-color);
  color: var(--error-color);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--success-color);
  color: var(--success-color);
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
}

/* Search */
.search-box {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-box input {
  padding-left: 2.5rem;
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

/* Pagination */
.pagination {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 2rem;
}

.pagination button {
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-color);
  cursor: pointer;
}

.pagination button:hover:not(:disabled) {
  background: var(--border-color);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination button.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
}


/* Table Action Buttons */
td .btn-small {
  margin-right: 0.5rem;
}

td .btn-small:last-child {
  margin-right: 0;
}

/* Competition Button Grid */
.competition-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ============================================================================ */
/* MOBILE RESPONSIVE STYLES */
/* ============================================================================ */

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

  nav .container {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  nav h1 {
    font-size: 1.25rem;
    flex: 1;
    order: 1;
  }

  /* Show hamburger menu */
  .menu-toggle {
    display: flex;
    order: 2;
    z-index: 1001;
  }

  /* Hide menu by default on mobile */
  nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-direction: column;
    gap: 0;
    width: 100%;
    padding: 0;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    order: 3;
  }

  /* Show menu when active */
  nav ul.active {
    display: flex;
  }

  nav li {
    width: 100%;
    border-bottom: 1px solid var(--border-color);
  }

  nav li:last-child {
    border-bottom: none;
  }

  nav a {
    display: block;
    padding: 1rem;
    background: transparent;
    border-radius: 0;
    transition: background 0.2s;
  }

  nav a:hover,
  nav a.active {
    background: var(--bg-tertiary);
  }

  /* Fix nav positioning */
  nav {
    position: relative;
  }

  /* Container */
  .container {
    padding: 1rem;
  }

  /* Card Header */
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .card-header > div {
    width: 100%;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }

  .card-header .btn {
    width: 100%;
    text-align: center;
  }

  /* Card Padding */
  .card {
    padding: 1rem;
  }

  /* Stats Grid */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Filters */
  .filters {
    grid-template-columns: 1fr;
  }

  /* Tables - Make Responsive */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
  }

  table {
    min-width: 600px;
    font-size: 0.875rem;
  }

  th, td {
    padding: 0.5rem;
  }

  /* Hide less important columns on mobile */
  @media (max-width: 640px) {
    th:nth-child(4),
    td:nth-child(4) {
      display: none; /* Hide Points column */
    }
  }

  /* Buttons in Tables */
  td .btn-small {
    display: block;
    width: 100%;
    margin-bottom: 0.25rem;
    margin-right: 0;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }

  td .btn-small:last-child {
    margin-bottom: 0;
  }

  /* Forms */
  input, select, textarea {
    font-size: 16px; /* Prevent iOS zoom */
  }

  /* Pagination */
  .pagination {
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .pagination button {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
  }

  /* Competition Cards - 3 column button grid */
  .competition-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
  }

  /* Make buttons stack on very small screens */
  @media (max-width: 480px) {
    .competition-buttons {
      grid-template-columns: 1fr;
    }

    .competition-buttons .btn {
      width: 100%;
      font-size: 0.875rem;
      padding: 0.75rem 0.5rem;
    }
  }

  /* Modal - Full Screen on Mobile */
  .modal-content {
    width: 95% !important;
    max-width: 95% !important;
    margin: 1rem auto !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Search Box */
  .search-box input {
    font-size: 16px;
  }

  /* Badges - Smaller on Mobile */
  .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }

  /* Stat Cards */
  .stat-card {
    padding: 0.75rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  /* Alert */
  .alert {
    padding: 0.75rem;
    font-size: 0.875rem;
  }

  /* Toast Notifications */
  .alert {
    min-width: 250px !important;
    max-width: calc(100vw - 2rem) !important;
    right: 1rem !important;
    left: 1rem !important;
    top: 1rem !important;
  }
}

/* Tablet Styles */
@media (min-width: 769px) and (max-width: 1024px) {
  nav ul {
    gap: 1.5rem;
  }

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

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

  .competition-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
  }
}

/* Custom Scrollbar Styling */
/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
  border: 2px solid var(--bg-secondary);
  transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

::-webkit-scrollbar-corner {
  background: var(--bg-secondary);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--bg-secondary);
}

/* Ultra-wide screens */
@media (min-width: 1600px) {
  .container {
    max-width: 1600px;
  }

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