/* CSS variables for consistent premium design */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #121826;
  --card-bg: rgba(22, 30, 49, 0.65);
  --card-border: rgba(255, 255, 255, 0.08);
  --accent-blue: #38bdf8;
  --accent-blue-glow: rgba(56, 189, 248, 0.2);
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.25);
  --accent-purple: #a855f7;
  --accent-orange: #f97316;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --danger: #ef4444;
  --font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --border-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Layout elements */
header {
  padding: 20px 16px;
  text-align: center;
  border-bottom: 1px solid var(--card-border);
  background: rgba(10, 14, 23, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, var(--accent-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-user {
  font-size: 0.85rem;
  color: var(--accent-blue);
  background: var(--accent-blue-glow);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  margin-left: 8px;
  text-decoration: underline;
}

main {
  flex: 1;
  padding: 16px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

/* Glass card styling */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-glow);
  transition: var(--transition);
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  font-family: var(--font-family);
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue) 0%, #0284c7 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.2);
}

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

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

.btn-outline {
  background: transparent;
  color: var(--accent-blue);
  border: 1.5px solid var(--accent-blue);
}

.btn-outline:active {
  background: var(--accent-blue-glow);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent-green) 0%, #047857 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

/* Inputs & Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-control {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  background: rgba(10, 14, 23, 0.8);
  border: 1.5px solid var(--card-border);
  border-radius: 12px;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  font-family: var(--font-family);
}

.input-control:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

/* VIEW: Login page specific */
.login-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 120px);
}

.login-title {
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #fff 30%, var(--accent-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 30px;
}

/* VIEW: Dashboard (Lobby) */
.progress-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
}

.progress-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.progress-bar-bg {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  margin-left: 12px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
  width: 0%;
  transition: width 0.5s ease-out;
}

.team-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.team-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.team-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--text-muted);
}

.team-card.graded::after {
  background: var(--accent-green);
}

.team-card:active {
  transform: translateY(-2px);
  background: rgba(30, 41, 67, 0.8);
}

.team-card.graded {
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.03);
}

.team-info {
  flex: 1;
  padding-left: 8px;
  padding-right: 12px;
  overflow: hidden;
}

.team-card-num {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-blue);
  margin-bottom: 2px;
  display: inline-block;
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.team-card-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-card-project {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-status {
  text-align: right;
  min-width: 75px;
}

.status-badge {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 20px;
  display: inline-block;
}

.status-badge.pending {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

.status-badge.done {
  background: var(--accent-green-glow);
  color: var(--accent-green);
  font-weight: bold;
}

.score-display-small {
  margin-top: 4px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-green);
}

/* VIEW: Scoring Panel */
.scoring-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
}

.back-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
}

.scoring-team-details {
  flex: 1;
}

.scoring-team-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.scoring-team-num {
  font-size: 0.85rem;
  background: var(--accent-blue-glow);
  color: var(--accent-blue);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}

.scoring-team-name {
  font-size: 1.2rem;
  font-weight: 800;
}

.scoring-project-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Dimension Sliders & Steppers */
.dimension-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.dimension-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.dimension-title-area {
  flex: 1;
  padding-right: 12px;
}

.dimension-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dimension-max-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: normal;
}

.dimension-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

/* Numeric Value Control */
.score-control-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(10, 14, 23, 0.6);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 2px;
}

.score-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.score-btn:active {
  background: var(--accent-blue-glow);
  color: var(--accent-blue);
}

.score-val-input {
  width: 40px;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--accent-blue);
  font-size: 1.1rem;
  font-weight: 800;
  outline: none;
  -moz-appearance: textfield;
}

.score-val-input::-webkit-outer-spin-button,
.score-val-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Custom HTML5 Range Slider styling */
.slider-container {
  display: flex;
  align-items: center;
  margin-top: 12px;
}

.score-range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  margin: 10px 0;
}

.score-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--accent-blue);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
  transition: var(--transition);
}

