/**
 * Component Library — 3D50.com
 * Reusable UI components: buttons, cards, badges, inputs, modals, toasts, skeletons, tables
 */

/* ────────────────────────────────────────────────
   BUTTONS
──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.6rem 1.25rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  box-shadow: 0 0 0 0 rgba(245,158,11,0);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-bright);
  box-shadow: 0 4px 20px rgba(245,158,11,0.3);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  background: var(--color-accent-dim);
}

.btn-whatsapp {
  background: #25D366;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.2);
}
.btn-whatsapp:hover:not(:disabled) {
  background: #20ba5a;
  box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
  transform: translateY(-1px);
}
.btn-whatsapp:active:not(:disabled) {
  transform: translateY(0);
  background: #1da34e;
}

.btn-secondary {
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg-card-hover);
  border-color: rgba(255,255,255,0.15);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--color-accent-bg);
  color: var(--color-accent);
}

.btn-danger {
  background: transparent;
  color: var(--color-danger);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-bg);
}

.btn-sm { padding: 0.4rem 0.875rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.875rem 2rem; font-size: var(--text-base); }
.btn-icon { padding: 0.6rem; border-radius: var(--radius-md); }
.btn-full { width: 100%; }

/* Loading spinner in button */
.btn .spinner {
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn.loading .spinner { display: block; }
.btn.loading .btn-text { opacity: 0.7; }

/* ────────────────────────────────────────────────
   PRODUCT CARD
──────────────────────────────────────────────── */
.product-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: transform var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
  position: relative;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.product-card:hover {
  transform: translateY(-4px);
  border-color: var(--color-accent-border);
  box-shadow: var(--shadow-accent), var(--shadow-lg);
}

.product-card__image-wrap {
  position: relative;
  width: 100%;
  padding-bottom: calc(100% * 650 / 512);
  overflow: hidden;
  background: var(--color-bg-elevated);
}

.product-card__image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform var(--transition-slow);
}
.product-card:hover .product-card__image { transform: scale(1.05); }

.product-card__overlay {
  position: absolute;
  inset: 0;
  background: rgba(9,9,11,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-base);
  gap: var(--space-2);
}
.product-card:hover .product-card__overlay { opacity: 1; }

.product-card__body { padding: var(--space-4); flex: 1; display: flex; flex-direction: column; gap: var(--space-2); }
.product-card__category {
  font-size: var(--text-xs);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: var(--font-weight-semibold);
}
.product-card__title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
  color: var(--color-text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card__meta { display: flex; align-items: center; gap: var(--space-3); margin-top: auto; }
.product-card__price {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-accent);
}
.product-card__price-wrap {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  line-height: 1;
}
.product-card__price--free { color: var(--color-success); }
.product-card__price--sale { color: var(--color-danger); }
.product-card__price-original {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-decoration: line-through;
  font-weight: var(--font-weight-regular);
  margin-bottom: 2px;
}
.product-card__rating { display: flex; align-items: center; gap: 4px; font-size: var(--text-xs); color: var(--color-text-muted); }
.product-card__stars { color: var(--color-star-filled); font-size: 11px; letter-spacing: 1px; }
.product-card__downloads { margin-left: auto; font-size: var(--text-xs); color: var(--color-text-muted); }

