
:root {
  --bg-color: #F2F2F7;
  --text-color: #1C1C1E;
  --card-bg: rgba(255, 255, 255, 0.7);
  --modal-bg: rgba(255, 255, 255, 0.8);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  --border-radius: 20px;
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #1C1C1E;
    --text-color: #F2F2F7;
    --card-bg: rgba(44, 44, 46, 0.7);
    --modal-bg: rgba(44, 44, 46, 0.8);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  }
}

[data-theme="dark"] {
  --bg-color: #1C1C1E;
  --text-color: #F2F2F7;
  --card-bg: rgba(44, 44, 46, 0.7);
  --modal-bg: rgba(44, 44, 46, 0.8);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --bg-color: #F2F2F7;
  --text-color: #1C1C1E;
  --card-bg: rgba(255, 255, 255, 0.7);
  --modal-bg: rgba(255, 255, 255, 0.8);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  padding: 20px;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease;
}

#background-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  flex: 1;
  position: relative;
  z-index: 1;
}

h1 {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
  color: var(--text-color);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  letter-spacing: -1px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.settings-btn {
  background-color: var(--card-bg);
  border: none;
  padding: 10px 20px;
  border-radius: 30px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-color);
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.settings-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.settings-modal {
  display: none;
  position: fixed;
  z-index: 2;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
}

.settings-content {
  background-color: var(--modal-bg);
  margin: 10% auto;
  padding: 30px;
  border-radius: var(--border-radius);
  width: 350px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.settings-content h2 {
  margin-bottom: 20px;
  text-align: center;
  color: var(--text-color);
  font-size: 24px;
}

.settings-group {
  margin-bottom: 20px;
}

.settings-group label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
  color: var(--text-color);
}

.custom-select {
  position: relative;
  display: inline-block;
  width: 100%;
}

.custom-select select {
  display: none;
}

.select-selected {
  background-color: var(--card-bg);
  border-radius: 15px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.select-selected:after {
  position: absolute;
  content: "";
  top: 50%;
  right: 16px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-color: var(--text-color) transparent transparent transparent;
  transform: translateY(-25%);
}

.select-selected.select-arrow-active:after {
  border-color: transparent transparent var(--text-color) transparent;
  transform: translateY(-75%);
}

.select-items {
  position: absolute;
  background-color: var(--bg-color);
  top: 100%;
  left: 0;
  right: 0;
  z-index: 99;
  border-radius: 15px;
  margin-top: 5px;
  overflow: hidden;
  box-shadow: var(--shadow);
  max-height: 0;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
  opacity: 0;
}

.select-items div {
  color: var(--text-color);
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.select-items div:hover {
  background-color: rgba(0, 122, 255, 0.1);
}

.custom-select.active .select-items {
  max-height: 300px;
  opacity: 1;
}

.close-settings {
  position: absolute;
  right: 20px;
  top: 20px;
  width: 30px;
  height: 30px;
  background-color: rgba(229, 229, 234, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-color);
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(5px);
}

.close-settings:hover {
  background-color: rgba(209, 209, 214, 0.7);
  transform: rotate(90deg);
}

.filter-options {
  display: flex;
  justify-content: center;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.filter-btn {
  background-color: var(--card-bg);
  border: none;
  padding: 10px 20px;
  margin: 5px;
  border-radius: 30px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-color);
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.filter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.filter-btn.active {
  background-color: #ffc400;
  color: white;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  transition: var(--transition);
}

.color-card {
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  opacity: 0;
  transform: translateY(50px);
}

.color-card.show {
  opacity: 1;
  transform: translateY(0);
}

.color-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.color-sample {
  height: 200px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.color-sample::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 50%);
  transform: scale(0);
  transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.color-card:hover .color-sample::before {
  transform: scale(1);
}

.color-name {
  padding: 20px;
  text-align: center;
  font-weight: 600;
  font-size: 18px;
  position: relative;
  overflow: hidden;
}

.color-name::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  transform: translateX(-101%);
  transition: transform 0.3s ease;
}

.color-card:hover .color-name::before {
  transform: translateX(0);
}

.favorite-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}

.color-card:hover .favorite-btn,
.favorite-btn.active {
  opacity: 1;
}

.favorite-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: #FF3B30;
  stroke-width: 2;
  transition: fill 0.3s ease, transform 0.3s ease;
}

.favorite-btn.active svg {
  fill: #FF3B30;
}

.favorite-btn:hover {
  transform: scale(1.1);
}

.favorite-btn:active {
  transform: scale(0.9);
}

@keyframes favoriteAnimation {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.favorite-btn.animating svg {
  animation: favoriteAnimation 0.4s ease-in-out;
}

@keyframes particleAnimation {
  0% {
    transform: translate(0, 0) scale(0);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(1);
    opacity: 0;
  }
}

.particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #FF3B30;
  pointer-events: none;
  opacity: 0;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.show {
  opacity: 1;
}

.modal-content {
  background-color: var(--modal-bg);
  margin: 3% auto;
  padding: 40px;
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 600px;
  position: relative;
  opacity: 0;
  transform: scale(0.9) translateY(-50px);
  transition: var(--transition);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.modal.show .modal-content {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.color-preview {
  width: 100%;
  height: 200px;
  border-radius: var(--border-radius);
  margin-bottom: 30px;
  transition: var(--transition);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.color-preview::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 200%;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.2), transparent);
  transform: skewX(-25deg);
  transition: 0.5s;
}

.color-preview:hover::before {
  animation: fluidAnimation 1.5s infinite;
}

.color-preview:active {
  transform: scale(0.98);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.color-preview::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, transparent 70%);
  transition: all 0.5s ease-out;
  opacity: 0;
}

.color-preview:active::after {
  width: 300px;
  height: 300px;
  top: calc(50% - 150px);
  left: calc(50% - 150px);
  opacity: 0.5;
}

@keyframes fluidAnimation {
  0% { left: -100%; }
  100% { left: 100%; }
}

.color-info h2 {
  font-size: 28px;
  margin-bottom: 20px;
  color: var(--text-color);
}

.color-info p {
  margin-bottom: 20px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-color);
}