.score-range-slider::-webkit-slider-thumb:active {
  transform: scale(1.2);
}

.score-range-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--accent-blue);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

/* Real-time Total Panel */
.total-panel {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1) 0%, rgba(16, 185, 129, 0.1) 100%);
  border: 1.5px solid rgba(56, 189, 248, 0.2);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.total-title {
  font-size: 1.1rem;
  font-weight: 800;
}

.total-value-box {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.total-value {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent-green);
  text-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.total-max {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Nav Actions on Scoring Screen */
.score-nav-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.score-submit-action {
  margin-top: 24px;
}

/* Toast Messages */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid var(--card-border);
  padding: 12px 24px;
  border-radius: 50px;
  box-shadow: var(--shadow-glow);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-green);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

/* ==================== ADMIN LAYOUT ==================== */
.admin-header {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.admin-main {
  max-width: 1200px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

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

.admin-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-title {
  font-size: 1.6rem;
  font-weight: 800;
}

.admin-actions {
  display: flex;
  gap: 12px;
}

/* Admin Table styles */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  background: rgba(10, 14, 23, 0.4);
  border-radius: 12px;
  border: 1px solid var(--card-border);
  margin-top: 12px;
}

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

.admin-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 14px 16px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1.5px solid var(--card-border);
  white-space: nowrap;
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--card-border);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.team-cell {
  display: flex;
  flex-direction: column;
}

.team-cell-num {
  font-size: 0.75rem;
  color: var(--accent-blue);
  font-weight: bold;
}

.team-cell-name {
  font-weight: bold;
  color: var(--text-primary);
}

.team-cell-project {
  font-size: 0.8rem;
  color: var(--text-secondary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-cell-total {
  font-weight: bold;
  font-size: 1rem;
  color: var(--text-primary);
  text-align: center;
  cursor: help;
  position: relative;
}

.score-cell-total:hover .score-tooltip {
  visibility: visible;
  opacity: 1;
}

/* Tooltip for dimension scores */
.score-tooltip {
  visibility: hidden;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  text-align: left;
  white-space: nowrap;
  box-shadow: var(--shadow-glow);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.score-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--card-border) transparent transparent transparent;
}

.score-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.score-tooltip-row:last-child {
  margin-bottom: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 2px;
  font-weight: bold;
  color: var(--accent-green);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-weight: bold;
  font-size: 0.8rem;
}

.rank-1 { background: #fbbf24; color: #000; }
.rank-2 { background: #cbd5e1; color: #000; }
.rank-3 { background: #d97706; color: #fff; }
.rank-other { background: rgba(255, 255, 255, 0.1); color: var(--text-secondary); }

/* Inactive/Hidden styling */
tr.inactive-team td {
  opacity: 0.4;
}

/* Reorder and Toggle Controls */
.order-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  margin-right: 4px;
}

.order-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.order-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

/* Switch Toggle Styling */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

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

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 20px;
  border: 1px solid var(--card-border);
}

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

input:checked + .switch-slider {
  background-color: var(--accent-green);
}

input:checked + .switch-slider:before {
  transform: translateX(20px);
}

/* Side Card for Stats */
.stat-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-blue);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.judge-progress-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.judge-progress-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.01);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.judge-prog-name {
  font-weight: bold;
}

.judge-prog-bar-bg {
  width: 80px;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
  margin-left: auto;
  margin-right: 12px;
}

.judge-prog-bar-fill {
  height: 100%;
  background: var(--accent-blue);
}

.judge-prog-ratio {
  color: var(--text-secondary);
  font-weight: bold;
}

/* Modal dialogue for admin login */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  padding: 28px;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-glow);
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Utility classes */
.d-none {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-green {
  color: var(--accent-green) !important;
}

.text-blue {
  color: var(--accent-blue) !important;
}

.text-orange {
  color: var(--accent-orange) !important;
}

.pulse-badge {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
  animation: pulse 2s infinite;
  vertical-align: middle;
  margin-right: 4px;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}
