/* ========== Theme:  To Do style ========== */
:root{
  --background-color:#f3f3f8;
  --primary-color:#2564cf;
  --primary-hover:#1d4fb7;
  --accent-color:#5c9cff;
  --text-color:#111827;
  --muted-text:#6b7280;
  --border-color:#e5e7eb;
  --card-bg:#ffffff;
  --button-bg:#ffffff;
  --inprogress-bg:#fff8db;
  --inprogress-border:#f6c744;
  --inprogress-text:#8a6d1a;
}

/* Base */
html,body{
  margin:0;
  padding:0;
  background:var(--background-color);
  color:var(--text-color);
  font-family:"Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol", sans-serif;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

/* Header */
.header{
  background:var(--primary-color);
  color:#fff;
  border-bottom:1px solid rgba(255,255,255,.15);
  position:sticky;
  top:0;
  z-index:1000;
}
.header .container{
  max-width:1100px;
  margin:0 auto;
  padding:10px 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.header .logo{
  display:flex;
  align-items:center;
  gap:10px;
}
.header .logo img{
  height:36px;
  width:auto;
  display:block;
}
.header .logo span{
  font-weight:700;
  font-size:18px;
  letter-spacing:.2px;
}

/* Header links area */
#app-header-links{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
}
#app-header-links a{
  color:#fff;
  text-decoration:none;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.25);
  transition:all .2s ease;
}
#app-header-links a:hover{
  background:rgba(255,255,255,.12);
}

/* Burger */
.burger{
  display:none;
  background:transparent;
  border:0;
  color:#fff;
  font-size:22px;
  line-height:1;
  padding:6px 10px;
  border-radius:8px;
  cursor:pointer;
}
.burger:focus{ outline:2px solid #fff; outline-offset:2px; }

/* Desktop: links visible and centered, burger hidden */
@media(min-width:769px){
  .header .container{ justify-content:space-between; }
  #app-header-links{ display:flex !important; }
  .burger{ display:none; }
}

/* Mobile: links collapsed by default, burger visible */
@media(max-width:768px){
  .burger{ display:inline-flex; align-items:center; justify-content:center; }
  #app-header-links{ display:none; width:100%; }
  #app-header-links.active{
    display:flex;
    flex-direction:column;
    align-items:stretch;
    gap:8px;
    margin-top:8px;
  }
  #app-header-links a{
    background:rgba(255,255,255,.10);
    border-color:rgba(255,255,255,.2);
  }
}

/* Buttons */
.button, .button-danger{
  background:var(--primary-color);
  color:#fff;
  border:none;
  padding:10px 16px;
  border-radius:10px;
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  transition:background-color .2s, transform .05s ease-in;
  box-shadow:0 2px 6px rgba(0,0,0,.06);
}
.button:hover{ background:var(--primary-hover); }
.button:active{ transform:scale(.98); }

