/* =====================================================
   utilities.css
   Animation, transitions, and utility helpers.
   ===================================================== */

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

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

@keyframes zoomIn {
  from { opacity: 0; transform: scale(.9); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(40px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- Buttons – Base ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(.97); }

/* ---- Button Variants ---- */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: 2px solid var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
}
.btn-outline:hover { border-color: var(--border-hover); background: var(--bg); }

.btn-secondary {
  background: var(--secondary);
  color: #fff;
  border: 2px solid var(--secondary);
  font-weight: 600;
}
.btn-secondary:hover {
  background: var(--secondary-dark);
  border-color: var(--secondary-dark);
  box-shadow: 0 4px 12px rgba(245,158,11,.3);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: 2px solid var(--danger);
}
.btn-danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); }

.btn-full { width: 100%; justify-content: center; height: 44px; font-size: 15px; }

/* ---- Loading Spinner in Button ---- */
.btn.loading span::before {
  content: '';
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

/* ---- Contact Button ---- */
.btn-contact {
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}
.btn-contact:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}

/* ---- Form – Input Focus ---- */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

#registerFirstName:focus,
#registerFirstName:focus-visible,
#registerLastName:focus,
#registerLastName:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ---- Transitions ---- */
.card {
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: var(--border-hover);
}

.card-img-wrap img {
  transition: transform .35s ease;
}
.card:hover .card-img-wrap img {
  transform: scale(1.04);
}

.card-owner-actions {
  transition: opacity var(--transition);
}
.card:hover .card-owner-actions {
  opacity: 1;
}

.card-action-btn {
  transition: transform var(--transition), box-shadow var(--transition);
}
.card-action-btn:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow);
}

/* ---- Dropdown ---- */
.user-dropdown {
  animation: dropIn .15s ease;
}

.dropdown-item {
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--bg); }

.dropdown-danger { color: var(--danger); }
.dropdown-danger:hover { background: #fef2f2; }

/* ---- Link Button ---- */
.link-btn {
  color: var(--primary);
  font-weight: 600;
  font-size: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ---- Upload Progress ---- */
.upload-progress {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.upload-progress-bar {
  height: 100%;
  background: var(--primary);
  transition: width .3s ease;
}

/* ---- Modal Animations ---- */
.modal-overlay {
  animation: fadeIn .2s ease;
}

.modal {
  animation: slideUp .2s ease;
}

/* ---- Image Gallery Transitions ---- */
.gallery-thumbnails .thumbnail {
  transition: opacity .2s ease, border .2s ease;
}
.gallery-thumbnails .thumbnail:hover {
  opacity: 0.9;
}
.gallery-thumbnails .thumbnail.active {
  opacity: 1;
  border-color: var(--primary);
}

.card-image-gallery .main-image {
  transition: opacity .2s ease;
}

/* ---- User Avatar ---- */
.user-avatar {
  transition: transform var(--transition), box-shadow var(--transition);
}
.user-avatar:hover {
  transform: scale(1.07);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

/* ---- Filter Button ---- */
.filter-btn {
  transition: all var(--transition);
}
.filter-btn:hover { background: var(--primary-light); color: var(--primary); }
.filter-btn.active {
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}

/* ---- Modal Close Button ---- */
.modal-close {
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* ---- Tab Navigation ---- */
.tab-btn.active {
  box-shadow: var(--shadow-sm);
}

/* ---- Hover States ---- */
.header-search input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.search-icon-svg {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.btn-clear-search:hover { color: var(--danger); }

.zoom-close:hover { background: rgba(255,255,255,.3); }

.toggle-password:hover { color: var(--text); }

.image-preview-card .remove-single-image:hover {
  background: var(--danger-dark);
}

/* ---- Desc Popup ---- */
.desc-info-popup {
  position: fixed;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 36px 12px 14px;
  box-shadow: var(--shadow-lg);
  z-index: 250;
  max-width: 280px;
  border: 1px solid var(--border);
}

.desc-info-popup p {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
}

/* ---- Contact Popup ---- */
.contact-info-popup {
  position: fixed;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  z-index: 250;
  min-width: 200px;
  border: 1px solid var(--border);
}
.contact-info-popup h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.contact-info-popup p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0;
}
.close-popup {
  position: absolute;
  top: 4px; right: 4px;
  font-size: 18px;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
}
.close-popup:hover { color: var(--text); }
