/* 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: flex;
  gap: 1rem;
  width: 100%;
  height: 600px;
}

/* Calculator container */
.calculator-container {
  flex: 1;
  background-color: #181A1E;
  border: 1px solid #2D2F34;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 550px;
  align-items: center;
  justify-content: flex-start;
}

/* Right panel container */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 50%;
  height: 100%;
}

/* 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: #dc2626;
}

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

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

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

/* HISTORY PANEL */
.history-panel {
  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: 250px;
  overflow-y: auto;
  flex-shrink: 0;
}

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

.history-header h2 {
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0;
}

#clearHistoryBtn {
  background-color: #dc2626;
  color: #FFFFFF;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s ease;
  font-family: 'SF Mono', monospace;
  font-weight: 500;
}

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

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

.history-list {
  font-size: 0.9rem;
  line-height: 1.4;
  width: 100%;
  font-family: 'SF Mono', monospace;
}

/* Active states for touch devices */
.calc-btn:active,
#clearHistoryBtn:active,
.delete-btn:active {
  background-color: #3A3D42;
  opacity: 1;
}

.history-list div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-list .timestamp {
  color: #888;
  font-size: 0.75rem;
  margin-left: 1rem;
  white-space: nowrap;
}

/* History entry styling */
.history-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  position: relative;
  cursor: pointer;
}

.history-entry .calculation {
  flex-grow: 1;
  margin-right: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-entry .timestamp {
  color: #888;
  font-size: 0.75rem;
  white-space: nowrap;
  margin-right: 25px;
}

.history-entry .delete-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  background: none;
  border: none;
  padding: 2px;
}

/* Desktop: Show hover effect only on devices with hover capability */
@media (hover: hover) {
  .history-entry .delete-btn:hover {
    opacity: 1;
  }

  /* Desktop: Hide delete buttons by default, show on hover */
  .history-entry .delete-btn {
    display: none;
  }

  .history-entry:hover .delete-btn {
    display: block;
  }
}

/* Mobile: Show delete button when entry is selected */
@media (hover: none) {
  .history-entry .delete-btn {
    display: none;
  }

  .history-entry.selected .delete-btn {
    display: block;
  }
}

.history-entry.selected {
  background-color: rgba(79, 70, 229, 0.1);
  border-radius: 4px;
}

/* ILLUSTRATION PANEL */
.illustration {
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  height: 100%;
  flex-grow: 1;
  min-height: 200px;
}

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

/* RESPONSIVE DESIGN */
@media (max-width: 992px) {
  .calc-grid {
    flex-direction: column;
    height: auto;
  }

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

  .right-panel {
    width: 100%;
    height: auto;
  }

  .history-panel {
    height: auto;
  }

  .illustration {
    height: auto;
    min-height: 180px;
  }

  .illustration img {
    max-width: 80%;
    max-height: 80%;
    width: auto;
    height: auto;
  }
}

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

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

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

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

  .right-panel {
    width: 100%;
  }

  .history-panel {
    width: 100%;
    padding: 0.75rem;
    max-height: none;
    height: auto;
  }

  .illustration {
    min-height: 150px;
  }

  .illustration img {
    max-width: 75%;
    max-height: 75%;
    width: auto;
    height: auto;
  }

  .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 h2 {
    font-size: 1.1rem;
    line-height: 1.4;
  }

  #clearHistoryBtn {
    font-size: 0.9rem;
    padding: 0.4rem 0.7rem;
  }

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