/* === Dark Theme & Base Styles === */
:root {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a24;
  --bg-tertiary: #252535;
  --bg-hover: #2d2d42;
  --text-primary: #e8e8f0;
  --text-secondary: #b0b0c0;
  --text-muted: #808090;
  --border-color: #2a2a3a;
  --border-light: #353545;
  --accent: #5b7fff;
  --accent-hover: #6d8fff;
  --success: #4ade80;
  --danger: #f87171;
  --warning: #fbbf24;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  color: var(--text-primary);
  font: 500 14px/1.5 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
  background: var(--bg-primary);
}

h1,
h2 {
  margin: 0 0 12px;
  font-weight: 700;
  font-size: 22px;
  color: var(--text-primary);
}

/* === Toolbar === */
#toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
  color: var(--text-primary);
}

#toolbar select,
#toolbar input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

#toolbar select:hover,
#toolbar input:hover {
  border-color: var(--border-light);
  background: var(--bg-tertiary);
}

#toolbar select:focus,
#toolbar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 127, 255, 0.1);
}

/* === Table Container (Vertical Scroll Only) === */
.table-viewport {
  max-height: 70vh; /* adjust viewport height */
  overflow-y: auto; /* enable vertical scroll */
  overflow-x: hidden; /* disable horizontal scroll */
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  background: var(--bg-secondary);
}

/* === Events Table - Dark Theme with Orange Accents === */
#eventsTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #1a0f00;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(249, 115, 22, 0.25);
  border: 3px solid rgba(249, 115, 22, 0.5);
}

#eventsTable thead th {
  background: #383521;
  color: #fff7ed;
  padding: 16px 18px;
  text-align: center;
  border-right: 1px solid rgba(249, 115, 22, 0.4);
  border-bottom: 3px solid rgba(249, 115, 22, 0.7);
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 12px;
}

#eventsTable thead th:last-child {
  border-right: none;
}

#eventsTable thead th[data-sort] {
  cursor: pointer;
  transition: all 0.2s ease;
}

#eventsTable thead th[data-sort]:hover {
  background: #606013;
  color: #ffedd5;
}

#eventsTable tbody td {
  padding: 14px 16px;
  border-right: 1px solid rgba(124, 63, 19, 0.25);
  text-align: center;
  vertical-align: middle;
  color: #e1d011;
  white-space: normal;
  word-break: break-word;
  hyphens: auto;
  transition: all 0.2s ease;
}

#eventsTable tbody tr:nth-child(odd) td {
  background: #100f0f;
}

#eventsTable tbody tr:nth-child(even) td {
  background: #1c1616;
}

#eventsTable tbody tr:hover td {
  background: #584540;
}

/* === Expand Buttons === */
.expand-cell button {
  appearance: none;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-primary);
  background: var(--accent);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.expand-cell button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(91, 127, 255, 0.3);
}

.expand-cell button:active {
  transform: translateY(0);
}

/* === Expanded Section === */
.expand-row td {
  background: #0f172a;
  border-top: 3px solid rgb(154, 149, 195);
  padding: 20px 16px;
}

/* === Expand Header - Dark Yellow Theme === */
.expand-header {
  background: #4a3d00;
  color: #fef3c7;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  border: 2px solid rgba(234, 179, 8, 0.5);
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.2);
}

/* === Lines Table - Dark Theme (Higher Specificity to Override Events Table) === */
#eventsTable .expand-row .linesTable,
.linesTable {
  margin-top: 12px !important;
  width: 100% !important;
  border-collapse: collapse !important;
  /* border: 1px solid rgba(34, 197, 94, 0.5) !important; */

  border-radius: 10px !important;
  overflow: hidden !important;
  background: #0f172a !important;
  box-shadow: 0 6px 24px rgba(34, 197, 94, 0.25) !important;
}

#eventsTable .expand-row .linesTable thead th,
.linesTable thead th {
  background: #065f46 !important;
  color: #d1fae5 !important;
  padding: 14px 16px !important;
  text-align: center !important;
  border-right: 1px solid rgba(34, 197, 94, 0.4) !important;
  /* border-bottom: 1px solid rgba(34, 197, 94, 0.7) !important; */
  position: sticky !important;
  top: 0 !important;
  z-index: 1 !important;
  font-weight: 700 !important;
  letter-spacing: 0.4px !important;
  font-size: 11px !important;
  text-transform: uppercase !important;
}

#eventsTable .expand-row .linesTable tbody td,
.linesTable tbody td {
  padding: 12px 14px !important;
  text-align: center !important;
  color: #d1fae5 !important;
  border-right: 1px solid rgba(34, 197, 94, 0.25) !important;
  word-break: break-word !important;
  transition: all 0.2s ease !important;
  background: transparent !important;
}

#eventsTable .expand-row .linesTable tbody tr:nth-child(odd) td,
.linesTable tbody tr:nth-child(odd) td {
  background: #1e293b !important;
  color: #d1fae5 !important;
}

#eventsTable .expand-row .linesTable tbody tr:nth-child(even) td,
.linesTable tbody tr:nth-child(even) td {
  background: #0f172a !important;
  color: #d1fae5 !important;
}

#eventsTable .expand-row .linesTable tbody tr:hover td,
.linesTable tbody tr:hover td {
  background: #334155 !important;
  color: #d1fae5 !important;
}

#eventsTable .expand-row .linesTable thead th:last-child,
#eventsTable .expand-row .linesTable tbody td:last-child,
.linesTable thead th:last-child,
.linesTable tbody td:last-child {
  border-right: none !important;
}

#eventsTable .expand-row .linesTable tbody {
  /* border-top: 10px solid rgba(182, 45, 159, 0.7) !important; */
  border-bottom: 10px solid rgb(154, 149, 195) !important;
}
/* === Pagination === */
#pagination-controls,
.lines-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  flex-wrap: wrap;
}

#pagination-controls input,
.lines-pagination input,
.lines-pagination select {
  width: 72px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

#pagination-controls input:hover,
.lines-pagination input:hover,
.lines-pagination select:hover {
  border-color: var(--border-light);
  background: var(--bg-tertiary);
}

#pagination-controls input:focus,
.lines-pagination input:focus,
.lines-pagination select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 127, 255, 0.1);
}

.lines-pagination select {
  width: auto;
}

#pageInfo,
#pageInfoTop,
.lines-page-info {
  color: var(--text-secondary);
}

/* === Loader Overlay === */
#loadingOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 20, 0.85);
  z-index: 999;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-weight: 600;
  backdrop-filter: blur(2px);
}

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

.spinner {
  border: 4px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.9s linear infinite;
  margin-right: 12px;
}

.sort-icon {
  font-size: 0.8rem;
  margin-left: 4px;
  color: var(--text-secondary);
}

/* === Additional Styles for Login Page === */
button {
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}

button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(91, 127, 255, 0.3);
}

button:active {
  transform: translateY(0);
}

#status {
  margin-top: 12px;
  color: var(--text-secondary);
}

#messageBox {
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  /* background: rgba(248, 113, 113, 0.1); */
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--text-secondary);
}
