/* Root color variables */
:root {
  --bg-color: #4a7dbb;
  --calc-bg: #dce8f5;
  --display-bg: #bcd1ec;
  --btn-bg: #c7daf3;
  --btn-hover: #a9c8f0;
  --text-color: #1c2b3a;
  --enter-bg: #4a7dbb;
  --enter-hover: #3c6ea8;
}

/* Dark mode variables */
[data-theme="dark"] {
  --bg-color: #121212;
  --calc-bg: #1f1f1f;
  --display-bg: #2a2a2a;
  --btn-bg: #333;
  --btn-hover: #444;
  --text-color: #f1f1f1;
  --enter-bg: #0059b3;
  --enter-hover: #0073e6;
}

* {
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}

body {
  background-color: var(--bg-color);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
}

/* Main Calculator Container */
.calculator {
  background-color: var(--calc-bg);
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  width: 340px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Theme toggle section */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
  margin-right: 10px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--enter-bg);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

#modeText {
  color: var(--text-color);
  font-size: 0.9em;
}

/* Display area */
.display {
  background-color: var(--display-bg);
  border-radius: 15px;
  padding: 15px;
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  min-height: 90px;
  word-wrap: break-word;
  position: relative;
}

/* Input text */
.input {
  font-size: 1.2em;
  color: var(--text-color);
  opacity: 0.8;
  width: 100%;
  text-align: right;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: var(--enter-bg) transparent;
}

/* Scrollbar styling for input overflow */
.input::-webkit-scrollbar {
  height: 5px;
}
.input::-webkit-scrollbar-thumb {
  background-color: var(--enter-bg);
  border-radius: 10px;
}

/* Result display */
.result {
  font-size: 2em;
  font-weight: 600;
  color: var(--text-color);
  width: 100%;
  text-align: right;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Button grid styling */
.buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

button {
  border: none;
  background-color: var(--btn-bg);
  border-radius: 12px;
  font-size: 1.1em;
  font-weight: 500;
  color: var(--text-color);
  padding: 12px;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
}

button:hover {
  background-color: var(--btn-hover);
  transform: translateY(-2px);
}

button:active {
  transform: scale(0.97);
}

.enter {
  grid-column: span 2;
  background-color: var(--enter-bg);
  color: white;
  font-weight: 600;
}

.enter:hover {
  background-color: var(--enter-hover);
}

/* Responsive styling */
@media (max-width: 400px) {
  .calculator {
    width: 300px;
  }
  .input {
    font-size: 1em;
  }
  .result {
    font-size: 1.6em;
  }
}
