/* Milestone Banner Styles */
.milestone-banner {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  padding: 8px 12px;
  border-radius: 12px;
  margin-top: 12px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
  animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.milestone-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#milestone-message {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  flex: 1;
}

.milestone-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.milestone-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.milestone-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.milestone-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s;
}

.milestone-close:hover {
  color: white;
}

/* Base Action Button Style */
.action-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background-color: #f1f5f9; /* Initial neutral color */
  color: #475569;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-sizing: border-box;
}

/* Top Buttons Area */
.quick-access-buttons {
  display: flex;
  justify-content: space-around;
  gap: 10px;
  background: white;
  padding: 8px 12px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  margin-top: -5px;
}

.quick-access-buttons .action-btn {
  flex: none;
  width: 50%;
}

/* Specific Active Colors - Only apply when JS adds .active */
#common-btn.active {
  background-color: #4f46e5;
  color: white;
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
  transform: translateY(-1px);
}

#favorites-btn.active {
  background-color: #db2777;
  color: white;
  box-shadow: 0 4px 6px -1px rgba(219, 39, 119, 0.2);
  transform: translateY(-1px);
}

/* Bottom Action Buttons (Copy/Insert) */
.button-container .action-btn {
  background-color: #4f46e5;
  color: white;
}

.button-container .action-btn:hover:not(:disabled) {
  background-color: #4338ca;
}

.action-btn:disabled {
  background-color: #d1d5db;
  cursor: not-allowed;
  opacity: 0.7;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  background: white;
  padding: 8px 12px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.category-selection {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #334155;
}

.category-select-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.manage-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.manage-btn:hover {
  background-color: #f1f5f9;
  color: #4f46e5;
}

#category-select {
  width: 120px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background-color: #f8fafc;
  font-size: 13px;
  color: #334155;
  appearance: none;
  background-image: url('../assets/dropdown-arrow.svg');
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 20px;
  padding-right: 22px;
  cursor: pointer;
}

.search-container {
  flex: 1;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#search-input {
  width: 100%;
  padding: 6px 10px;
  padding-right: 28px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  background-color: #f8fafc;
  color: #334155;
}

#search-input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  background-color: white;
}

.search-clear-btn {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  font-size: 16px;
  color: #94a3b8;
  cursor: pointer;
}

/* Grid Container */
.grid-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: white;
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  height: 300px;
  overflow-y: auto;
  align-content: flex-start;
}

.char-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  white-space: nowrap;
  background-color: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  color: #334155;
  padding: 0 10px;
}

.char-cell.has-user-tag::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  background-color: #db2777;
  border-radius: 50%;
  border: 1px solid white; /* Added border for better contrast on purple background */
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
}

.char-cell:hover {
  background-color: #e0e7ff;
  border-color: #c7d2fe;
}

.char-cell.selected {
  background-color: #4f46e5;
  color: white;
  border-color: #4338ca;
}

.placeholder-message {
  width: 100%;
  text-align: center;
  color: #94a3b8;
  font-style: italic;
  padding: 20px 0;
}

/* Mode Selection */
.mode-selection {
  display: flex;
  justify-content: space-around;
  background: white;
  padding: 10px 12px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  font-size: 13px;
  color: #555;
}

.mode-selection label {
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
}

.mode-selection input[type="radio"] {
  margin-right: 5px;
  accent-color: #4f46e5;
}

/* Editor Area - Hidden by default to prevent flicker */
.editor-container {
  background: white;
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  position: relative;
  display: none; /* JS will set to flex if needed */
  align-items: center;
}

#editor-input {
  width: 100%;
  padding: 8px;
  padding-right: 32px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 15px;
  color: #334155;
}

.clear-btn {
  position: absolute;
  right: 20px;
  background: none;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
}

/* Bottom Buttons Area - Hidden by default */
.button-container {
  display: none; /* JS will set to flex if needed */
  gap: 10px;
}

/* Animation helpers */
.action-btn.success { background-color: #10b981 !important; }
.action-btn.error { background-color: #ef4444 !important; }

/* Footer */
.footer {
  width: 100%;
  text-align: center;
  padding-top: 6px;
  border-top: 1px solid #e2e8f0;
  margin-top: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.footer a {
  font-size: 12px;
  color: #6b7280;
  text-decoration: none;
}

.footer .footer-divider {
  width: 1px;
  height: 10px;
  background-color: #e2e8f0;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20000;
  backdrop-filter: blur(2px);
}

.tag-editor-modal {
  background: white;
  width: 320px;
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.tag-editor-modal h3 {
  margin: 0;
  font-size: 16px;
  color: #1a202c;
  text-align: center;
}

.editing-char-display {
  font-size: 48px;
  text-align: center;
  padding: 10px;
  background: #f8fafc;
  border-radius: 12px;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.tag-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tag-field label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

.default-tags-box {
  font-size: 13px;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 8px 12px;
  border-radius: 8px;
  min-height: 1.2em;
  word-break: break-all;
}

#user-tags-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}

#user-tags-input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.modal-buttons {
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.modal-btn.cancel { background-color: #f1f5f9; color: #475569; }
.modal-btn.save { background-color: #4f46e5; color: white; }

/* Context Menu */
.context-menu {
  position: fixed;
  background-color: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 6px;
  z-index: 10000;
  min-width: 140px;
}

.context-menu-item {
  padding: 8px 12px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  border-radius: 4px;
}

.context-menu-item:hover { background-color: #f1f5f9; color: #4f46e5; }

/* Toast & Preview */
#toast-container {
  position: fixed;
  bottom: 300px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background-color: #334155;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background-color: #10b981; }

.char-preview {
  position: fixed;
  display: none;
  pointer-events: none;
  background: white;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  min-width: 60px;
  min-height: 60px;
  padding: 5px 15px;
  font-size: 42px;
  z-index: 10001;
  /* Centering Logic */
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: #334155;
}

/* Category Management & Selection Modals */
.cat-manager-modal, .cat-selector-modal {
  background: white;
  width: 320px;
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.cat-list, .cat-options-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.cat-item, .cat-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
  color: #334155;
  transition: all 0.2s;
}

.cat-item:last-child, .cat-option:last-child {
  border-bottom: none;
}

.cat-item:hover, .cat-option:hover {
  background-color: #f1f5f9;
}

.cat-option {
  cursor: pointer;
}

.cat-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-actions {
  display: flex;
  gap: 4px;
}

.cat-action-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.cat-action-btn:hover {
  background-color: #e2e8f0;
  color: #4f46e5;
}

.cat-action-btn.delete:hover {
  color: #ef4444;
}

.add-cat-field {
  display: flex;
  gap: 8px;
}

.add-cat-field input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}

.add-cat-field input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}