/* ============================================
   3D CAPTCHA - Unified Design System
   Modern, professional UI with consistent styling
   ============================================ */

/* === CSS Variables for Easy Theming === */
:root {
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --primary-color: #667eea;
  --primary-dark: #764ba2;
  --accent-color: #4ECDC4;
  --accent-dark: #45b8b0;

  --success: #28a745;
  --success-bg: #d4edda;
  --success-border: #c3e6cb;
  --success-text: #155724;

  --warning: #ffc107;
  --warning-bg: #fff3cd;
  --warning-text: #856404;

  --danger: #dc3545;
  --danger-bg: #f8d7da;
  --danger-border: #f5c6cb;
  --danger-text: #721c24;

  --info-bg: #d1ecf1;
  --info-border: #bee5eb;
  --info-text: #0c5460;

  --bg-light: #f5f5f5;
  --bg-white: #ffffff;
  --bg-gray: #f8f9fa;

  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-light: #999;

  --border-color: #dee2e6;
  --border-light: #e9ecef;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.3);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --transition: all 0.3s ease;

  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}

/* === Global Reset === */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px;
  font-family: var(--font-family);
  background: var(--bg-light);
  min-height: 100vh;
  color: var(--text-primary);
}

/* === Container Layouts === */
.captcha-container,
.admin-container,
.mouse-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

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

.mouse-container {
  max-width: 1600px;
  box-shadow: var(--shadow-xl);
}

/* === Page Headers === */
.page-header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 3px solid var(--primary-color);
}

.page-header h1,
.page-header h2 {
  color: var(--primary-color);
  margin: 0 0 12px 0;
  font-size: 32px;
  font-weight: 700;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0;
}

.captcha-title {
  text-align: center;
  color: var(--primary-color);
  margin: 0 0 10px 0;
  font-size: 28px;
  font-weight: 700;
}

.admin-title {
  text-align: center;
  color: var(--primary-color);
  margin: 0 0 20px 0;
  font-size: 28px;
  font-weight: 700;
}

/* === Back Links === */
.back-link {
  display: inline-block;
  margin-bottom: 20px;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
}

.back-link:hover {
  color: var(--primary-dark);
  transform: translateX(-4px);
}

/* === Instructions & Text === */
.captcha-instructions {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-secondary);
}

.captcha-instructions p {
  margin: 5px 0;
  font-size: 14px;
}

/* === Loading States === */
.loading {
  text-align: center;
  padding: 80px 20px;
  font-size: 18px;
  color: var(--primary-color);
  font-weight: 500;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-light);
}

.empty-state p {
  margin: 8px 0;
}

/* === Banned/Blocked Message === */
.banned-container {
  text-align: center;
  padding: 60px 20px;
  background: var(--danger-bg);
  border: 2px solid var(--danger-border);
  border-radius: var(--radius-md);
  margin: 20px 0;
}

.banned-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.banned-container h3 {
  color: var(--danger-text);
  margin: 0 0 15px 0;
  font-size: 24px;
}

.banned-container p {
  color: var(--danger-text);
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
}

/* === CAPTCHA Image === */
.captcha-wrapper {
  display: block;
}

.captcha-image-container {
  position: relative;
  width: 400px;
  height: 400px;
  margin: 0 auto 20px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #1a1a2e;
}

.captcha-image {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
}

/* === Camera Controls === */
.captcha-controls {
  margin-top: 20px;
  padding: 24px;
  background: var(--bg-gray);
  border-radius: var(--radius-md);
}

.camera-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.camera-row {
  display: flex;
  gap: 8px;
  margin: 4px 0;
}

.btn-arrow {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  font-weight: bold;
  color: var(--primary-color);
}

.btn-arrow:hover:not(:disabled) {
  background: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-arrow:active:not(:disabled) {
  transform: scale(0.95);
}

.btn-arrow:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === Input Fields === */
.input-group {
  margin-bottom: 20px;
  text-align: center;
}

.captcha-input {
  width: 80px;
  padding: 16px 20px;
  font-size: 32px;
  text-align: center;
  text-transform: uppercase;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  outline: none;
  transition: var(--transition);
  font-weight: 700;
  letter-spacing: 2px;
}

.captcha-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.captcha-input::placeholder {
  font-size: 20px;
  letter-spacing: normal;
  text-transform: none;
  opacity: 0.5;
}

/* === Buttons === */
.button-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.actions {
  margin-bottom: 24px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

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

.btn:disabled.verifying {
  opacity: 1;
  cursor: wait;
}

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

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
  box-shadow: var(--shadow-sm);
}

.btn-primary.verifying,
.btn-primary:disabled.verifying {
  background: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%) !important;
  animation: pulse 0.8s infinite;
  transform: translateY(0) !important;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.6);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 8px 30px rgba(255, 107, 53, 0.8);
    transform: scale(1.02);
  }
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #5a6268;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.btn-danger:hover:not(:disabled) {
  background: #c82333;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(220, 53, 69, 0.4);
}

.btn-small {
  padding: 8px 20px;
  font-size: 13px;
}

.btn-dashboard {
  display: inline-block;
  padding: 16px 36px;
  background: var(--primary-gradient);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
  transition: var(--transition);
  border: none;
  cursor: pointer;
}

.btn-dashboard:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

/* === Messages & Alerts === */
.message {
  padding: 14px 20px;
  margin-bottom: 20px;
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 14px;
  font-weight: 500;
}

.message.success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.message.error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.message.info {
  background: var(--info-bg);
  color: var(--info-text);
  border: 1px solid var(--info-border);
}

