/* --- MANTINE UI STYLING --- */
:root {
  --mantine-primary: #228be6; /* Mantine Blue 6 */
  --mantine-primary-hover: #1c7ed6; /* Mantine Blue 7 */
  --mantine-danger: #fa5252; /* Mantine Red 6 */
  --mantine-danger-hover: #e03131; /* Mantine Red 7 */

  --mantine-bg: #f8f9fa; /* Mantine Gray 0 */
  --mantine-surface: #ffffff;
  --mantine-text: #212529; /* Mantine Gray 9 */
  --mantine-text-dimmed: #868e96; /* Mantine Gray 6 */
  --mantine-border: #ced4da; /* Mantine Gray 4 */
  --mantine-focus: #339af0; /* Mantine Blue 5 */

  --mantine-radius: 4px;
  --mantine-shadow-sm:
    0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
  --mantine-shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

  --mantine-font:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

/* --- RESET & BASE --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  overflow: hidden;
  font-family: var(--mantine-font);
  color: var(--mantine-text);
  background-color: var(--mantine-bg);
  line-height: 1.55;
}

canvas {
  display: block;
}

p {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

/* --- BUTTONS --- */
button {
  flex: 0 0 auto;
  min-width: 80px;
  padding: 8px 14px;
  margin: 8px 0;
  font-family: var(--mantine-font);
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  background-color: var(--mantine-primary);
  border: 1px solid transparent;
  border-radius: var(--mantine-radius);
  cursor: pointer;
  transition:
    background-color 150ms ease,
    transform 100ms ease;
}

button:hover {
  background-color: var(--mantine-primary-hover);
}

button:active {
  transform: translateY(1px);
}

/* Specific Button Overrides */
.menu-toggle-button {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1000;
  margin: 0;
  box-shadow: var(--mantine-shadow-sm);
}

.sort,
.stop {
  position: fixed;
  top: 15px;
  z-index: 1000;
  margin: 0;
  box-shadow: var(--mantine-shadow-sm);
}

.sort {
  right: 15px;
}

.stop {
  right: 105px;
  background-color: var(--mantine-danger);
}

.stop:hover {
  background-color: var(--mantine-danger-hover);
}

/* --- UI PANELS --- */
.menu {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 300px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--mantine-surface);
  padding: 24px;
  border-right: 1px solid var(--mantine-border);
  box-shadow: var(--mantine-shadow-md);
  z-index: 999;
}

.title {
  position: fixed;
  bottom: 20px;
  left: 0px;
  border-radius: 0 var(--mantine-radius) var(--mantine-radius) 0;
  min-width: 250px;
  background-color: var(--mantine-surface);
  border: 1px solid var(--mantine-border);
  border-left: none;
  text-align: right;
  padding: 12px 20px;
  z-index: 1000;
  box-shadow: var(--mantine-shadow-md);
}

.title h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--mantine-text);
  margin-bottom: 2px;
}

.title p {
  color: var(--mantine-text-dimmed);
  font-size: 13px;
  margin: 0;
}

.title a {
  color: var(--mantine-primary);
  text-decoration: none;
}

.title a:hover {
  text-decoration: underline;
}

.stats {
  position: fixed;
  top: 80px;
  right: 0px;
  border-radius: var(--mantine-radius) 0 0 var(--mantine-radius);
  min-width: 100px;
  background-color: var(--mantine-surface);
  color: var(--mantine-text);
  border: 1px solid var(--mantine-border);
  border-right: none;
  text-align: center;
  padding: 8px 16px;
  z-index: 1000;
  box-shadow: var(--mantine-shadow-md);
  font-weight: 500;
  font-size: 14px;
  display: none;
}

/* --- INPUTS & FORMS --- */
input[type="number"],
select {
  width: 100%;
  border-radius: var(--mantine-radius);
  border: 1px solid var(--mantine-border);
  padding: 8px 12px;
  font-family: var(--mantine-font);
  font-size: 14px;
  color: var(--mantine-text);
  background-color: #fff;
  transition: border-color 150ms ease;
  outline: none;
}

input[type="number"]:focus,
select:focus {
  border-color: var(--mantine-focus);
}

.checkboxs {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--mantine-text);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--mantine-primary);
  cursor: pointer;
}

/* Slider CSS */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  width: 100%;
  margin: 10px 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  background: #e9ecef; /* Mantine Gray 2 */
  height: 8px;
  border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--mantine-primary);
  border: 2px solid #fff;
  border-radius: 50%;
  margin-top: -5px;
  cursor: pointer;
  box-shadow: var(--mantine-shadow-sm);
  transition: transform 100ms ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

/* --- UTILITIES --- */
.hide {
  display: none !important;
}

.gap {
  height: 12px;
}

.size-label {
  margin-top: 50px;
}

#speedLabel {
  margin-top: 10px;
}

/* --- RESPONSIVE --- */
@media (max-width: 600px) {
  .menu {
    width: 100vw;
    border-right: none;
  }
  .title {
    width: 100vw;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--mantine-border);
    bottom: 0;
  }
}
/* --- TOP CENTER HEADING --- */
.top-header {
  position: fixed;
  top: 15px;
  left: 50%;
  transform: translateX(-50%); /* Perfectly centers the element */
  background-color: var(--mantine-surface);
  padding: 12px 32px;
  border: 1px solid var(--mantine-border);
  border-radius: var(--mantine-radius);
  box-shadow: var(--mantine-shadow-md);
  text-align: center;
  z-index: 998; /* Just below the menu to prevent overlaps */
}

.top-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--mantine-primary);
  margin-bottom: 2px;
  letter-spacing: 0.5px;
}

.top-header .department-credit {
  font-size: 12px;
  font-weight: 600;
  color: var(--mantine-text-dimmed);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0;
}

/* Ensure it doesn't overlap the Sort/Stop buttons on smaller screens */
@media (max-width: 768px) {
  .top-header {
    top: 70px; /* Pushes it below the top row of buttons */
    padding: 10px 20px;
    width: 90%;
  }
  .top-header h1 {
    font-size: 18px;
  }
  .top-header .department-credit {
    font-size: 10px;
  }
}
