/* ==========================================================================
   Sira Admin — component classes
   Visual language aligned with sira-vendor-app.
   Tokens live in /public/css/theme.css and are consumed here.
   ========================================================================== */

/* ──────────────────────────────────────────────────────────────────────────
   Buttons
   ────────────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  height: 36px;
  padding: 0 1rem;
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease,
              box-shadow .15s ease, opacity .15s ease;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
  border-color: var(--primary);
}
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  pointer-events: none;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

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

.btn-outline {
  background: var(--background);
  color: var(--foreground);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--sidebar-accent); }

.btn-ghost {
  background: transparent;
  color: var(--foreground);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--sidebar-accent); }

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
  border-color: var(--destructive);
}
.btn-destructive:hover { opacity: 0.92; }

.btn-link {
  background: transparent;
  color: var(--primary);
  border-color: transparent;
  padding: 0;
  height: auto;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--primary-hover); }

.btn-sm { height: 32px; padding: 0 0.75rem; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { height: 42px; padding: 0 1.25rem; font-size: 15px; }
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  border-radius: var(--radius-md);
}
.btn-icon.btn-sm { width: 32px; height: 32px; }
.btn-icon.btn-lg { width: 42px; height: 42px; }

/* Topbar icon button */
.icon-btn {
  position: relative;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--sidebar-accent); color: var(--foreground); }


/* ──────────────────────────────────────────────────────────────────────────
   Inputs, textareas, selects
   ────────────────────────────────────────────────────────────────────────── */
.input,
.textarea,
.select {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 0.875rem;
  font-size: 14px;
  font-weight: var(--font-weight-normal);
  color: var(--foreground);
  background: var(--input-background);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.textarea { height: auto; min-height: 88px; padding: 10px 14px; line-height: 1.5; resize: vertical; }
.input:focus,
.textarea:focus,
.select:focus {
  background: var(--background);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.input::placeholder,
.textarea::placeholder { color: var(--muted-foreground); }
.input[aria-invalid='true'],
.textarea[aria-invalid='true'] {
  border-color: var(--destructive);
  box-shadow: 0 0 0 3px rgba(212, 24, 61, 0.12);
}

/* Back-compat alias used by legacy templates */
.input-field {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 0.875rem;
  font-size: 14px;
  color: var(--foreground);
  background: var(--input-background);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input-field:focus {
  background: var(--background);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: var(--font-weight-medium);
  color: var(--foreground);
  margin-bottom: 6px;
}
.form-hint  { margin-top: 6px; font-size: 12.5px; color: var(--muted-foreground); }
.form-error { margin-top: 6px; font-size: 12.5px; color: var(--destructive); }
.form-group { margin-bottom: 1rem; }


/* ──────────────────────────────────────────────────────────────────────────
   Cards
   ────────────────────────────────────────────────────────────────────────── */
.card,
.page-card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 16px;
  font-weight: var(--font-weight-semibold);
  color: var(--foreground);
  margin: 0;
}
.card-description {
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--muted-foreground);
}
.card-body { padding: 24px; }
.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Stat card — vendor-app StatsCard pattern */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: box-shadow .18s ease, transform .18s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card .stat-label { font-size: 13.5px; color: var(--muted-foreground); margin-bottom: 6px; }
.stat-card .stat-value {
  font-size: 26px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: -0.01em;
  color: var(--foreground);
}
.stat-card .stat-trend { margin-top: 8px; font-size: 12.5px; }
.stat-card .stat-trend.up   { color: var(--status-completed); }
.stat-card .stat-trend.down { color: var(--status-issue); }
.stat-card .stat-icon-wrap {
  width: 40px; height: 40px;
  background: var(--muted);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-foreground);
}


/* ──────────────────────────────────────────────────────────────────────────
   Badges / status pills
   ────────────────────────────────────────────────────────────────────────── */
.badge,
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: var(--font-weight-medium);
  line-height: 1.5;
  border-radius: 9999px;
  background: var(--muted);
  color: var(--muted-foreground);
}
.badge-pending    { background: var(--status-pending-bg);   color: var(--status-pending); }
.badge-accepted   { background: var(--status-accepted-bg);  color: var(--status-accepted); }
.badge-ready      { background: var(--status-ready-bg);     color: var(--status-ready); }
.badge-completed  { background: var(--status-completed-bg); color: var(--status-completed); }
.badge-issue      { background: var(--status-issue-bg);     color: var(--status-issue); }
.badge-neutral    { background: var(--status-neutral-bg);   color: var(--status-neutral); }

