/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

@import "tailwindcss";

@layer base {
  body {
    font-family: 'Nunito', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  }
}

/* Global text selection color */
::selection {
  background-color: #ef4444; /* Tailwind red-500 */
  color: #f9fafb;
}

::-moz-selection {
  background-color: #ef4444;
  color: #f9fafb;
}

/* Card styles */
.note-card,
.space-card {
  box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  .note-card,
  .space-card {
    box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.2);
  }
}

.note-card:hover,
.space-card:hover {
  box-shadow: 0 0 16px 0 rgba(0, 0, 0, 0.12);
}

@media (prefers-color-scheme: dark) {
  .note-card:hover,
  .space-card:hover {
    box-shadow: 0 0 16px 0 rgba(0, 0, 0, 0.4);
  }
}

.note-card .menu-button {
  pointer-events: auto;
}

.note-card.dragging {
  opacity: 0.8;
  cursor: grabbing !important;
}

.note-content:focus {
  outline: none;
}

/* Truncate note content in grid cards */
/* Note: truncation is handled by truncate_html helper, this just ensures overflow is hidden */
.note-card .note-content {
  overflow: hidden;
  word-wrap: break-word;
}

/* Ensure todo items display properly in card previews */
.note-card .note-content .todo-item {
  display: block;
  width: 100%;
  margin-bottom: 2px;
}

.note-card .note-content input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 0.125rem; /* rounded-sm */
  margin-right: 6px;
  cursor: default;
  vertical-align: middle;
  position: relative;
  flex-shrink: 0;
  background-color: transparent;
  display: inline-block;
}

.note-card .note-content input[type="checkbox"]:checked {
  background-color: #ef4444; /* red-500 */
  border-color: #ef4444;
}

.note-card .note-content input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 10px;
  font-weight: bold;
  line-height: 1;
}

/* Strikethrough for checked items in card preview */
.note-card .note-content .todo-item:has(input[type="checkbox"]:checked),
.note-card .note-content .todo-item.checked {
  color: #9ca3af; /* gray-400 */
  text-decoration: line-through;
}

.note-card .note-content .todo-item:has(input[type="checkbox"]:checked) *,
.note-card .note-content .todo-item.checked * {
  text-decoration: line-through !important;
  color: #9ca3af !important; /* gray-400 */
}

@media (prefers-color-scheme: dark) {
  .note-card .note-content input[type="checkbox"] {
    border-color: #57534e; /* stone-600 */
  }

  .note-card .note-content .todo-item:has(input[type="checkbox"]:checked),
  .note-card .note-content .todo-item.checked {
    color: #78716c; /* stone-500 */
    text-decoration: line-through;
  }

  .note-card .note-content .todo-item:has(input[type="checkbox"]:checked) *,
  .note-card .note-content .todo-item.checked * {
    color: #78716c !important; /* stone-500 */
    text-decoration: line-through !important;
  }
}

/* Link card contenteditable styles - remove Safari blue borders */
.link-title:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
  -webkit-focus-ring-color: transparent;
}

.link-title {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none !important;
}

.link-title[contenteditable="true"]:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
  -webkit-focus-ring-color: transparent;
}

/* URL field is not editable - make it clear it's read-only */
.link-url {
  cursor: default;
  user-select: text; /* Allow text selection for copying */
}

.note-content:empty:before {
  content: 'Type something...';
  color: #9ca3af;
}

@media (prefers-color-scheme: dark) {
  .note-content:empty:before {
    color: #78716c;
  }
}

/* Add note card input styles - remove borders and outline */
.add-note-card {
  outline: none !important;
}

.add-note-card:focus,
.add-note-card:focus-within {
  outline: none !important;
  box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.04) !important;
}

@media (prefers-color-scheme: dark) {
  .add-note-card:focus,
  .add-note-card:focus-within {
    box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.2) !important;
  }
}

.add-note-content {
  outline: none !important;
  border: none !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: transparent;
}

.add-note-content:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}

.add-note-content:active {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}

