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

* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

body {
  font-family: "Inter", sans-serif;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-4px);
  }

  40%,
  80% {
    transform: translateX(4px);
  }
}

.animate-shake {
  animation: shake 0.35s ease-in-out;
}

/* Mobile responsiveness improvements */
.mobile-scroll {
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  table {
    min-width: 700px;
  }

  math-field {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Responsive updates for the Calculator Window */
  #calculator-window {
    width: calc(100% - 24px) !important;
    max-width: 380px;
    left: 12px !important;
    right: 12px !important;
    margin: 0 auto;
    top: 40px !important;
  }

  #calculator-body {
    flex-direction: column;
  }

  #calculator-display {
    font-size: 22px;
    padding: 14px 12px;
  }

  .calc-keys {
    gap: 3px;
    padding: 6px;
  }

  .calc-keys button {
    padding: 12px 0;
    font-size: 12px;
  }

  #calculator-history {
    width: 100% !important;
    max-height: 80px !important;
    border-left: none;
    border-top: 1px solid rgba(130, 120, 230, 0.08);
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    padding: 6px 8px;
  }

  .calc-hist-item {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px 8px;
    border-radius: 4px;
    flex-shrink: 0;
    word-break: normal;
  }
}

/* Custom overrides to make MathLive math-fields look completely uniform with Tailwind styling scales */
math-field {
  font-size: 14px !important;
  background-color: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 0.25rem !important;
  padding: 0.375rem 0.75rem !important;
  outline: none !important;
  transition: all 0.15s ease-in-out;
}

math-field:focus-within {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2) !important;
}

.dark math-field {
  background-color: #0f172a !important;
  border-color: #475569 !important;
  color: #e2e8f0 !important;
}

.dark math-field:focus-within {
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25) !important;
}

math-field[disabled] {
  background-color: #f8fafc !important;
  opacity: 0.6 !important;
  pointer-events: none !important;
}

.dark math-field[disabled] {
  background-color: #020617 !important;
}

.dark #reference-tables-modal th,
.dark #reference-tables-modal td {
  border-color: #334155 !important;
}

/* Calculator Window Styles */
#calculator-window {
  width: 380px;
  position: fixed;
  top: 80px;
  left: 80px;
  display: none;
  flex-direction: column;
  z-index: 100;
  background: rgba(24, 22, 38, 0.88);
  border-radius: 14px;
  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.7),
    0 5px 15px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(130, 120, 230, 0.08);
  overflow: hidden;
  height: auto;
}

#calculator-window::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("https://grainy-gradients.vercel.app/noise.svg");
  opacity: 0.03;
}

#calculator-titlebar {
  background: linear-gradient(to bottom, #2b2744, #1c192d);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding: 12px;
  cursor: move;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  color: #cbd3f0;
  font-weight: bold;
  font-size: 13px;
  letter-spacing: 0.5px;
}

#calculator-controls {
  display: flex;
  gap: 2px;
  margin-top: -12px;
  margin-bottom: -12px;
  margin-right: -12px;
}

.calc-btn {
  width: 44px;
  height: 41px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #7b7a93;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  user-select: none;
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}

.calc-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.calc-close:hover {
  background: #e81123 !important;
  color: #ffffff !important;
}

.calc-max {
  font-size: 18px;
}

#calculator-display {
  width: 100%;
  box-sizing: border-box;
  font-size: 26px;
  padding: 18px 16px;
  border: none;
  outline: none;
  background: #080711;
  color: #ffffff;
  text-align: right;
  border-bottom: 1px solid rgba(130, 120, 230, 0.05);
}

#calculator-body {
  display: flex;
  flex: 1;
}

.calc-keys {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
  flex: 1;
}

.calc-keys button {
  padding: 14px 0;
  border: none;
  color: #d1cef0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  background: linear-gradient(145deg, #27243c, #1b192b);
  box-shadow:
    2px 2px 5px rgba(0, 0, 0, 0.45),
    -1px -1px 3px rgba(255, 255, 255, 0.01);
  transition: all 0.1s ease;
}

.calc-keys button:hover {
  background: linear-gradient(145deg, #312e4c, #211e35);
  color: #ffffff;
}

.calc-keys button:active {
  transform: translateY(1px);
  box-shadow:
    1px 1px 2px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.calc-op {
  background: linear-gradient(145deg, #2f2a52, #201c3b);
  color: #aaa4de;
}
.calc-op:hover {
  background: linear-gradient(145deg, #3a3466, #27234a);
}

.calc-eq {
  background: linear-gradient(145deg, #493ebd, #332b8f);
  color: white;
  font-weight: bold;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.calc-eq:hover {
  background: linear-gradient(145deg, #584be3, #3d33ab);
}

#calculator-history {
  width: 130px;
  background: #07060d;
  color: #7b7896;
  font-size: 11px;
  padding: 8px;
  overflow-y: auto;
  max-height: 330px;
  border-left: 1px solid rgba(130, 120, 230, 0.03);
  box-sizing: border-box;
}

.calc-hist-item {
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(130, 120, 230, 0.03);
  padding-bottom: 6px;
  word-break: break-all;
}

/* Subtle Indigo Neon Glow Effect */
.neon-widget {
  border: 1px solid rgba(99, 102, 241, 0.6); /* Subtle Indigo-500 border */
  box-shadow:
    0 0 8px rgba(99, 102, 241, 0.24),
    0 4px 12px rgba(99, 102, 241, 0.08);
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

/* Enhanced visibility tailored for Dark Mode */
.dark .neon-widget {
  border-color: rgba(129, 140, 248, 0.7); /* Indigo-400 border */
  box-shadow:
    0 0 10px rgba(129, 140, 248, 0.5),
    0 0 20px rgba(99, 102, 241, 0.2),
    inset 0 0 6px rgba(129, 140, 248, 0.1);
}

@layer utilities {
  /* Hide scrollbar for Chrome, Safari and Opera */
  .no-scrollbar::-webkit-scrollbar {
    display: none;
  }
  /* Hide scrollbar for IE, Edge and Firefox */
  .no-scrollbar {
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
  }
}
