/* Calculator page styles – page-header from base.css */
.history-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-muted) !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.history-toggle:hover {
  color: var(--text) !important;
  background: var(--surface-hover) !important;
}

.history-toggle .icon {
  font-size: 1rem;
  transition: transform 0.25s ease;
}

.app.history-open .history-toggle .icon {
  transform: rotate(180deg);
}

.app {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xl, 2rem);
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: min(900px, 100vw - 2rem);
}

.calculator-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.calculator {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  width: 100%;
  min-width: 0;
  max-width: 440px;
}

.display {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  min-height: 80px;
  max-width: 100%;
  text-align: right;
  font-size: 2.25rem;
  font-weight: 500;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  color: var(--text);
}

.display-expression {
  font-size: 1rem;
  color: var(--text-muted);
  min-height: 1.4rem;
  margin-bottom: 0.35rem;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  text-align: right;
}

.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
}

.calculator button {
  font-family: inherit;
  font-size: 1.4rem;
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.calculator button:hover {
  background: var(--border);
}

.calculator button:active {
  transform: scale(0.97);
}

.calculator button.operator {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
}

.calculator button.operator:hover {
  background: rgba(99, 102, 241, 0.35);
}

.calculator button.equals {
  background: var(--accent);
  color: #fff;
  grid-column: span 2;
}

.calculator button.equals:hover {
  background: var(--accent-hover);
}

.calculator button.clear {
  color: #dc2626;
}

.history-slider {
  width: 0;
  overflow: hidden;
  transition: width 0.3s ease;
  flex-shrink: 0;
}

.app.history-open .history-slider {
  width: 320px;
}

@media (max-width: 991.98px) {
  .app .calculator-wrap {
    display: flex !important;
  }
  .app .history-slider {
    display: none;
    width: 0;
    overflow: hidden;
  }
  .app.history-open .calculator-wrap {
    display: none !important;
  }
  .app.history-open .history-slider {
    display: block !important;
    width: 100% !important;
    max-width: 100%;
    overflow: visible;
  }
  .app.history-open .history-panel {
    width: 100%;
    max-width: 100%;
    max-height: min(70vh, 520px);
  }
}

.history-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  width: 320px;
  max-width: 100%;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.history-panel h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 0.15rem;
  margin-bottom: 0.15rem;
}

.history-item {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

.history-item .expr {
  color: var(--text-muted);
}

.history-item .result {
  font-weight: 600;
  color: var(--accent);
}

.history-item .time {
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.9;
  margin-top: 0.2rem;
}

.history-item:hover {
  background: var(--surface-hover);
  cursor: pointer;
}

.history-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1rem 0;
  text-align: center;
}

.clear-history {
  margin-top: 1rem;
  padding: 0.5rem;
  font-size: 0.8rem;
  background: transparent !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border) !important;
}

.clear-history:hover {
  color: #dc2626 !important;
  border-color: #dc2626 !important;
}
