@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  color: rgb(55, 53, 47);
  font-family: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  padding: 20px 30px;
}

header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-decoration: none;
  padding: 0px;
  margin: 0px;
}

.page-header-icon {
  font-size: 48px;
  margin-right: 10px;
}

.page-title {
  font-family: "Inter", sans-serif;
  font-size: 40px;
  font-weight: 700;
  margin: 0px;
}

hr {
  background: transparent;
  display: block;
  width: 100%;
  height: 1px;
  visibility: visible;
  border: none;
  border-bottom: 1px solid rgba(55, 53, 47, 0.345);
  margin-bottom: 18px;
}

.main-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

a {
  color: inherit;
  text-decoration: underline;
}

/* bookmark-sec */
.bookmark-sec {
  border-radius: 3px;
  padding: 12px 30px 26px 30px;
  display: flex;
  flex-direction: column;
}

.bookmark-heading {
  font-size: 26px;
  text-decoration: none;
  transition: opacity 0.3s ease;
}

.bookmark-heading:hover {
  opacity: 0.7;
}

.bookmark-heading h4 {
  margin: 0px 0px 0px 0px;
}

.bookmark-card-div {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  align-items: start;
}

.bookmark-card-div a {
  text-decoration: none;
  color: inherit;
}

.bookmark-card-wrapper {
  position: relative;
  width: 100%;
  /* Changed from fixed 160px */
  height: auto;
  /* Changed from fixed 290px */
}

.bookmark-card {
  width: 100%;
  /* Changed from fixed 160px */
  height: auto;
  /* Changed from fixed 290px */
  min-height: 320px;
  border: 1px solid #a5a5a5;
  border-radius: 2px;
  position: relative;
}

.bookmark-card.long-press-active {
  transform: scale(0.98);
  box-shadow: 0 0 0 2px rgba(80, 148, 110, 0.5);
  transition: all 0.2s ease;
}

/* Three-dot menu button */
.bookmark-menu-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #ddd;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  color: #555;
  z-index: 10;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.bookmark-card-wrapper:hover .bookmark-menu-btn,
.bookmark-menu-btn.active {
  opacity: 1;
}

.bookmark-menu-btn:hover {
  background: rgba(80, 148, 110, 0.9);
  color: white;
  border-color: rgba(80, 148, 110, 1);
}

.bookmark-menu-btn:active {
  transform: scale(0.95);
}

.bookmark-card-img {
  width: 100%;
  height: 85%;
}

.bookmark-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bookmark-info {
  padding: 12px 12px 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bookmark-title {
  font-weight: 700;
  font-size: 18px;
  margin: 0;
  color: #333;
  white-space: pre-wrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #555;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}

.card-link-item:hover {
  background-color: #f5f5f5;
  color: #000;
  text-decoration: none;
}

.card-link-icon {
  width: 16px;
  text-align: center;
}

/* Card Tags */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 12px 4px 12px;
  margin-top: auto;
}

.card-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  color: white;
  background-color: #2196f3;
  /* Default Blue */
}

.card-tag:nth-child(even) {
  background-color: #e91e63;
  /* Pink for variety */
}

.card-tag:nth-child(3n) {
  background-color: #9c27b0;
  /* Purple */
}

.bookmark-card-title {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 16px;
  text-decoration: none;
  padding: 0px 2px 0px 2px;
  height: 15%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bookmark-card-title p {
  font-size: 16px;
  text-decoration: none;
  padding: 0;
  margin: 0;
  white-space: wrap;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-self: start;
  /* text-overflow: ellipsis; */
}

.highlight-red {
  color: rgba(207, 81, 72, 1);
}

.highlight-blue {
  color: rgba(56, 125, 201, 1);
}

.highlight-teal {
  color: rgba(80, 148, 110, 1);
}

/* Block colors */
.bg-gray {
  background: rgba(240, 239, 237, 1);
}

.bg-red {
  background: rgba(252, 233, 231, 1);
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 30px;
  border: 1px solid #888;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: slideDown 0.3s ease;
}

.modal-small {
  max-width: 420px;
}

@keyframes slideDown {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 20px;
}

.close:hover,
.close:focus {
  color: #000;
}

.modal-content h2 {
  margin-top: 0;
  color: rgb(55, 53, 47);
  font-size: 28px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: rgb(55, 53, 47);
}

.form-group input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}

