/* ==========================================================================
   COMPONENTS
   Buttons, Modals, Forms, Cards, Toasts, Audio Controls
   ========================================================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--transition-normal);
  white-space: nowrap;
}

.btn-primary {
  background: var(--text-main);
  color: var(--bg-surface);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--accent-subtle);
  border-color: var(--accent-primary);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  transition: var(--transition-normal);
}

.btn-icon:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background: var(--bg-secondary);
}

/* Modal System */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 19, 29, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  position: relative;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
}

/* Paper Note Aesthetic for Modals and Cards */
.paper-card {
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  position: relative;
  transition: var(--transition-normal);
}

.paper-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* Form Styling */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-textarea,
[data-theme="dark"] .form-select {
  background: rgba(15, 19, 29, 0.4);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(140, 122, 107, 0.15);
  background: var(--bg-surface);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

/* Mood Select Grid */
.mood-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
}

.mood-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.mood-chip:hover, .mood-chip.selected {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
  color: var(--text-main);
  font-weight: 500;
}

/* Paper Color Swatches */
.paper-color-picker {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.selected {
  border-color: var(--text-main);
  transform: scale(1.1);
}

/* Tag Pills */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  background: var(--accent-subtle);
  color: var(--accent-primary);
  border: 1px solid var(--accent-secondary);
}

/* Audio Player Panel Drawer */
.audio-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 80;
  width: 320px;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.audio-panel.hidden {
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
}

.audio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.sound-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sound-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.sound-item:hover, .sound-item.active {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
  color: var(--accent-primary);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  background: var(--text-main);
  color: var(--bg-surface);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Gallery & Search Grid */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.memory-card-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

/* Badges & Meta Info */
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