.button-danger{ background:#d9534f; }
.button-danger:hover{ background:#c9302c; }

/* Containers */
.main-container{ max-width:1100px; margin:0 auto; padding:12px; }
.content-container{ display:flex; gap:16px; }
.tasks-content{ flex:1; }

.categories{
  display:flex; flex-wrap:wrap; justify-content:center; gap:10px;
  margin-bottom:20px; padding:10px; background:#fff;
  border:1px solid var(--border-color); border-radius:12px;
  box-shadow:0 2px 8px rgba(0,0,0,.06);
}
.categories select{ max-width:100%; width:100%; padding:10px; border-radius:10px; border:1px solid var(--border-color); background:#fff; }

/* Lists */
ul.tasks{ list-style:none; margin:0; padding:0; }

/* Task row */
.task-item{
  display:grid;
  grid-template-columns:auto 1fr auto auto;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border:1px solid var(--border-color);
  border-radius:14px;
  background:var(--card-bg);
  margin:10px 0;
  box-shadow:0 2px 8px rgba(0,0,0,.06);
  transition:background-color .25s, border-color .25s, opacity .2s;
  position:relative;
}

/* 4) Fade completed */
.task-item.complete{
  opacity:.5;
}

/* Text and date */
.task-text{ word-break:break-word; overflow-wrap:anywhere; }
.task-due-date{
  font-size:12px;
  color:var(--muted-text);
  white-space:nowrap;
}

/* Actions */
.task-actions{ display:inline-flex; gap:8px; align-items:center; }
.task-actions button{
  display:inline-flex; align-items:center; justify-content:center;
  width:34px; height:34px; border-radius:10px;
  border:1px solid var(--border-color); background:var(--button-bg);
  cursor:pointer; transition:transform .05s ease-in, background .2s;
}
.task-actions button:hover{ background:#f7f7fb; }
.task-actions button:active{ transform:scale(.96); }
.task-actions i{ pointer-events:none; }

/* Checkbox: square and crisp */
.task-item input[type="checkbox"].complete-checkbox{
  padding:0 !important; margin:0;
  min-width:18px !important; min-height:18px !important;
  width:18px !important; height:18px !important; max-width:18px !important; max-height:18px !important;
  aspect-ratio:1/1; box-sizing:border-box; line-height:0; flex:0 0 auto; vertical-align:middle;
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  border:2px solid #555; border-radius:4px; background:#fff; cursor:pointer; position:relative;
}
.task-item input[type="checkbox"].complete-checkbox:focus{ outline:2px solid #0078d4; outline-offset:2px; }
.task-item input[type="checkbox"].complete-checkbox:checked{
  background-color:#0078d4; border-color:#0078d4;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l3 3 7-7' stroke='%23fff' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:center; background-size:12px 12px;
}

/* Dragging */
.task-item.dragging{ opacity:.6; box-shadow:0 4px 12px rgba(0,0,0,.15); }
.task-item{ cursor:grab; }
.task-item:active{ cursor:grabbing; }

.task-placeholder{
  border:2px dashed #0078d4; border-radius:10px; height:52px; margin:6px 0;
  background:#f0f8ff; display:flex; align-items:center; justify-content:center; color:#0078d4; font-style:italic;
}
.task-placeholder::before{ content:"Drop here"; }

/* In-progress highlight preserved */
.task-item.in-progress:not(.complete){
  background:var(--inprogress-bg);
  border-color:var(--inprogress-border);
}
.task-item.in-progress:not(.complete)::before{
  content:"";
  position:absolute; left:0; top:0; bottom:0; width:4px;
  border-top-left-radius:14px; border-bottom-left-radius:14px;
  background:linear-gradient(180deg,#ffd84d,#f6c744);
}
.task-item.in-progress:not(.complete) .task-due-date{ color:var(--inprogress-text); }
.task-item.in-progress:not(.complete) .bulb-btn{ border-color:#f1c40f; background:#fff3c4; }
.task-item.in-progress:not(.complete) .bulb-btn i{ color:#8a6d1a; }
.task-item.in-progress:not(.complete) .complete-checkbox{ border-color:#d4a017; background-color:#fffbea; }

/* Notes popup */
.popup-overlay{
  position:fixed; inset:0; display:none; align-items:center; justify-content:center;
  background:rgba(0,0,0,.45); z-index:10000;
}
.popup-content{
  width:min(560px,92vw); max-height:80vh; overflow:hidden;
  background:var(--card-bg); color:var(--text-color);
  border:1px solid var(--border-color); border-radius:12px;
  box-shadow:0 12px 30px rgba(0,0,0,.25);
  padding:16px; display:flex; flex-direction:column; gap:12px;
}
.popup-title{ margin:0 0 4px 0; font-size:18px; font-weight:600; }
#note-text{
  width:100%; min-height:200px; max-height:60vh; resize:vertical;
  padding:10px; border:1px solid var(--border-color); border-radius:8px;
  background:var(--card-bg); color:var(--text-color);
}
.popup-actions{ display:flex; gap:8px; justify-content:flex-end; }
.popup-actions .btn{ border:1px solid var(--border-color); background:var(--button-bg); padding:8px 12px; border-radius:8px; cursor:pointer; }

/* Dark mode variants */
body[data-theme="dark"]{
  --background-color:#0f172a;
  --text-color:#f5f5f5;
  --border-color:#374151;
  --card-bg:#111827;
  --button-bg:#0b1222;
}
body[data-theme="dark"] .header{ border-color:rgba(255,255,255,.15); }
body[data-theme="dark"] .categories{ background:#0b1222; border-color:#374151; }
body[data-theme="dark"] .task-actions button{ border-color:#374151; background:#0b1222; }
body[data-theme="dark"] .popup-content{ background:#1f2937; color:#f5f5f5; border-color:#374151; box-shadow:0 12px 30px rgba(0,0,0,.6); }
body[data-theme="dark"] #note-text{ background:#111827; color:#f5f5f5; border-color:#374151; }
body[data-theme="dark"] .popup-actions .btn{ background:#111827; border-color:#374151; }
body[data-theme="dark"] .task-item.in-progress:not(.complete){ background:#3a341a; border-color:#b28a00; }
body[data-theme="dark"] .task-item.in-progress:not(.complete)::before{ background:linear-gradient(180deg,#e3b400,#b28a00); }
body[data-theme="dark"] .task-item.in-progress:not(.complete) .task-due-date{ color:#e8c058; }
body[data-theme="dark"] .task-item.in-progress:not(.complete) .bulb-btn{ background:#4a3e16; border-color:#b28a00; }
body[data-theme="dark"] .task-item.in-progress:not(.complete) .bulb-btn i{ color:#e8c058; }
body[data-theme="dark"] .task-item.in-progress:not(.complete) .complete-checkbox{ background-color:#3b3416; border-color:#b28a00; }

/* Mobile tweaks */
@media(max-width:768px){
  html,body{ overflow-x:hidden; }
  .content-container{ display:block; }

  .task-item{
    grid-template-columns:auto 1fr auto;
    grid-template-areas:
      "cb text actions"
      "date text actions";
    row-gap:6px; padding:12px;
  }
  .complete-checkbox{ grid-area:cb; }
  .task-text{ grid-area:text; }
  .task-due-date{ grid-area:date; font-size:12px; }
  .task-actions{ grid-area:actions; gap:6px; }
  .task-actions button{ width:36px; height:36px; }

  .add-task-container form{ flex-wrap:wrap; }
  .add-task-container input[type="text"],
  .add-task-container select,
  .add-task-container textarea{
    width:100% !important; min-height:44px;
  }
  .add-task-button, .bulk-task-button, .button, .button-danger{
    width:auto; min-height:44px;
  }
}

/* Tap highlight removal */
*{ -webkit-tap-highlight-color: rgba(0,0,0,0); }
/* ===== Category page polish ===== */
.category-page { max-width: 900px; margin: 0 auto; padding: 12px; }
.category-hero {
  display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between;
  gap:10px; margin: 6px 0 12px;
}
.category-title {
  font-size: 1.6rem; font-weight: 700; margin: 0;
}
.category-toolbar {
  display:flex; align-items:center; gap:12px; flex-wrap:wrap;
  background: var(--card-bg); border:1px solid var(--border-color);
  border-radius: 12px; padding: 8px 10px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.category-toolbar .switch { transform: scale(0.95); }

.add-task-card{
  background: var(--card-bg);
  border:1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.add-task-inline{
  display:flex; gap:10px; align-items:center; flex-wrap:wrap;
}
.add-task-inline input[type="text"], .add-task-inline select{
  padding:10px; border:1px solid var(--border-color); border-radius:10px; background: var(--card-bg);
}
.add-task-inline .button{ padding:10px 16px; }

.task-section { margin-top: 6px; }
.no-tasks-message{
  background: var(--card-bg); border:1px solid var(--border-color);
  border-radius: 12px; padding: 20px; text-align:center;
  color: var(--muted-text);
}

/* On single-category view, make list a bit tighter */
body[data-view="list"] ul.tasks .task-item { margin: 8px 0; }
/* ===== Mobile task row fix ===== */
@media (max-width: 480px) {
  /* Put actions on their own row so text has room */
  .task-item {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "cb text"
      "date text"
      "actions actions";
    align-items: start;
    row-gap: 6px;
    padding: 10px 10px 12px;
  }

  .task-item input[type="checkbox"].complete-checkbox {
    min-width: 16px !important;
    min-height: 16px !important;
    width: 16px !important;
    height: 16px !important;
    border-radius: 4px;
    margin-top: 2px;
  }

  .task-text {
    font-size: 15px;
    line-height: 1.3;
  }

  .task-due-date {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 2px;
  }

  .task-actions {
    grid-area: actions;
    width: 100%;
    justify-content: flex-end;   /* push buttons to the right */
    gap: 6px;
  }

  .task-actions button {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }

  /* Keep the “in progress” highlight tidy on small screens */
  .task-item.in-progress:not(.complete)::before { width: 3px; }
}

/* ===== Mobile: compact actions with More menu ===== */
@media (max-width: 480px) {
  .task-item {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "cb text"
      "date text"
      "actions actions";
    align-items: start;
    row-gap: 6px;
    padding: 10px 10px 12px;
  }

  .task-actions {
    grid-area: actions;
    position: relative;
    display: inline-flex;
    gap: 6px;
    justify-content: flex-end;
    width: 100%;
  }

  /* Keep these two visible */
  .task-actions .edit-btn,
  .task-actions .bulb-btn {
    display: inline-flex;
  }

  /* These move into the More menu (hidden inline on mobile) */
  .task-actions .note-btn,
  .task-actions .delete-btn {
    display: none;
  }

  .task-actions .more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--button-bg, #fff);
    cursor: pointer;
  }

  .task-actions .more-menu {
    position: absolute;
    right: 0;
    bottom: 38px; /* pops above the buttons row */
    display: none;
    gap: 6px;
    padding: 6px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    z-index: 1000;
  }
  .task-actions .more-menu .icon-btn,
  .task-actions .more-menu .note-btn,
  .task-actions .more-menu .delete-btn {
    width: 34px; height: 34px; border-radius: 8px;
    display: inline-flex; align-items:center; justify-content:center;
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--button-bg, #fff);
  }
  .task-actions .more-menu.show { display: inline-flex; }
}

/* Desktop/tablet: ensure everything is visible inline */
@media (min-width: 481px) {
  .task-actions .more-btn,
  .task-actions .more-menu { display: none !important; }
  .task-actions .note-btn,
  .task-actions .delete-btn { display: inline-flex; }
}

/* ===== Move action + popover ===== */
.task-actions .move-btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px; border: 1px solid var(--border-color, #e5e7eb);
  background: var(--button-bg, #fff); cursor: pointer;
}

.move-popover {
  position: absolute;
  right: 0;
  bottom: 40px;
  z-index: 1000;
  display: none;
  background: var(--card-bg, #fff);
  color: var(--text-color, #111);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: 8px;
  gap: 8px;
}
.move-popover.show { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.move-popover select {
  min-width: 200px;
  padding: 8px; border-radius: 8px; border:1px solid var(--border-color);
  background: var(--card-bg); color: var(--text-color);
}
.move-popover .button { padding: 8px 12px; }

/* Mobile: put Move under _ More; desktop shows inline */
@media (max-width: 480px) {
  .task-actions .move-btn { display: none; }
}
@media (min-width: 481px) {
  .task-actions .more-menu .move-btn { display: none !important; }
}
/* ===== Move action + popover ===== */
.task-actions .move-btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px; border: 1px solid var(--border-color, #e5e7eb);
  background: var(--button-bg, #fff); cursor: pointer;
}

.move-popover {
  position: absolute;
  right: 0;
  bottom: 40px;
  z-index: 1000;
  display: none;
  background: var(--card-bg, #fff);
  color: var(--text-color, #111);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: 8px;
  gap: 8px;
}
.move-popover.show { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.move-popover select {
  min-width: 200px;
  padding: 8px; border-radius: 8px; border:1px solid var(--border-color);
  background: var(--card-bg); color: var(--text-color);
}
.move-popover .button { padding: 8px 12px; }

/* Mobile: put Move under ⋯ More; desktop shows inline */
@media (max-width: 480px) {
  .task-actions .move-btn { display: none; }
}
@media (min-width: 481px) {
  .task-actions .more-menu .move-btn { display: none !important; }
}

/* Fix: show Move inside the More popover on mobile */
@media (max-width: 480px) {
  .task-actions .more-menu .move-btn {
    display: inline-flex !important; /* override the mobile hide */
  }
}
/* Move task dropdown styling */
.move-dropdown {
    background: #fff;
    border: 1px solid #ccc;
    padding: 5px;
    border-radius: 5px;
    z-index: 1000;
}

[data-theme="dark"] .move-dropdown {
    background: #333;
    border: 1px solid #666;
}

.move-dropdown button {
    background: #0078d4;
    color: #fff;
    border: none;
    padding: 5px 10px;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
}

.move-dropdown button:hover {
    background: #0056a3;
}
/* Move text link/icon */
.move-btn {
    color: #0078d4; /* Blue in light mode */
    cursor: pointer;
}

[data-theme="dark"] .move-btn {
    color: #f5f5f5; /* White in dark mode */
}

.move-btn:hover {
    opacity: 0.8;
}
/* Move popover styling */
.move-popover {
  position: absolute;
  top: 40px;
  right: 0;
  display: none;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,.15);
  padding: 8px;
  z-index: 10000;
}
.move-popover.show { display: flex; }

/* Make the “Move” confirm button visible */
.move-popover .button {
  background: #0078d4;
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 8px;
font-weight: 200;
  cursor: pointer;
}
.move-popover .button:hover { background: #005fb0; }

/* Dark mode */
[data-theme="dark"] .move-popover {
  background: #1f2937;
  border-color: #374151;
}
[data-theme="dark"] .move-popover .button {
  background: #2563eb;
  color: #fff;
}

/* Ensure Move appears inside the ⋯ menu on phones */
@media (max-width: 480px) {
  .task-actions .more-menu .move-btn {
    display: inline-flex !important;
  }
}
.move-popover select:disabled { opacity: .6; }
.move-popover .button:disabled { opacity: .6; cursor: not-allowed; }

/* === Board (Google Keep–style) layout for All Tasks === */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
}

.list-column {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
  padding: 12px;
}

[data-theme="dark"] .list-column {
  background: #111827;
  border-color: #374151;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.list-header a {
  font-weight: 700;
  text-decoration: none;
  color: var(--text-color, #111);
}

[data-theme="dark"] .list-header a {
  color: #f5f5f5;
}

.list-count {
  font-size: 12px;
  opacity: .7;
}

/* Make task list inside columns breathe a bit */
.list-column ul.tasks {
  margin: 0;
  padding: 0;
}

/* Keep mobile single column */
@media (max-width: 768px) {
  .board-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Google Keep–style masonry board --- */
.board-masonry{
  /* Automatically chooses how many columns fit the width */
  column-width: 340px;       /* target card width */
  column-gap: 16px;          /* space between columns */
  padding: 8px 8px 0;
}

@media (max-width: 1200px){
  .board-masonry{ column-width: 300px; }
}
@media (max-width: 900px){
  .board-masonry{ column-width: 260px; }
}
@media (max-width: 700px){
  .board-masonry{ column-width: 100%; } /* single column on phones */
}

/* Each category list acts as a single "card" in the masonry */
.list-column{
  display: inline-block;     /* let cards flow into columns */
  width: 100%;
  margin: 0 0 16px;          /* vertical spacing between cards */
  break-inside: avoid;       /* prevent card splitting across columns */
  -webkit-column-break-inside: avoid;
  -moz-column-break-inside: avoid;
  /* keep your existing styling (bg, border, shadow) intact */
}

/* Optional: tighten header spacing so cards feel compact */
.list-header{
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 6px;
}

/* Ensure inner UL doesn't add extra side spacing */
.list-column > .tasks{
  padding: 6px 12px 12px;
  margin: 0;
}
.list-column { display:block; margin:0 0 16px; }