.badge-primary  { background: rgba(220, 38, 38, 0.1); color: var(--primary); }
.badge-outline  { background: transparent; color: var(--foreground); box-shadow: inset 0 0 0 1px var(--border); }


/* ──────────────────────────────────────────────────────────────────────────
   Tables
   ────────────────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
.data-table thead th {
  text-align: left;
  font-size: 12px;
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  padding: 12px 16px;
  background: var(--sidebar-accent);
  border-bottom: 1px solid var(--border);
}
.data-table thead th:first-child { border-top-left-radius: var(--radius-md); }
.data-table thead th:last-child  { border-top-right-radius: var(--radius-md); }

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--foreground);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: var(--sidebar-accent); }

.data-table .td-muted { color: var(--muted-foreground); }


/* ──────────────────────────────────────────────────────────────────────────
   Page header (title + description + actions)
   ────────────────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 24px;
  font-weight: var(--font-weight-semibold);
  color: var(--foreground);
  margin: 0 0 4px;
}
.page-header .page-subtitle {
  font-size: 14px;
  color: var(--muted-foreground);
}
.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}


/* ──────────────────────────────────────────────────────────────────────────
   Tabs (simple)
   ────────────────────────────────────────────────────────────────────────── */
.tabs-list {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--muted);
  border-radius: var(--radius-md);
}
.tab-trigger {
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: var(--font-weight-medium);
  color: var(--muted-foreground);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab-trigger[aria-selected='true'],
.tab-trigger.active {
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}


/* ──────────────────────────────────────────────────────────────────────────
   Avatar
   ────────────────────────────────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px;
  border-radius: 9999px;
  background: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: var(--font-weight-medium);
  color: var(--muted-foreground);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }


/* ──────────────────────────────────────────────────────────────────────────
   Alert / callout
   ────────────────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--sidebar-accent);
  color: var(--foreground);
  border: 1px solid var(--border);
  font-size: 13.5px;
}
.alert-destructive {
  background: var(--status-issue-bg);
  color: var(--status-issue);
  border-color: rgba(239, 68, 68, 0.3);
}
.alert-warning {
  background: var(--status-pending-bg);
  color: var(--status-pending);
  border-color: rgba(249, 115, 22, 0.3);
}
.alert-success {
  background: var(--status-completed-bg);
  color: var(--status-completed);
  border-color: rgba(34, 197, 94, 0.3);
}


/* ──────────────────────────────────────────────────────────────────────────
   Product card (grid on /v1/products/gift-items)
   Image section stacks all images absolutely; JS toggles `.active` to
   fade-swap between them. Fixed 220px image height keeps the grid even.
   ────────────────────────────────────────────────────────────────────────── */
.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .18s ease, transform .18s ease;
}
.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.product-image-section {
  position: relative;
  width: 100%;
  height: 220px;
  background: var(--muted);
  overflow: hidden;
  flex-shrink: 0;
}

.product-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease;
}
.product-image.active {
  opacity: 1;
  visibility: visible;
  z-index: 1;
}

/* Carousel arrows — hidden until hover; auto-hidden entirely when single image. */
.product-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--foreground);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity .15s ease, background .15s ease;
}
.product-arrow:hover       { background: #fff; }
.product-arrow.left-arrow  { left: 8px; }
.product-arrow.right-arrow { right: 8px; }
.product-card:hover .product-arrow { opacity: 1; }

/* Hide both arrows when the card has only one image. */
.product-image-section:not(:has(.product-image:nth-child(2))) .product-arrow {
  display: none;
}

.product-body {
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.product-title {
  font-size: 14px;
  font-weight: var(--font-weight-semibold);
  color: var(--foreground);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  min-height: calc(14px * 1.45 * 2); /* reserve 2 lines so cards align */
}
.product-price {
  font-size: 12.5px;
  color: var(--muted-foreground);
  margin: 4px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ──────────────────────────────────────────────────────────────────────────
   Utilities
   ────────────────────────────────────────────────────────────────────────── */
.data-row { cursor: pointer; transition: background 0.12s; }
.data-row:hover { background-color: var(--sidebar-accent); }

.soft-scroll::-webkit-scrollbar         { width: 6px; height: 6px; }
.soft-scroll::-webkit-scrollbar-thumb   { background: rgba(0,0,0,0.12); border-radius: 8px; }
.soft-scroll::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.18); }


/* ──────────────────────────────────────────────────────────────────────────
   Responsive tweaks
   ────────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .card-body { padding: 18px; }
  .card-header { padding: 16px 18px; }
  .data-table thead th,
  .data-table tbody td { padding: 12px; }
}