/* Add space card input styles - mirror note card behavior */
.add-space-card {
  outline: none !important;
}

.add-space-card:focus,
.add-space-card:focus-within {
  outline: none !important;
  box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.04) !important;
}

@media (prefers-color-scheme: dark) {
  .add-space-card:focus,
  .add-space-card:focus-within {
    box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.2) !important;
  }
}

.add-space-content {
  outline: none !important;
  border: none !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: transparent;
}

.add-space-content:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}

.add-space-content:active {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}

/* SortableJS styles */
.sortable-ghost {
  opacity: 0.4;
  background: #f3f4f6;
}

@media (prefers-color-scheme: dark) {
  .sortable-ghost {
    background: #292524;
  }
}

.sortable-chosen {
  cursor: grabbing !important;
}

.sortable-drag {
  opacity: 0.6;
}

/* Delete Modal styles */
.delete-modal {
  animation: fadeIn 0.2s ease-out;
}

.delete-modal .bg-white {
  animation: slideUp 0.3s ease-out;
}

.delete-modal.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Drag and Drop styles */
.drag-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(239, 68, 68, 0.4); /* red-500/40 */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  pointer-events: none;
}

.drag-overlay-text {
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Upload card animation */
.upload-card {
  opacity: 0.8;
  animation: fadeIn 0.2s ease-out;
}

.upload-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Image card styles */
.image-card {
  padding: 0;
  background: transparent;
  border: none;
  overflow: hidden;
  display: flex;
  min-height: 200px;
  max-height: 340px;
  height: auto;
}

/* Allow context menu and submenus to overflow card boundaries */
.note-card .context-menu {
  overflow: visible;
}

.note-card .context-menu .size-submenu,
.note-card .context-menu .color-submenu,
.note-card .context-menu .space-submenu {
  overflow: visible;
  z-index: 60; /* Higher than context menu to ensure it appears above */
}

/* Ensure link cards allow context menu overflow (link-card has overflow: hidden) */
.note-card.link-card .context-menu,
.note-card.image-card .context-menu {
  overflow: visible;
}

.note-card.link-card .context-menu .size-submenu,
.note-card.link-card .context-menu .color-submenu,
.note-card.link-card .context-menu .space-submenu,
.note-card.image-card .context-menu .size-submenu,
.note-card.image-card .context-menu .color-submenu,
.note-card.image-card .context-menu .space-submenu {
  overflow: visible;
  z-index: 60;
}

/* Context menu appearing animation */
.context-menu:not(.hidden),
.space-context-menu:not(.hidden) {
  animation: contextMenuAppear 0.15s ease-out;
}

.context-menu.hidden,
.space-context-menu.hidden {
  display: none;
}

@keyframes contextMenuAppear {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Ensure submenus can overflow when using fixed positioning */
.size-submenu[style*="position: fixed"],
.color-submenu[style*="position: fixed"],
.space-submenu[style*="position: fixed"] {
  position: fixed !important;
  z-index: 60 !important;
}

.image-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}


.image-card .menu-button {
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
}

@media (prefers-color-scheme: dark) {
  .image-card .menu-button {
    background-color: rgba(28, 25, 23, 0.9);
  }
}

/* Link card styles */
.link-card {
  padding: 0;
  background: transparent;
  border: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.link-card .link-card-content > a {
  display: inline-block;
  word-break: break-all;
}

.link-card-image {
  flex-shrink: 0;
  overflow: hidden;
}

.link-card-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  min-height: 200px;
}

.link-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.link-card:hover {
  transform: translateY(-2px);
  transition: transform 0.2s ease;
}

.link-card .menu-button {
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
}

@media (prefers-color-scheme: dark) {
  .link-card .menu-button {
    background-color: rgba(28, 25, 23, 0.9);
  }
}

/* Filter pills */
.filter-pill {
  cursor: pointer;
  user-select: none;
}

.filter-pill.active {
  background-color: #3b82f6;
  color: white;
}

/* Size transition animation */
.note-card.size-transition {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* Ensure grid items animate smoothly when size changes */
#notes-container {
  transition: grid-template-columns 0.3s ease-in-out;
  overflow: visible; /* Allow submenus to overflow grid container */
}

#notes-container .note-card {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease-in-out;
}