/* Featured badge */
.badge-featured {
  position: absolute; top: var(--space-3); left: var(--space-3);
  background: var(--color-accent); color: var(--color-text-inverse);
  font-size: var(--text-xs); font-weight: var(--font-weight-bold);
  padding: 2px 8px; border-radius: var(--radius-full);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-free {
  position: absolute; top: var(--space-3); left: var(--space-3);
  background: var(--color-success-bg); color: var(--color-success);
  border: 1px solid var(--color-success);
  font-size: var(--text-xs); font-weight: var(--font-weight-bold);
  padding: 2px 8px; border-radius: var(--radius-full);
  text-transform: uppercase;
}
.badge-discount {
  position: absolute; top: var(--space-3); right: var(--space-3);
  background: var(--color-danger); color: #fff;
  font-size: var(--text-xs); font-weight: var(--font-weight-bold);
  padding: 2px 8px; border-radius: var(--radius-full);
}

/* ────────────────────────────────────────────────
   BADGES / TAGS
──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.04em;
}
.badge-amber   { background: var(--color-accent-bg);    color: var(--color-accent);  border: 1px solid var(--color-accent-border); }
.badge-green   { background: var(--color-success-bg);   color: var(--color-success); }
.badge-red     { background: var(--color-danger-bg);    color: var(--color-danger);  }
.badge-blue    { background: var(--color-info-bg);      color: var(--color-info);    }
.badge-neutral { background: rgba(255,255,255,0.06);    color: var(--color-text-secondary); }

.tag {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}
.tag:hover, .tag.active {
  background: var(--color-accent-bg);
  border-color: var(--color-accent-border);
  color: var(--color-accent);
}

/* ────────────────────────────────────────────────
   FORM INPUTS
──────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }
.form-label {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.12);
}
.form-input::placeholder { color: var(--color-text-muted); }
.form-textarea { resize: vertical; min-height: 120px; }
.form-select option { background: var(--color-bg-card); }
.form-error { font-size: var(--text-xs); color: var(--color-danger); margin-top: var(--space-1); }
.form-hint  { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }

/* Search bar */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}
.search-bar__icon {
  position: absolute; left: 1rem;
  color: var(--color-text-muted);
  pointer-events: none;
  font-size: 1.1rem;
}
.search-bar__input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 3rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-primary);
  font-size: var(--text-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-bar__input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.1);
  outline: none;
}

/* Search suggestions dropdown */
.search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  z-index: var(--z-dropdown);
  box-shadow: var(--shadow-xl);
  display: none;
}
.search-suggestions.open { display: block; }
.search-suggestion-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.search-suggestion-item:hover { background: var(--color-bg-card-hover); }
.search-suggestion-item__title { font-size: var(--text-sm); flex: 1; }
.search-suggestion-item__price { font-size: var(--text-xs); color: var(--color-accent); font-weight: var(--font-weight-medium); }

/* ────────────────────────────────────────────────
   STAR RATING DISPLAY
──────────────────────────────────────────────── */
.star-rating { display: inline-flex; gap: 2px; }
.star-rating .star { font-size: 1rem; transition: transform var(--transition-fast); }
.star-rating .star.filled { color: var(--color-star-filled); }
.star-rating .star.empty  { color: var(--color-star-empty); }

/* Interactive star rating (review form) */
.star-input { display: flex; flex-direction: row-reverse; gap: 4px; }
.star-input input { display: none; }
.star-input label {
  font-size: 1.75rem;
  color: var(--color-star-empty);
  cursor: pointer;
  transition: color var(--transition-fast), transform var(--transition-fast);
}
.star-input label:hover,
.star-input label:hover ~ label,
.star-input input:checked ~ label {
  color: var(--color-star-filled);
  transform: scale(1.1);
}