.color-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 10px 15px;
  border-radius: 10px;
  margin-bottom: 15px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.color-value::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,0.3), transparent);
  transform: translateX(-100%);
  transition: 0.5s;
}

.color-value:hover::before {
  transform: translateX(100%);
}

.color-value span {
  font-family: monospace;
  font-size: 14px;
}

.copy-btn {
  background-color: #007AFF;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  outline: none;
}

.copy-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: 0.5s;
}

.copy-btn:hover::before {
  left: 100%;
}

.copy-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 122, 255, 0.4);
}

.copy-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 5px rgba(0, 122, 255, 0.4);
}

.close {
  position: absolute;
  right: 20px;
  top: 20px;
  width: 30px;
  height: 30px;
  background-color: rgba(229, 229, 234, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-color);
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(5px);
}

.close:hover {
  background-color: rgba(209, 209, 214, 0.7);
  transform: rotate(90deg);
}

footer {
  text-align: center;
  padding: 20px;
  margin-top: 40px;
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

footer p {
  font-size: 14px;
  color: var(--text-color);
}

@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    padding: 30px;
  }
}

.context-menu {
  display: none;
  position: fixed;
  background-color: var(--bg-color);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  overflow: hidden;
  animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.context-menu-item {
  padding: 12px 20px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 14px;
  color: var(--text-color);
  display: flex;
  align-items: center;
}

.context-menu-item:hover {
  background-color: rgba(0, 122, 255, 0.1);
}

.context-menu-item:active {
  background-color: rgba(0, 122, 255, 0.2);
}

.context-menu-item:not(:last-child) {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.context-menu-item i {
  margin-right: 10px;
  font-size: 18px;
}

@keyframes copyAnimation {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.copy-animation {
  position: fixed;
  background-color: rgba(76, 217, 100, 0.9);
  color: white;
  padding: 10px 20px;
  border-radius: 30px;
  font-weight: bold;
  z-index: 1001;
  pointer-events: none;
  animation: copyAnimation 0.5s ease-out, fadeOut 0.5s ease-out 1s forwards;
}

@keyframes fadeOut {
  to { opacity: 0; }
}