/* Header (h2) styling in note content */
.note-content h2 {
  font-weight: 700; /* bold */
  font-size: 1.25rem; /* text-xl - 4 points larger than text-base (16px) */
  line-height: 1.75rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Link styling in note content */
.note-content a {
  color: #ef4444; /* red-500 */
  text-decoration: underline;
  cursor: pointer;
}

.note-content a:hover {
  color: #dc2626; /* red-600 */
}

/* Highlight (mark) styling in note content */
.note-content mark {
  background-color: #fef08a; /* yellow-200 */
}

@media (prefers-color-scheme: dark) {
  .note-content mark {
    background-color: rgba(254, 240, 138, 0.6) !important; /* yellow-200 at 60% opacity */
  }
}

/* Ensure empty divs/p tags display as line breaks */
.note-content div:empty,
.note-content p:empty {
  min-height: 1em;
  display: block;
}

/* Todo list styling - ensure each item is on its own line */
.note-content .todo-item {
  display: block;
  width: 100%;
}

/* Todo list checkbox styling */
.note-content input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 0.125rem; /* rounded-sm */
  margin-right: 8px;
  cursor: pointer;
  vertical-align: middle;
  position: relative;
  flex-shrink: 0;
  background-color: transparent;
  transition: all 0.2s ease;
  /* Prevent cursor from appearing in checkbox */
  caret-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Disable checkbox interactions in preview mode (non-contenteditable notes) */
.note-content[contenteditable="false"] input[type="checkbox"] {
  pointer-events: none;
  cursor: default;
}

.note-content input[type="checkbox"]:hover {
  border-color: #9ca3af; /* gray-400 */
}

/* Disable hover effects in preview mode */
.note-content[contenteditable="false"] input[type="checkbox"]:hover {
  border-color: #d1d5db; /* gray-300 - same as default */
}

.note-content input[type="checkbox"]:checked {
  background-color: #ef4444; /* red-500 */
  border-color: #ef4444;
}

.note-content input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
}

/* Strikethrough and gray text for checked todo items */
/* Apply to all text content in checked todo items, regardless of formatting */
.note-content .todo-item:has(input[type="checkbox"]:checked),
.note-content .todo-item.checked {
  color: #9ca3af; /* gray-400 */
  text-decoration: line-through;
}

/* Ensure all child elements also get strikethrough and gray color */
.note-content .todo-item:has(input[type="checkbox"]:checked) *,
.note-content .todo-item.checked * {
  text-decoration: line-through !important;
  color: #9ca3af !important; /* gray-400 */
}

/* Also handle direct sibling selector for compatibility */
.note-content .todo-item input[type="checkbox"]:checked ~ * {
  text-decoration: line-through;
  color: #9ca3af; /* gray-400 */
}

@media (prefers-color-scheme: dark) {
  .note-content input[type="checkbox"] {
    border-color: #57534e; /* stone-600 */
  }

  .note-content input[type="checkbox"]:hover {
    border-color: #78716c; /* stone-500 */
  }

  .note-content .todo-item:has(input[type="checkbox"]:checked),
  .note-content .todo-item.checked {
    color: #78716c; /* stone-500 */
    text-decoration: line-through;
  }

  .note-content .todo-item:has(input[type="checkbox"]:checked) *,
  .note-content .todo-item.checked * {
    color: #78716c !important; /* stone-500 */
    text-decoration: line-through !important;
  }
}

/* Remove blue border/outline from form inputs in Safari and other browsers */
input[type="email"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  outline: none !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input[type="email"],
input[type="text"],
input[type="password"],
textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Tag autocomplete dropdown styles */
.tag-autocomplete-dropdown {
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.tag-autocomplete-dropdown.hidden {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.tag-autocomplete-dropdown:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
}

.autocomplete-item {
  transition: background-color 0.15s ease;
}