.form-group input:focus {
  outline: none;
  border-color: rgba(80, 148, 110, 1);
  box-shadow: 0 0 0 2px rgba(80, 148, 110, 0.2);
}

.form-buttons {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn-submit {
  flex: 1;
  padding: 12px;
  background-color: rgba(80, 148, 110, 1);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-submit:hover {
  background-color: rgba(60, 128, 90, 1);
}

.btn-submit:active {
  transform: scale(0.98);
}

.btn-delete {
  flex: 1;
  padding: 12px;
  background-color: rgba(207, 81, 72, 1);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-delete:hover {
  background-color: rgba(180, 60, 52, 1);
}

.btn-delete:active {
  transform: scale(0.98);
}

/* Scroll to top button */
.scroll-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  background-color: rgba(80, 148, 110, 1);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 999;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-to-top:hover {
  background-color: rgba(60, 128, 90, 1);
  transform: translateY(-3px);
}

.scroll-to-top:active {
  transform: translateY(-1px);
}

/* Clickable title effect */
.page-title:hover {
  color: rgba(80, 148, 110, 1);
  transition: color 0.3s ease;
}

/* --- New UI Components --- */

/* Tags Input */
.tags-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  min-height: 45px;
  background: white;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  background-color: #e0e0e0;
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 14px;
  color: #333;
}

.tag-chip .remove-tag {
  margin-left: 6px;
  cursor: pointer;
  font-weight: bold;
  color: #666;
}

.tag-chip .remove-tag:hover {
  color: #d32f2f;
}

#tagInput {
  border: none;
  outline: none;
  flex-grow: 1;
  min-width: 120px;
  padding: 4px;
  font-size: 14px;
}

/* Link Rows in Modal */
.links-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.link-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
}

.link-type-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.link-type-btn {
  padding: 6px 12px;
  border: 1px solid #d0d0d0;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.link-type-btn:hover {
  background: #f0f0f0;
  border-color: #50946e;
}

.link-type-btn.active {
  background: #50946e;
  color: white;
  border-color: #50946e;
  box-shadow: 0 2px 6px rgba(80, 148, 110, 0.3);
}

.link-type-btn i {
  font-size: 14px;
}

.link-inputs {
  display: flex;
  gap: 8px;
  align-items: center;
}

.link-inputs input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.btn-remove-link {
  background: none;
  border: none;
  color: #d32f2f;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
}

.tag-color-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.tag-color-label {
  font-weight: 600;
  color: rgb(55, 53, 47);
}

#tagColorPicker {
  width: 42px;
  height: 36px;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  background: white;
}

.btn-compact {
  padding: 6px 10px;
  font-size: 12px;
}

.tag-color-preview {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #ccc;
  background: #50946e;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.help-text {
  margin: 8px 0 0 0;
  font-size: 12px;
  color: #666;
  font-style: italic;
}

.btn-secondary {
  background-color: #f0f0f0;
  color: #333;
  border: 1px solid #ccc;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary:hover {
  background-color: #e0e0e0;
}

/* Updated Bookmark Card */
.bookmark-card {
  height: auto;
  /* Allow dynamic height */
  min-height: 320px;
  display: flex;
  flex-direction: column;
  padding-bottom: 10px;
  background: white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.bookmark-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.bookmark-card-img {
  width: 100%;
  height: 350px;
  object-fit: cover;
  border-bottom: 1px solid #eee;
}

.bookmark-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Mobile Responsiveness */
@media (max-width: 536px) {
  body {
    padding: 8px;
    overflow-x: hidden;
  }

  .bookmark-sec {
    padding: 12px 15px 18px 15px;
  }

  .bookmark-card-div {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
  }

  .bookmark-card-wrapper {
    width: calc(50% - 6px);
    flex-shrink: 0;
    height: auto;
  }

  .bookmark-card {
    width: 100%;
    height: auto;
    min-height: auto;
  }

  .bookmark-card-img {
    height: 320px;
    /* aspect-ratio: 3/4; */
  }

  .page-title {
    font-size: 24px;
  }

  .page-header-icon {
    font-size: 32px;
  }

  .bookmark-info {
    padding: 8px;
  }

  .card-tags {
    padding: 0 8px 8px 8px;
  }

  .bookmark-title {
    font-size: 14px;
  }

  .card-link-item {
    font-size: 12px;
    padding: 3px 5px;
  }

  .link-row {
    flex-direction: column;
  }
}