/* RESET & BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
}

.content-wrapper {
  width: 100%;
  max-width: 1200px;
}

.page-title {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

/* CALCULATOR GRID */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1rem;
  width: 100%;
}

/* Calculator container spans two rows in left column */
.calculator-container {
  grid-column: 1;
  grid-row: 1 / 3;
  background-color: #181A1E;
  border: 1px solid #2D2F34;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 550px;
  margin: auto 0;
  align-items: center;
  justify-content: flex-start;
}

/* Calculator display */
.calculator-display {
  width: 100%;
  background-color: #24272B;
  border-radius: 6px;
  padding: 1rem;
  font-size: 1.6rem;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: 'SF Mono', monospace;
}

/* Calculator buttons */
.calculator-buttons {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: 0.75rem;
  width: 100%;
}

.calc-btn {
  background-color: #2D2F34;
  font-size: 1.1rem;
  color: #FFFFFF;
  padding: 1rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  font-family: 'SF Mono', monospace;
}

.calc-btn:hover {
  background-color: #3A3D42;
}

.btn-ac {
  background-color: #EF4444;
}

.btn-ac:hover {
  background-color: #dc2626;
}

.btn-equals {
  background-color: #3B82F6;
}

.btn-equals:hover {
  background-color: #2D6FE4;
}

/* HISTORY PANEL */
.history-panel {
  grid-column: 2;
  grid-row: 1;
  background-color: #181A1E;
  border: 1px solid #2D2F34;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  height: 100%;
  overflow-y: auto;
}

.history-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.history-header h3 {
  font-size: 1rem;
}

#clearHistoryBtn {
  background-color: #EF4444;
  color: #FFFFFF;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease;
  font-family: 'SF Mono', monospace;
}

#clearHistoryBtn:hover {
  background-color: #dc2626;
}

/* Disable hover effects on touch devices */
@media (hover: none) {
  #clearHistoryBtn:hover {
    background-color: #EF4444;
    /* Revert to original background color */
  }
}

.history-list {
  font-size: 0.9rem;
  line-height: 1.4;
  width: 100%;
}

/* ILLUSTRATION PANEL */
.illustration {
  grid-column: 2;
  grid-row: 2;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  height: 100%;
}

.illustration img {
  max-width: 75%;
  max-height: 75%;
  object-fit: contain;
}

/* RESPONSIVE DESIGN */
@media (max-width: 992px) {
  .calc-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .calculator-container {
    grid-row: 1;
    margin: 0 auto 1rem;
  }

  .history-panel {
    grid-row: 2;
    height: auto;
  }

  .illustration {
    grid-row: 3;
    height: auto;
  }
}

@media (max-width: 768px) {
  .main-content {
    padding: 60px 1rem 1rem;
  }

  .page-title {
    font-size: 1.3rem;
    line-height: 1.3;
  }

  .calc-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .calculator-container {
    min-height: 500px;
    width: 100%;
    padding: 0.75rem;
  }

  .history-panel {
    width: 100%;
    padding: 0.75rem;
  }

  .calculator-display {
    font-size: 1.4rem;
    padding: 0.75rem;
    line-height: 1.3;
  }

  .calculator-buttons {
    gap: 0.5rem;
  }

  .calc-btn {
    font-size: 1.1rem;
    padding: 0.75rem;
  }

  .history-header h3 {
    font-size: 1rem;
    line-height: 1.4;
  }

  #clearHistoryBtn {
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
  }

  .history-list {
    font-size: 0.95rem;
    line-height: 1.5;
  }
}