/* ────────────────────────────────────────────────
   MODAL
──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-spring);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}
.modal__title { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--font-weight-bold); }
.modal__close {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); font-size: 1.5rem; line-height: 1;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.modal__close:hover { color: var(--color-text-primary); background: rgba(255,255,255,0.05); }
.modal__body { padding: var(--space-6); }
.modal__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex; gap: var(--space-3); justify-content: flex-end;
}

/* ────────────────────────────────────────────────
   TOAST NOTIFICATIONS
──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 280px;
  max-width: 400px;
  pointer-events: all;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-left: 3px solid var(--color-text-muted);
}
.toast.success { border-left-color: var(--color-success); }
.toast.error   { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }
.toast.info    { border-left-color: var(--color-info); }
.toast__icon { font-size: 1.2rem; flex-shrink: 0; }
.toast.success .toast__icon { color: var(--color-success); }
.toast.error   .toast__icon { color: var(--color-danger);  }
.toast__message { flex: 1; font-size: var(--text-sm); line-height: var(--line-height-snug); }
.toast__close {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); font-size: 1.1rem; line-height: 1;
  transition: color var(--transition-fast);
  flex-shrink: 0;
}
.toast__close:hover { color: var(--color-text-primary); }

/* ────────────────────────────────────────────────
   SKELETON LOADERS
──────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-card) 25%,
    var(--color-bg-card-hover) 50%,
    var(--color-bg-card) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}
.skeleton-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}
.skeleton-card__image { aspect-ratio: 4/3; }
.skeleton-card__body  { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.skeleton-text-sm  { height: 12px; width: 60%; }
.skeleton-text-md  { height: 14px; width: 100%; }
.skeleton-text-lg  { height: 18px; width: 80%; }
.skeleton-text-xl  { height: 22px; width: 40%; }

/* ────────────────────────────────────────────────
   DATA TABLE
──────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
}
.data-table {
  width: 100%;
  font-size: var(--text-sm);
}
.data-table thead tr {
  background: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border);
}
.data-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}
.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .col-actions { display: flex; gap: var(--space-2); }

/* Checkbox */
.data-table input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

/* ────────────────────────────────────────────────
   PAGINATION
──────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.pagination__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.pagination__btn:hover:not(:disabled) {
  border-color: var(--color-accent-border);
  color: var(--color-accent);
}
.pagination__btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text-inverse);
  font-weight: var(--font-weight-bold);
}
.pagination__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination__info { font-size: var(--text-sm); color: var(--color-text-muted); }

/* ────────────────────────────────────────────────
   SECTION HEADERS
──────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.section-label {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}
.section-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-extrabold);
  color: var(--color-text-primary);
}
.section-link {
  font-size: var(--text-sm);
  color: var(--color-accent);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  transition: opacity var(--transition-fast);
}
.section-link:hover { opacity: 0.75; }

/* ────────────────────────────────────────────────
   STAT CARD (admin/dashboard)
──────────────────────────────────────────────── */
.stat-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: var(--color-accent-bg);
  border-radius: 0 var(--radius-xl) 0 80px;
  transition: width var(--transition-slow), height var(--transition-slow);
}
.stat-card:hover::before { width: 100px; height: 100px; }
.stat-card__icon {
  font-size: 1.5rem;
  color: var(--color-accent);
  z-index: 1;
}
.stat-card__label { font-size: var(--text-sm); color: var(--color-text-muted); }
.stat-card__value {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: var(--font-weight-extrabold);
  color: var(--color-text-primary);
  line-height: 1;
}
.stat-card__change {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
}
.stat-card__change.positive { color: var(--color-success); }
.stat-card__change.negative { color: var(--color-danger); }

/* ────────────────────────────────────────────────
   ANIMATIONS
──────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.animate-fade-in-up { animation: fadeInUp 0.5s ease both; }
.animate-fade-in    { animation: fadeIn 0.4s ease both; }
.animate-scale-in   { animation: scaleIn 0.3s ease both; }

/* Stagger delays for grid items */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.10s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.20s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.30s; }

/* ────────────────────────────────────────────────
   UTILITY CLASSES
──────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-6);
}
.container-wide { max-width: var(--container-2xl); }

.text-accent   { color: var(--color-accent); }
.text-muted    { color: var(--color-text-muted); }
.text-success  { color: var(--color-success); }
.text-danger   { color: var(--color-danger); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-8) 0;
}

.empty-state {
  text-align: center;
  padding: var(--space-16);
  color: var(--color-text-muted);
}
.empty-state__icon { font-size: 3rem; margin-bottom: var(--space-4); opacity: 0.4; }
.empty-state__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-2);
  color: var(--color-text-secondary);
}
