/* Import Google Fonts */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

/* CSS Variables */
:root {
  --primary-color: #6366f1;
  --primary-dark: #4f46e5;
  --secondary-color: #8b5cf6;
  --success-color: #10b981;
  --background: #0f172a;
  --surface: #1e293b;
  --surface-light: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --border-color: #475569;
  --shadow: rgba(0, 0, 0, 0.3);
  --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  background-image:
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
}

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

/* Header */
header {
  text-align: center;
  margin-bottom: 3rem;
  animation: fadeInDown 0.6s ease-out;
}

header h1 {
  font-size: 3rem;
  font-weight: 700;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Upload Section */
.upload-section {
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

.upload-box {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(10px);
  border: 2px dashed var(--border-color);
  border-radius: 1.5rem;
  padding: 4rem 2rem;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.upload-box:hover {
  border-color: var(--primary-color);
  background: rgba(30, 41, 59, 0.8);
  transform: translateY(-4px);
  box-shadow: 0 20px 40px var(--shadow);
}

.upload-box.drag-over {
  border-color: var(--success-color);
  background: rgba(16, 185, 129, 0.1);
}

.upload-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 2s infinite;
}

.upload-box h2 {
  margin-bottom: 0.5rem;
  font-size: 1.8rem;
}

.upload-box p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-correct {
  padding: 0.875rem 2rem;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

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

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: var(--surface-light);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border-color);
  transform: translateY(-2px);
}

.btn-correct {
  background: var(--gradient-2);
  color: white;
  font-size: 1.2rem;
  padding: 1.25rem 3rem;
  box-shadow: 0 10px 30px rgba(245, 87, 108, 0.3);
}

.btn-correct:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 40px rgba(245, 87, 108, 0.5);
}

.btn-reset {
  background: rgba(71, 85, 105, 0.2);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.1rem;
  margin: 0 auto;
}

.btn-reset:hover {
  background: var(--surface-light);
  color: var(--primary-color);
  border-color: var(--primary-color);
  transform: rotate(-180deg);
}

/* Main Content */
#mainContent {
  animation: fadeInUp 0.6s ease-out;
}

.hidden {
  display: none !important;
}

/* File Info */
.file-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.info-card {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(10px);
  padding: 1.5rem 2rem;
  border-radius: 1rem;
  border: 1px solid var(--border-color);
  flex: 1;
  min-width: 300px;
}

.info-card h3 {
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.info-card p {
  color: var(--text-secondary);
}

/* Table Section */
.table-section {
  margin-bottom: 3rem;
}

.table-section h2 {
  margin-bottom: 0.5rem;
  font-size: 1.8rem;
}

.table-hint {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.table-container {
  overflow-x: auto;
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(10px);
  border-radius: 1rem;
  border: 1px solid var(--border-color);
}

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

thead {
  background: rgba(99, 102, 241, 0.1);
}

th {
  padding: 1rem;
  text-align: center;
  font-weight: 600;
  color: var(--primary-color);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

td {
  padding: 0.875rem 1rem;
  text-align: center;
  border-bottom: 1px solid rgba(71, 85, 105, 0.3);
}

tbody tr {
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: rgba(99, 102, 241, 0.05);
}

.editable {
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
  display: inline-block;
  min-width: 50px;
  border: 1px solid transparent;
}

.editable:hover {
  background: rgba(99, 102, 241, 0.2);
  transform: scale(1.05);
}

.editable input {
  background: var(--surface-light);
  border: 2px solid var(--primary-color);
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: 0.375rem;
  width: 80px;
  font-size: 1rem;
  font-family: inherit;
}

/* Charts Section */
.charts-section {
  margin-bottom: 3rem;
}

.charts-section h2 {
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
}

.charts-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 2rem;
}

.chart-wrapper {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(10px);
  padding: 2rem;
  border-radius: 1rem;
  border: 1px solid var(--border-color);
}

.chart-wrapper h3 {
  margin-bottom: 1rem;
  color: var(--secondary-color);
}

.action-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: 2rem;
  margin-bottom: 3rem;
  gap: 1.5rem;
}

.download-note {
  color: var(--text-secondary);
  font-size: 0.95rem;
  background: rgba(245, 158, 11, 0.1);
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(245, 158, 11, 0.3);
  max-width: 600px;
  text-align: center;
  animation: fadeInUp 0.6s ease-out 0.4s both;
}

.download-note strong {
  color: #fbbf24;
}

/* Summary Section */
.summary-section {
  margin-bottom: 3rem;
  animation: fadeInUp 0.6s ease-out;
}

.summary-section h2 {
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.summary-card {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
  border-radius: 1rem;
  border: 1px solid var(--border-color);
  text-align: center;
  transition: all 0.3s ease;
}

.summary-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary-color);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.summary-label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-value {
  display: block;
  color: var(--text-primary);
  font-size: 1.75rem;
  font-weight: 700;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Animations */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
  }

  .container {
    padding: 1rem;
  }

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

  .chart-wrapper {
    min-width: 0;
  }

  table {
    font-size: 0.875rem;
  }

  th,
  td {
    padding: 0.5rem;
  }

  .btn-correct {
    font-size: 1rem;
    padding: 1rem 2rem;
  }
}

@media (max-width: 480px) {
  .upload-box {
    padding: 2rem 1rem;
  }

  .upload-icon {
    font-size: 3rem;
  }

  .file-info {
    flex-direction: column;
  }
}

/* Bulk Edit Section */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

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

.bulk-edit-section {
  margin-bottom: 2rem;
  animation: fadeInDown 0.4s ease-out;
}

.bulk-edit-card {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid var(--primary-color);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

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

.bulk-header h3 {
  color: var(--primary-color);
  margin: 0;
  font-size: 1.4rem;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.5rem;
  transition: color 0.2s;
}

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

.bulk-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 768px) {
  .bulk-content {
    grid-template-columns: 1fr;
  }
}

.bulk-col h4 {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quick-filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--surface-light);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

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

.selection-input-wrapper label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

#lapSelection {
  width: 100%;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 0.5rem;
  font-family: inherit;
  margin-bottom: 0.5rem;
}

#lapSelection:focus {
  border-color: var(--primary-color);
  outline: none;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
}

.action-grid-rows {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .action-grid-rows {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.action-pair-container {
  background: var(--surface);
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
}

.action-pair {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.action-group {
  flex: 1;
}

.pair-separator {
  padding-bottom: 0.8rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 600;
}

.pair-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  text-align: center;
  margin-bottom: 0;
}

.action-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  white-space: nowrap;
}

.action-group input {
  width: 100%;
  padding: 0.6rem;
  background: var(--surface-light);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 0.5rem;
  font-size: 0.95rem;
}

.action-group input:focus {
  border-color: var(--primary-color);
  outline: none;
}

.full-width {
  width: 100%;
}
