/* ---------- CSS VARIABLES (light theme default) ---------- */
:root{
  --bg: #F5F7FA;
  --card-bg: #FFFFFF;
  --primary: #2563EB;
  --primary-600: #1D4ED8;
  --text: #1F2937;
  --muted: #6B7280;
  --result-bg: #F9FAFB;
  --error: #DC2626;

  --radius: 12px;
  --card-padding: 1.5rem;
  --base-font: 16px;
}

/* Dark theme overrides (when .dark is on <html> or <body>) */
.dark {
  --bg: #0b1220;
  --card-bg: #071127;
  --primary: #3B82F6;
  --primary-600: #2563EB;
  --text: #E6EEF8;
  --muted: #9AA8BF;
  --result-bg: #061428;
  --error: #F87171;
}

body{
    font-family: system-ui,Segoe UI,Roboto,Arial;
    margin: 0;
    background: #f5f7fb;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;

    background: var(--bg);
  color: var(--text);
  font-size: var(--base-font);
  margin: 0;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}
  .card{
    position: relative; /* make card a positioning container*/
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(20, 30, 60, 0.08);
    width: 420px;
    max-width: 500px; /* Prevents card from growing too tall */
    margin: 20px auto;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--card-padding);
    overflow: hidden;
}

.title {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.title i {
  font-size: 40px;
  color: #2563eb; /* nice blue to match theme */
  margin-bottom: 10px;
}

.title h1 {
  font-size: 1.8rem;
  color: #333;
  margin: 0;
  text-align: center;
}

.title p {
  font-size: 1rem;
  color: #555;
  text-align: center;
}

  label{
    display: block;
    margin: 8px 0 4px;
    font-size: 13px;
    color: #333;
}
  input[type="text"], select{
    width: 100%;
    padding: 10px;
    border: 1px solid #d7dbe6;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 15px;
}
  .row{
    display: flex;
    gap: 10px;
    margin-top: 12px;
}
  button{
    padding: 10px 12px;
    border-radius: 6px;
    border: 0;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    font-weight: 600;
}
  .btn-ghost{
    background: #d3daf3;
    color: #2563eb;
    flex: 1;
}

.error{
    color: #b91c1c;
    margin-top: 8px;
    font-size: 14px;
}
  .results{
    margin-top: 14px;
}
  .result-row{
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 6px;
    background: #8e9397;
    margin-bottom: 8px;
    font-family: monospace;
}
  .small{
    font-size: 13px;
    color: #555;
}

  .history-list{
    margin-top: 8px;
    max-height: 120px;
    overflow-y: auto;
    background: #f9f9f9;
    padding: 8px;
    border-radius: 5px;
}
  .history-item{
    padding: 6px;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
}

.history-item:hover {
background-color: #e5e7eb;
}

#historyForm{
margin-top: 12px;
}

.history-buttons{
display: flex;
justify-content: space-between;
margin-top: 10PX;
gap: 10px;
}

.history-buttons button{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  background-color: #e0e7ff;
  color: #2563eb;
  border: none;
  border-radius: 5px;
  padding: 10px 10px;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}

.history-buttons button:hover {
  background-color: #c7d2fe;
}

button i {
  margin-right: 6px; /* puts icon in front of text */
  font-size: 16px;
}

.app-footer {
  margin-top: 20px;
  font-size: 0.9rem;
  color: #777;
  text-align: center;
  line-height: 1.4;
}

/* ---------- Responsive breakpoints ---------- */

/* Mobile phones (<= 480px) */
@media (max-width: 480px) {
  :root { --base-font: 15px; --card-padding: 1rem; }
  .card { max-width: 95%; border-radius: 10px; }
  .app-icon { width: 34px; height: 34px; }
  .subtitle { font-size: 0.9rem; padding: 0 0.25rem; }
  .results-scroll, .history-list { max-height: 220px; }
}

/* Small tablets (481 - 900px) */
@media (min-width: 481px) and (max-width: 900px) {
  :root { --base-font: 15.5px; --card-padding: 1.25rem; }
  .card { max-width: 560px; }
  .results-scroll, .history-list { max-height: 280px; }
}

/* Desktop (>= 901px) */
@media (min-width: 901px) {
  :root { --base-font: 16px; --card-padding: 1.75rem; }
  .card { max-width: 720px; }
  .results-scroll, .history-list { max-height: 360px; }
}

.small {
  color: var(--muted); font-size: 0.95rem;
}
.error { 
  color: var(--error); 
}

/* smooth color transitions on theme change */
* { transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease; }

/* Theme toggle styles */
.theme-toggle {
  position: absolute;
  top: 1.5rem;
  right: 1.0rem;
  cursor: pointer;
  display:inline-block;
  vertical-align:middle;
  margin-left:12px;
  --w:44px; --h:24px; --pad:3px;
}

/* Example toggle style */
.theme-toggle input {
  display:none;
}
.theme-toggle .toggle-track {
  width: var(--w);
  height: var(--h);
  display:inline-block;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(0,0,0,0.06), rgba(0,0,0,0.03));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
  position: relative;
  transition: background 180ms ease;
}
.theme-toggle .toggle-track::after {
  content: "";
  position: absolute;
  top: var(--pad);
  left: var(--pad);
  width: calc(var(--h) - var(--pad)*2);
  height: calc(var(--h) - var(--pad)*2);
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(16,24,40,0.12);
  transition: transform 180ms ease, background 180ms ease;
  transform: translateX(0);
}

/* checked state (dark) */
.theme-toggle input:checked + .toggle-track {
  background: linear-gradient(90deg, var(--primary), var(--primary-600));
}
.theme-toggle input:checked + .toggle-track::after {
  transform: translateX(calc(var(--w) - var(--h)));
  background: white;
}