/* === Tabs === */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-light);
  overflow-x: auto;
}

.tab {
  padding: 14px 28px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.tab:hover {
  color: var(--primary-color);
  background: rgba(102, 126, 234, 0.05);
}

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

.tab-content {
  display: none;
}

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

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

/* === Badges === */
.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-ip {
  background: var(--info-bg);
  color: var(--info-text);
}

.badge-fingerprint {
  background: #f3e5f5;
  color: #7b1fa2;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-failure {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge.low {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge.medium {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge.high {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge.critical {
  background: var(--danger-text);
  color: white;
}

/* === Lists === */
.list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-item {
  padding: 20px;
  margin-bottom: 12px;
  background: var(--bg-gray);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--danger);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.list-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.list-item-info {
  flex: 1;
}

.list-item-identifier {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
  font-family: 'Courier New', monospace;
  color: var(--text-primary);
}

.list-item-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.list-item-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* === Tables === */
.log-table,
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.log-table th,
table th {
  background: var(--primary-gradient);
  color: white;
  padding: 16px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.log-table td,
table td {
  padding: 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.log-table tr:hover,
table tr:hover {
  background: var(--bg-gray);
}

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

.fingerprint-short {
  font-family: 'Courier New', monospace;
  color: var(--text-secondary);
  font-size: 12px;
}

/* === Stats Cards === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--primary-gradient);
  color: white;
  padding: 28px;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(102, 126, 234, 0.4);
}

.stat-card h3 {
  font-size: 12px;
  opacity: 0.9;
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
}

.stat-card .value {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 8px;
  line-height: 1;
}

.stat-card .label {
  font-size: 13px;
  opacity: 0.85;
}

/* === Mouse Dashboard Link Card === */
.mouse-dashboard-link {
  text-align: center;
  padding: 60px 20px;
  background: linear-gradient(135deg, var(--bg-gray) 0%, var(--border-light) 100%);
  border-radius: var(--radius-lg);
  margin-bottom: 30px;
  box-shadow: var(--shadow-sm);
}

.mouse-dashboard-link h3 {
  color: var(--primary-color);
  margin-bottom: 16px;
  font-size: 24px;
  font-weight: 700;
}

.mouse-dashboard-link p {
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

/* === Filters === */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-bar select {
  padding: 12px 18px;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--bg-white);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.filter-bar select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-bar select:hover {
  border-color: var(--primary-color);
}

/* === Score Display === */
.score {
  font-size: 16px;
  font-weight: 700;
}

.score.good {
  color: var(--success);
}

.score.warning {
  color: var(--warning);
}

.score.danger {
  color: var(--danger);
}

/* === Session Details === */
.session-detail {
  background: var(--bg-gray);
  padding: 32px;
  border-radius: var(--radius-lg);
  margin-top: 24px;
  border-left: 5px solid var(--primary-color);
  box-shadow: var(--shadow-lg);
}

.session-detail h3 {
  color: var(--text-primary);
  margin-bottom: 24px;
  font-size: 22px;
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.detail-section {
  background: var(--bg-white);
  padding: 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.detail-section h4 {
  color: var(--primary-color);
  margin: 0 0 16px 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.metric-row:last-child {
  border-bottom: none;
}

.metric-label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
}

.metric-value {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

/* === Score Breakdown === */
.score-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.score-item {
  background: var(--bg-white);
  padding: 20px;
  border-radius: var(--radius-md);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.score-item-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.score-item-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary-color);
}

/* === Flags === */
.flags-list {
  background: var(--bg-white);
  padding: 20px;
  border-radius: var(--radius-md);
  margin-top: 16px;
  list-style: none;
}

.flags-list li {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--danger);
  color: var(--danger-text);
  font-size: 13px;
  background: var(--danger-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.flags-list li.positive {
  border-left-color: var(--success);
  color: var(--success-text);
  background: var(--success-bg);
}

/* === Trajectory Canvas === */
.trajectory-container {
  background: var(--bg-white);
  padding: 24px;
  border-radius: var(--radius-md);
  margin-top: 24px;
  box-shadow: var(--shadow-sm);
}

.trajectory-container h4 {
  color: var(--primary-color);
  margin: 0 0 16px 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#trajectoryCanvas {
  width: 100%;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-gray);
}

.canvas-legend {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
  justify-content: center;
}

.canvas-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.canvas-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* === Timeline Indicators === */
.timeline-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.timeline-dot.recent {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

.timeline-dot.old {
  background: var(--text-secondary);
}

/* === Responsive Design === */
@media (max-width: 768px) {
  body {
    padding: 12px;
  }

  .captcha-container,
  .admin-container,
  .mouse-container {
    padding: 24px;
  }

  .captcha-image-container {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .page-header h1,
  .page-header h2,
  .captcha-title,
  .admin-title {
    font-size: 24px;
  }

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

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

  .score-breakdown {
    grid-template-columns: 1fr;
  }

  .button-group,
  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .tab {
    flex-shrink: 0;
  }
}

@media (max-width: 480px) {
  .stat-card .value {
    font-size: 36px;
  }

  .captcha-input {
    width: 70px;
    font-size: 24px;
    padding: 12px 16px;
  }

  .btn-arrow {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
}

/* === Utility Classes === */
.text-center {
  text-align: center;
}

.mb-20 {
  margin-bottom: 20px;
}

.mt-20 {
  margin-top: 20px;
}

.hidden {
  display: none;
}
