* {
  box-sizing: border-box;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  margin: 0;
  font-family: Arial, sans-serif;
  color: #222;
  background: #f4f4f4;
}

button,
input {
  font: inherit;
}

button {
  /* padding: 8px 10px; */
  font-size: 13px;
  color: #333;
  cursor: pointer;
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
}

button:hover {
  background: #f4f4f4;
}

button.danger-button {
  color: #dc3545;
  border-color: #dc3545;
}

button.danger-button:hover {
  color: white;
  background: #dc3545;
}

.popup {
  width: 100%;
  /* max-width: 900px; */
  padding: 40px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ======================================== */
/* GENERAL */
/* ======================================== */

h1 {
  margin: 0;
  font-size: 26px;
  text-align: center;
}

h2 {
  margin: 0;
  font-size: 20px;
}

h3 {
  margin: 0;
  font-size: 16px;
}

.page-description,
.section-description {
  margin: 8px 0 0;
  font-size: 14px;
  color: #777;
}

.page-description {
  text-align: center;
}

/* ======================================== */
/* HOME / GROUPS */
/* ======================================== */

.groups-header {
  padding-bottom: 25px;
  border-bottom: 1px solid #eee;
}

.groups-section {
  margin-top: 25px;
}

#groups {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* Group link */

.group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  color: #333;
  text-decoration: none;
  background: #f4f4f4;
  border: 1px solid transparent;
  border-radius: 8px;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

.group-item:hover {
  background: #e9f2ff;
  border-color: #007bff;
  transform: translateY(-1px);
}

.group-name {
  font-size: 17px;
  font-weight: bold;
}

.group-arrow {
  font-size: 20px;
  color: #777;
}

/* Create group */

.create-group-section {
  padding-top: 25px;
  margin-top: 30px;
  border-top: 1px solid #eee;
}

.create-group-section h2 {
  margin-bottom: 15px;
  font-size: 18px;
}

#groupForm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#groupForm label {
  font-size: 14px;
  font-weight: bold;
}

#groupForm input {
  width: 100%;
  padding: 11px 12px;
  outline: none;
  border: 1px solid #ccc;
  border-radius: 8px;
}

#groupForm input:focus {
  border-color: #007bff;
}

#groupForm button {
  padding: 11px;
  margin-top: 2px;
  font-weight: bold;
  color: white;
  background: #007bff;
  border: none;
  border-radius: 8px;
}

#groupForm button:hover {
  background: #0056b3;
}

/* ======================================== */
/* GROUP HEADER */
/* ======================================== */

.group-header {
  padding-bottom: 25px;
  border-bottom: 1px solid #eee;
}

.back-link {
  display: inline-block;
  margin-bottom: 20px;
  font-size: 14px;
  color: #007bff;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

/* ======================================== */
/* TODOS */
/* ======================================== */

.todos-section {
  margin-top: 25px;
}

.todos-header {
  margin-bottom: 20px;
}

/* Two columns */

.todo-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Todo column */

.todo-column {
  min-width: 0;
  padding: 15px;
  background: #f8f8f8;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
}

.completed-column {
  background: #fafafa;
}

/* Column header */

.todo-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid #ddd;
}

.todo-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  font-size: 12px;
  font-weight: bold;
  color: #007bff;
  background: #e9f2ff;
  border-radius: 20px;
}

.completed-count {
  color: #198754;
  background: #e7f5ed;
}

/* Todo list */

.todo-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 25rem;
}

/* Todo */

.todo {
  /* position: relative; */
  padding: 12px;
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
}

.todo button {
  float: right;
}

.todo-label {
    display: grid;
    grid-template-columns: auto min-content;
}

.todo-label button {
    height: min-content;
}

.todo-main {
  display: inline-flex;
  gap: 9px;
  align-items: flex-start;
      margin-bottom: 0.5rem;
}

.todo-main input[type="checkbox"] {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: #007bff;
  cursor: pointer;
}

.todo-main label {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  cursor: pointer;
}

/* Completed todo */

.todo.completed {
  background: #f8f8f8;
}

.todo.completed .todo-main label {
  color: #888;
  text-decoration: line-through;
}

/* Tags underneath todo */

.todo-tag-group {
    display: grid;
    grid-template-columns: auto max-content;
}

.todo-tags {
  float: right;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  /* margin-bottom: 0.5rem; */
  margin-left: 26px;
}

.todo-tag-picker {
  position: relative;
  display: block;
}

.todo-tag-picker button {
    float: left;
}

.todo-tag-toggle {
  padding: 0;
  font-size: 0.85rem;
  color: #666;
  cursor: pointer;
  background: none;
  border: 0;
}

.todo-tag-toggle:hover {
  color: #222;
}

.todo-tag-menu {
  position: absolute;
  z-index: 10;
  min-width: 150px;
  padding: 0.6rem;
  margin-top: 1rem;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.todo-tag-menu label {
  display: block;
  padding: 0.25rem 0;
  cursor: pointer;
}

.todo-tag-menu input {
  margin-right: 0.4rem;
}

.tag {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  color: #555;
  background: #eee;
  border-radius: 20px;
}

/* Completed date */

.completed-date {
  margin-top: 9px;
  margin-left: 26px;
  font-size: 11px;
  color: #888;
}

/* Add todo */

.todo-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.todo-form label,
.tag-form label {
  font-size: 14px;
  font-weight: bold;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.input-row input:focus {
  border-color: #007bff;
}

.input-row button {
  padding: 11px 18px;
  font-size: 14px;
  font-weight: bold;
  color: white;
  background: #007bff;
  border: none;
  border-radius: 8px;
}

.input-row button:hover {
  background: #0056b3;
}

/* ======================================== */
/* TAGS */
/* ======================================== */

.tags-section {
  padding-top: 20px;
  margin-top: 30px;
  border-top: 1px solid #eee;
}

/* Toggle */

.tags-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 0;
  font-size: 17px;
  font-weight: bold;
  color: #333;
  text-align: left;
  background: transparent;
  border: none;
}

.tags-toggle:hover {
  color: #007bff;
}

.tags-arrow {
  font-size: 14px;
  color: #777;
  transition: transform 0.2s ease;
}

.tags-toggle[aria-expanded="true"] .tags-arrow {
  transform: rotate(90deg);
}

/* Panel */

.tags-panel {
  padding-top: 10px;
}

.tags-panel[hidden] {
  display: none;
}

/* Tag management */

.tag-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.tag-management-item {
  display: flex;
  gap: 8px;
}

.tag-management-item input {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  outline: none;
  border: 1px solid #ccc;
  border-radius: 7px;
}

.tag-management-item input:focus {
  border-color: #007bff;
}

.tag-management-item button {
  padding: 8px 10px;
}

/* ======================================== */
/* MOBILE */
/* ======================================== */

@media (max-width: 650px) {
  body {
    align-items: flex-start;
    padding: 10px;
  }

  .popup {
    padding: 25px 20px;
  }

  #groups {
    grid-template-columns: 1fr;
  }

  .todo-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 450px) {
  .input-row {
    flex-direction: column;
  }

  .input-row button {
    width: 100%;
  }

  .tag-management-item {
    flex-wrap: wrap;
  }

  .tag-management-item input {
    flex-basis: 100%;
  }

  .tag-management-item button {
    flex: 1;
  }
}
