/* -------------------- Base Reset -------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Nunito", sans-serif;
}

body {
  background: var(--base-color);
}

button,
input,
textarea {
  font: inherit;
}

button {
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap; /* NEW: prevents squish/wrap on small screens */
}

h1 {
  font-weight: 1000;
  color: var(--text-color);
}

/* -------------------- Color Variables -------------------- */
:root {
  --brand-color: #10b981;
  --base-color: #f0f0f0;
  --bar-color: hsl(0, 0%, 94%);
  --surface-color: hsl(0, 0%, 100%);
  --text-color: #1f2937;
  --secondary-text-color: #4b5563;
  --hover-color: #059669;
  --base-transparent-90: rgba(255, 255, 255, 0.9);
  --base-transparent-100: rgba(255, 255, 255, 1);
}

.dark-theme {
  --brand-color: #34d399;
  --base-color: hsl(216, 12%, 8%);
  --bar-color: hsl(215, 28%, 12%);
  --surface-color: hsl(215, 28%, 17%);
  --text-color: #e5e7eb;
  --secondary-text-color: #9ca3af;
  --hover-color: #10b981;
  --base-transparent-90: rgba(18, 20, 23, 0.9);
  --base-transparent-100: rgba(18, 20, 23, 1);
}

/* -------------------- Layout -------------------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.5rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.72rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.header-buttons {
  display: flex;
  align-items: center;
}

#userInfo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
  gap: 1.8rem;
  padding: 0rem 1rem;
}

.note-grid {
  display: grid;
}

.dialog-actions {
  display: flex;
  justify-content: end;
  gap: 0.6rem;
}

/* Responsive stack layout on small screens */
@media (max-width: 600px) {
  header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
  }

  .header-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    gap: 0.6rem;
  }

  .header-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .header-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;

    /* avoid ugly wraps—let the row scroll horizontally */
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .header-right::-webkit-scrollbar {
    display: none;
  }

  h1 {
    margin: 0;
  }

  .notes-grid {
    grid-template-columns: 1fr; /* single column */
  }

  .note-card {
    min-width: auto; /* override fixed 400px */
  }
}

/* -------------------- Buttons -------------------- */
.add-note-btn,
.theme-toggle-btn {
  padding: 0.96rem;
  background: var(--brand-color);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 1.2rem;
  min-height: 40px;
}

.theme-toggle-btn {
  margin-left: 1rem;
  background: var(--surface-color);
}

.theme-toggle-btn:hover {
  background: var(--brand-color);
}

.add-note-btn:hover,
.theme-toggle-btn:hover,
.cancel-btn:hover,
.save-btn:hover,
#loginBtn:hover {
  background: var(--hover-color);
}

.dialog-actions button {
  padding: 0.84rem;
  border: none;
  border-radius: 8px;
}

.cancel-btn {
  background: var(--base-color);
  color: var(--text-color);
}

.save-btn {
  color: white;
  background: var(--brand-color);
}

.close-btn {
  border: none;
  background: var(--surface-color);
  cursor: pointer;
  color: var(--text-color);
  font-weight: 600;
  font-size: 1.92rem;
}

#authSection button {
  padding: 0.84rem;
  background: var(--brand-color);
  border: none;
  border-radius: 12px;
  color: white;
  font-weight: 550;
  justify-content: end;
  min-height: 40px;
}

/* -------------------- Dialog -------------------- */
#noteDialog {
  margin: auto;
  max-width: 500px;
  width: 90vw;
  border: none;
  border-radius: 20px;
  color: var(--text-color);
  background: var(--surface-color);
}

#noteDialog::backdrop {
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(4px);
}

.dialog-content {
  padding: 2.4rem;
  margin: 0;
}

@media (max-width: 480px) {
  .dialog-content {
    padding: 1.4rem;
  }
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.dialog-title {
  font-size: 1.92rem;
  font-weight: 600;
}

/* -------------------- Forms -------------------- */
.form-group {
  margin-bottom: 1.5rem;
  display: grid;
}

.form-label {
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 1.32rem;
}

.form-input,
.form-textarea {
  border: none;
  border-radius: 8px;
  background: var(--base-color);
  margin-left: 0.1rem;
  border: 2px solid var(--surface-color);
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--brand-color);
}

.form-input {
  padding: 1.2rem 0.5rem;
  color: var(--text-color);
}

.form-textarea {
  padding: 1.2rem 0.5rem;
  height: 20rem;
  color: var(--text-color);
}

.form-textarea::-webkit-scrollbar {
  width: 6px;
}

.form-textarea::-webkit-scrollbar-thumb {
  background: var(--secondary-text-color);
  border-radius: 4px;
}

/* -------------------- Notes -------------------- */
.note-card {
  background: var(--surface-color);
  border-radius: 10px;
  position: relative;
  color: var(--text-color);
  border: 1px solid var(--surface-color);
  overflow: hidden;
}

