/* == Modern CSS Reset == */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* == Root Variables == */
:root {
  /* Gradients */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --bookmarklet-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --link-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  --folder-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);

  /* Colors */
  --card-bg: rgba(30, 41, 59, 0.7);
  --card-border: rgba(255, 255, 255, 0.1);
  --hover-border: rgba(168, 85, 247, 0.5);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --highlight: rgba(255, 255, 0, 0.3);
  --success: #10b981;
  --error: #ef4444;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* == Base Styles == */
body {
  font-family: var(--font-family);
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* == Layout == */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* == Header == */
header {
  text-align: center;
  margin-bottom: 3rem;
  padding: 1rem;
}

h1 {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 1rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* == Search Input == */
#searchInput {
  width: 100%;
  max-width: 600px;
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid var(--card-border);
  border-radius: 16px;
  color: var(--text-primary);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

#searchInput:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3);
}

#searchInput::placeholder {
  color: var(--text-secondary);
}

/* == Category Buttons == */
.category-btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid var(--card-border);
  border-radius: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.category-btn:hover {
  transform: translateY(-2px);
  border-color: var(--hover-border);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.category-btn.active {
  background: var(--primary-gradient);
  border-color: transparent;
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

/* == Bookmark Grid == */
#bookmarksContainer {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

/* == Bookmark Card == */
.bookmark-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 2rem;
  backdrop-filter: blur(20px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.bookmark-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary-gradient);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}

.bookmark-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--hover-border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.bookmark-card:hover::before {
  transform: scaleX(1);
}

.bookmark-card h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

/* == Badges == */
.folder-badge,
.bookmarklet-badge,
.link-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 50px;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

.folder-badge {
  background: var(--folder-gradient);
}

.bookmarklet-badge {
  background: var(--bookmarklet-gradient);
}

.link-badge {
  background: var(--link-gradient);
}

/* == Copy Button == */
.copy-btn {
  background: var(--primary-gradient);
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.copy-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.copy-btn:active {
  transform: translateY(0);
}
/* == Bookmarklet Drag Area == */
.bookmarklet-drag-area {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.1) 0%, rgba(0, 242, 254, 0.1) 100%);
  border: 2px solid rgba(79, 172, 254, 0.3);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.bookmarklet-link-container {
  margin: 1.5rem 0;
}

.bookmarklet-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: element;
  -khtml-user-drag: element;
  -moz-user-drag: element;
  -o-user-drag: element;
  transition: all 0.3s ease;
}

.bookmarklet-link:hover {
  transform: scale(1.02);
}

.bookmarklet-link:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.bookmarklet-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.2) 0%, rgba(0, 242, 254, 0.2) 100%);
  border: 2px solid rgba(79, 172, 254, 0.5);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.bookmarklet-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.bookmarklet-text {
  flex: 1;
  min-width: 0;
}

.bookmarklet-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #f0f9ff;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmarklet-subtitle {
  font-size: 0.875rem;
  color: #bae6fd;
  opacity: 0.9;
}

.bookmarklet-arrow {
  font-size: 1.5rem;
  color: #38bdf8;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.bookmarklet-link:hover .bookmarklet-arrow {
  transform: translateX(4px);
}

/* == Link Area == */
.link-drag-area {
  background: linear-gradient(135deg, rgba(67, 233, 123, 0.1) 0%, rgba(56, 249, 215, 0.1) 100%);
  border: 2px solid rgba(67, 233, 123, 0.3);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.link-preview {
  margin: 1.5rem 0;
}

.url-display {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1.5rem;
  font-size: 0.875rem;
  line-height: 1.6;
  word-break: break-all;
  backdrop-filter: blur(5px);
  max-height: 150px;
  overflow-y: auto;
}

.url-display::-webkit-scrollbar {
  width: 8px;
}

.url-display::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.url-display::-webkit-scrollbar-thumb {
  background: var(--link-gradient);
  border-radius: 4px;
}

/* == Dragging States == */
.bookmarklet-card.dragging {
  opacity: 0.5;
  transform: scale(0.95);
}

.bookmarklet-link.dragging {
  opacity: 0.7;
  cursor: grabbing;
}

/* == Visual Feedback == */
@keyframes dragPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(79, 172, 254, 0.7);
  }
  50% {
    box-shadow: 0 0 20px 10px rgba(79, 172, 254, 0.3);
  }
}

.bookmarklet-content.dragging {
  animation: dragPulse 1.5s infinite;
}

/* == Touch Support == */
@media (hover: none) {
  .bookmarklet-link {
    -webkit-tap-highlight-color: rgba(79, 172, 254, 0.3);
  }
  
  .bookmarklet-link:active {
    background: rgba(79, 172, 254, 0.1);
  }
}
.highlight {
  background: var(--highlight);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-weight: 600;
}

/* == Footer == */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--card-border);
  margin-top: 2rem;
}

footer p {
  margin-bottom: 1rem;
}

/* == Toast Notification == */
#toast {
  position: fixed;
  top: 2rem;
  right: 2rem;
  padding: 1rem 2rem;
  border-radius: 12px;
  color: white;
  font-weight: 600;
  transform: translateX(400px);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

#toast.show {
  transform: translateX(0);
}

#toast.bg-green-600 {
  background: var(--success);
}

#toast.bg-red-600 {
  background: var(--error);
}

/* == Animations == */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.02);
  }
}

.pulse {
  animation: pulse 2s infinite;
}

/* == Responsive Design == */
@media (max-width: 1024px) {
  .container {
    padding: 1.5rem;
  }
  
  #bookmarksContainer {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
  }
  
  h1 {
    font-size: 2.5rem;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }
  
  header {
    margin-bottom: 2rem;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  header p {
    font-size: 1rem;
  }
  
  #searchInput {
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }
  
  .category-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  
  #bookmarksContainer {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .bookmark-card {
    padding: 1.5rem;
  }
  
  .bookmark-card h3 {
    font-size: 1.25rem;
  }
  
  .code-display {
    padding: 1rem;
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0.75rem;
  }
  
  h1 {
    font-size: 1.75rem;
  }
  
  .category-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    margin: 0.25rem;
  }
  
  .bookmark-card {
    padding: 1.25rem;
  }
  
  .folder-badge,
  .bookmarklet-badge,
  .link-badge {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
  }
  
  .copy-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
}

/* == Accessibility Improvements == */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* == Focus Styles for Accessibility == */
button:focus-visible,
input:focus-visible,
.category-btn:focus-visible {
  outline: 2px solid #8b5cf6;
  outline-offset: 2px;
}

/* == Print Styles == */
@media print {
  body {
    background: white;
    color: black;
  }
  
  .bookmark-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
  
  .copy-btn,
  #toast,
  footer {
    display: none;
  }
}