/* Layout applies to both modes */
body {
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  transition: background 0.3s, color 0.3s;
}

/* Dark mode (default) */
body.dark-mode {
  background: #121212;
  color: #f7f9fb;
}

/* Light mode */
body.light-mode {
  background: #f7f9fb;
  color: #333;
}

/* Headings */
h1 {
  margin-bottom: 1rem;
  font-weight: 700;
}

/* Main container: left + right columns */
.main-content {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  width: 100%;
  max-width: 980px;
  flex-wrap: wrap; /* stacks on mobile */
}

/* Left column: text area + info box stacked */
.left-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

/* Info box around stats and controls */
.info-box {
  width: 100%;
  max-width: 720px;
  background: #1b1b1b;
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: background 0.3s, color 0.3s;
}

/* Light mode for info-box */
body.light-mode .info-box {
  background: #ffffff;
  color: #333;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* Textarea */
textarea {
  width: 100%;
  max-width: 720px;
  height: 220px;
  padding: 1rem;
  border-radius: 10px;
  font-size: 1rem;
  resize: vertical;
  outline: none;
  transition: background 0.3s, color 0.3s, border 0.3s, box-shadow 0.2s;
  border: 1px solid transparent;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

body.dark-mode textarea {
  background: #1b1b1b;
  color: #f7f9fb;
  border-color: #2a2a2a;
}
body.light-mode textarea {
  background: #ffffff;
  color: #222;
  border-color: #d0d0d0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* Stats */
.stats {
  margin-top: 0;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-weight: 600;
  justify-content: center;
}

.stat {
  min-width: 180px;
  text-align: center;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  transition: background 0.3s, color 0.3s, box-shadow 0.3s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

body.dark-mode .stat { background: #1b1b1b; color: #f7f9fb; }
body.light-mode .stat { background: #ffffff; color: #333; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

/* Controls */
.controls {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  align-items: center;
  width: 100%;
}

/* Goal input */
.goal {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.goal label { font-size: 0.9rem; opacity: 0.9; }
.goal input {
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  transition: background 0.3s, color 0.3s, border 0.2s, box-shadow 0.2s;
}
body.dark-mode .goal input { background: #1b1b1b; color: #f7f9fb; border-color: #2a2a2a; }
body.light-mode .goal input { background: #ffffff; color: #222; border-color: #d0d0d0; }

/* Progress bar */
.progress-wrap { display: flex; flex-direction: column; gap: 0.5rem; }
.progress-track {
  width: 100%;
  height: 12px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.35);
}
body.light-mode .progress-track {
  background: rgba(0,0,0,0.08);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7aa5ff, #5fe1b7);
  transition: width 0.25s ease;
}
.progress-label { font-size: 0.85rem; opacity: 0.9; }

/* Buttons */
.buttons {
  margin-top: 1.2rem;
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}
button {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s, color 0.2s, transform 0.05s;
}
button:active { transform: translateY(1px); }
body.dark-mode #toggleTheme { background: #2a2a2a; color: #f7f9fb; }
body.dark-mode #clearData  { background: #3a3a3a; color: #f7f9fb; }
body.light-mode #toggleTheme { background: #e6e6e6; color: #222; }
body.light-mode #clearData  { background: #dcdcdc; color: #222; }

/* Footer */
footer {
  margin-top: 1.6rem;
  font-size: 0.85rem;
  text-align: center;
  opacity: 0.8;
}

/* Most used words box */
.most-used-box {
  width: 260px;
  background: #1b1b1b;
  color: #f7f9fb;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  flex-shrink: 0;         /* prevent shrinking */
  margin-left: 2.5rem;    /* small space from left column */
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  transition: background 0.3s, color 0.3s;
}

body.light-mode .most-used-box {
  background: #ffffff;
  color: #222;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.most-used-box h2 {
  margin: 0;
  font-size: 1.1rem;
  text-align: center;
  font-weight: 700;
}

.most-used-box ul {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 200px;
  overflow-y: auto;
}

.most-used-box li {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0.4rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 0.9rem;
}

body.light-mode .most-used-box li {
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

/* Word search inside most used box */
.word-search {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.word-search input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #2a2a2a;
  background: #1b1b1b;
  color: #f7f9fb;
  font-size: 0.9rem;
}

body.light-mode .word-search input {
  background: #f7f7f7;
  border-color: #ccc;
  color: #222;
}

#searchResult {
  font-weight: 700;
  min-width: 25px;
  text-align: right;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .most-used-box {
    width: 100%;
    max-width: 720px;
    margin-left: 0; /* remove extra margin on mobile */
  }
}