.note-card:hover {
  transform: scale(1.02);
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.note-card:hover .note-actions {
  opacity: 1;
  visibility: visible;
}

/* NEW: on touch devices (no hover), keep actions visible */
@media (hover: none) {
  .note-actions {
    visibility: visible;
    opacity: 1;
  }
  .drag-bar {
    display: none;
  }
}

.note-card-text {
  padding: 0rem 2rem;
  margin-bottom: 3rem;
}

.note-title {
  font-size: 1.4rem;
  margin-bottom: 0.7rem;
  word-wrap: break-word;
}

.note-content {
  font-size: 1.2rem;
  color: var(--secondary-text-color);
  word-wrap: break-word;
  white-space: pre-wrap;
}

.note-actions {
  padding: 0.48rem 0.6rem;
  margin-bottom: 0.2rem;
  background: var(--bar-color);
  border-radius: 10px;
  visibility: hidden;
  display: flex;
  justify-content: space-between;
}

.note-actions button {
  border: none;
  background: transparent;
  color: var(--text-color);
}

.note-actions:hover {
  cursor: grab;
}

.edit-btn:hover,
.delete-btn:hover {
  transform: scale(1.1);
}

.drag-bar {
  width: 40%;
  height: 6px;
  background: var(--secondary-text-color);
  border-radius: 4px;
  margin-bottom: 6px;
  cursor: grab;
  align-self: center;
}

.note-scroll {
  overflow-y: auto;
  max-height: 300px;
  position: relative;
  padding-right: 8px;
}

.note-scroll::-webkit-scrollbar {
  width: 6px;
}

.note-scroll::-webkit-scrollbar-thumb {
  background: var(--secondary-text-color);
  border-radius: 4px;
}

/* -------------------- Sortable -------------------- */
.sortable-chosen {
  transform: rotate(2deg) scale(1.03);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  opacity: 0.95;
}

.sortable-ghost {
  opacity: 0.2;
}

/* -------------------- Tags -------------------- */
.tag-input-container {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tag-input-wrapper {
  position: relative;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.36rem;
}

.tag-pill {
  background: var(--brand-color);
  color: white;
  padding: 0.36rem 0.6rem;
  border-radius: 1rem;
  font-size: 1.08rem;
  display: flex;
  align-items: center;
  gap: 0.36rem;
}

.tag-pill .remove-tag {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-weight: bold;
}

/* -------------------- Tag Suggestions -------------------- */
.tag-suggestions {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--bar-color);
  border-radius: 6px;
  z-index: 100;
  max-height: 150px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tag-suggestions li {
  padding: 0.6rem 0.75rem;
  cursor: pointer;
}

.tag-suggestions li:hover {
  background-color: var(--hover-color);
  color: white;
}

/* -------------------- Tag Filters -------------------- */
.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.2rem 1rem 0.5rem;
}

/* on phones, make filters a single horizontal row that scrolls */
@media (max-width: 600px) {
  .tag-filters {
    margin: 0.8rem 0.6rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tag-filters::-webkit-scrollbar {
    display: none;
  }
}

.filter-pill {
  background-color: var(--surface-color);
  color: var(--text-color);
  border-radius: 999px;
  padding: 0.48rem 0.8rem;
  margin: 0.24rem;
  cursor: pointer;
  font-size: 1.02rem;
  transition:
    background-color 0.2s,
    color 0.2s,
    border-color 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  white-space: nowrap;
}

.filter-pill.active {
  background: var(--brand-color);
  color: var(--text-color);
  border-color: var(--brand-color);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.filter-pill:hover {
  background: var(--hover-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

/* ===== Hamburger menu polish ===== */
.menu {
  position: relative;
  display: none;
}
.menu-toggle {
  background: var(--surface-color);
  color: var(--text-color);
  border: none;
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  font-weight: 700;
  line-height: 1;
  min-height: 40px;
  cursor: pointer;
}

/* Panel */
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--surface-color);
  color: var(--text-color);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  padding: 0.35rem;
  min-width: 75px;
  display: none;
  z-index: 9999;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
}
.menu-panel.open {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.menu-item {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.4rem;

  background: transparent;
  border: none;
  color: var(--text-color);

  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  line-height: 1.3;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;

  margin-bottom: 0.35rem;
}

.menu-item:last-child {
  margin-bottom: 0;
}

.menu-item:hover {
  background: var(--bar-color);
}

/* Phones: show hamburger, hide standalone theme/logout; avoid clipping */
@media (max-width: 600px) {
  #themeToggleBtn,
  #logoutBtn {
    display: none;
  }
  .header-right .menu {
    display: block;
  }

  .header-right {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
  }
  .header-right::-webkit-scrollbar {
    display: none;
  }

  /* Use fixed so panel never gets cut off */
  .menu-panel {
    position: fixed;
    right: 1rem;
    z-index: 99999;
  }
}

/* Desktop: keep hamburger hidden /
@media (min-width: 601px){ .header-right .menu { display:none; } }




/* -------------------- Empty State -------------------- */
.empty-state {
  margin-left: 3%;
  display: inline-block;
  border-radius: 9px;
  padding: 3.6rem 2rem;
  text-align: center;
  color: var(--secondary-text-color);
}

/* NEW: center and scale better on phones */
@media (max-width: 600px) {
  .empty-state {
    margin-left: 0;
    display: block;
    padding: 2rem 1rem;
  }
}

.empty-state h2 {
  font-size: 1.92rem;
  margin-bottom: 0.8rem;
}

.empty-state p {
  font-size: 1.2rem;
  margin-bottom: 1.4rem;
}
