/* ==========================================================================
   Red Barn Butchers - components.css
   Buttons, cards, forms, badges, tables.
   ========================================================================== */

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.7rem 1.8rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: color var(--transition-standard), border-color var(--transition-standard), background var(--transition-standard);
}
.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-barn-red-dark);
  transform: translateX(-101%);
  transition: transform var(--transition-standard);
  z-index: 0;
}
.btn > * { position: relative; z-index: 1; }

.btn-primary {
  background: var(--color-barn-red);
  color: var(--color-white);
}
.btn-primary:hover::before { transform: translateX(0); }

.btn-outline {
  border-color: rgba(255,255,255,0.35);
  color: var(--color-white);
}
.btn-outline:hover { border-color: var(--color-white); background: rgba(255,255,255,0.06); }

.btn-outline-light {
  border-color: rgba(255,255,255,0.7);
  color: var(--color-white);
}
.btn-outline-light:hover { background: rgba(255,255,255,0.15); }

.btn-outline-dark {
  border-color: rgba(34,34,34,0.4);
  color: var(--color-text-dark);
}
.btn-outline-dark:hover { border-color: var(--color-text-dark); background: rgba(34,34,34,0.06); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-light);
  border-color: rgba(255,255,255,0.15);
  text-transform: none;
  font-weight: 500;
}
.btn-ghost:hover { border-color: var(--color-barn-red); color: var(--color-white); }

.btn-danger {
  background: transparent;
  color: var(--color-barn-red);
  border-color: rgba(168,30,30,0.4);
  text-transform: none;
  font-weight: 500;
}
.btn-danger:hover { background: rgba(168,30,30,0.12); border-color: var(--color-barn-red); }

.btn-small { min-height: 44px; padding: 0.5rem 1rem; font-size: 0.78rem; text-transform: none; font-weight: 500; }
.btn-block { width: 100%; }

@media (min-width: 1024px) {
  .btn { padding: 0.95rem 2rem; }
}

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
  min-width: 0; /* prevents wide intrinsic content (e.g. a file input's
                   native button) from forcing its grid/flex track wider
                   than the available space */
}
.field input[type="file"] {
  max-width: 100%;
}
.field span { font-size: 0.8rem; color: rgba(34,34,34,0.6); letter-spacing: 0.02em; }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="file"],
.field select,
.field textarea {
  background: var(--color-white);
  border: 1px solid rgba(34,34,34,0.2);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  color: var(--color-text-dark);
  transition: border-color var(--transition-standard);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--color-barn-red);
  outline: none;
}
.field textarea { resize: vertical; min-height: 120px; }
.field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.7rem;
  min-height: 44px;
  cursor: pointer;
}
.field-checkbox input { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--color-barn-red); }
.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.2rem;
}
@media (min-width: 768px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}
.field-help { display: block; font-size: 0.78rem; line-height: 1.45; color: rgba(34,34,34,0.55); }
.field-help code { font-size: 0.95em; }

.current-photo {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.current-photo img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid rgba(34,34,34,0.15);
  flex-shrink: 0;
}
.current-photo .field { margin-bottom: 0; }

.form-error {
  background: rgba(168,30,30,0.08);
  border-left: 3px solid var(--color-barn-red);
  padding: 0.9rem 1.1rem;
  color: var(--color-text-dark);
  font-size: 0.9rem;
  margin-bottom: 1.4rem;
}
.form-error::before { content: '\2715  '; color: var(--color-barn-red); font-weight: 700; }
.form-success::before { content: '\2713  '; color: var(--color-barn-red); font-weight: 700; }
.form-success {
  background: rgba(168,30,30,0.06);
  border-left: 3px solid var(--color-barn-red);
  padding: 0.9rem 1.1rem;
  color: var(--color-text-dark);
  font-size: 0.9rem;
  margin-bottom: 1.4rem;
}
.form-actions { display: flex; gap: 1rem; align-items: center; }
.inline-form { display: inline-block; margin: 0; }

/* ---------- Meat / product cards ---------- */

.meat-card {
  background: var(--color-white);
  border: 1px solid rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-standard), border-color var(--transition-standard);
}
.meat-card:hover {
  transform: scale(1.025);
  border-color: rgba(168,30,30,0.4);
  z-index: 2;
}

.meat-card-photo {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--color-off-white);
}
.meat-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}
.meat-card:hover .meat-card-photo img { transform: scale(1.08); }

.meat-card-photo-fallback {
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(135deg, rgba(168,30,30,0.12) 0 2px, transparent 2px 22px),
    var(--color-off-white);
}

.meat-card-badge {
  position: absolute;
  top: 0.9rem;
  left: 0.9rem;
  background: var(--color-black);
  color: var(--color-text-light);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.4rem 0.7rem;
}
.meat-card--unavailable .meat-card-photo img,
.meat-card--unavailable .meat-card-photo-fallback { opacity: 0.4; }

.meat-card-body { padding: 1.4rem 1.5rem 1.6rem; flex: 1; display: flex; flex-direction: column; }
.meat-card-body h3 { font-size: 1.15rem; margin-bottom: 0.4em; }
.meat-card-body p { color: rgba(34,34,34,0.72); font-size: 0.92rem; flex: 1; }
.meat-card-price {
  margin: 0.6rem 0 0;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--color-barn-red);
}
.meat-card-price span { font-family: var(--font-body); font-size: 0.7rem; color: rgba(34,34,34,0.55); margin-left: 0.2em; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius);
}
.badge-in { background: rgba(168,30,30,0.14); color: var(--color-white); }
.badge-out { background: rgba(255,255,255,0.08); color: var(--color-text-muted); }

/* ---------- Admin table ---------- */

.admin-table { width: 100%; border-collapse: collapse; margin-bottom: 1.6rem; }
.admin-table th, .admin-table td {
  text-align: left;
  padding: 0.85rem 0.6rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 0.9rem;
}
.admin-table th { color: var(--color-text-muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.meat-thumb-cell { width: 56px; }
.meat-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--radius);
}
.meat-thumb-empty {
  display: block;
  background: repeating-linear-gradient(135deg, rgba(168,30,30,0.18) 0 2px, transparent 2px 8px), var(--color-charcoal);
}
.meat-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Below tablet width, tables become a stack of labeled cards instead
   of a horizontally-scrolling (or squeezed) table - nothing on this
   site scrolls sideways except the deliberate product shelves. */
@media (max-width: 767px) {
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td {
    display: block;
    width: 100%;
  }
  .admin-table tr {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    margin-bottom: 0.9rem;
  }
  .admin-table td {
    border-bottom: none;
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }
  .admin-table td[data-label]::before {
    content: attr(data-label);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    flex-shrink: 0;
  }
  .meat-table .meat-thumb-cell {
    justify-content: flex-start;
    padding-bottom: 0.7rem;
    margin-bottom: 0.3rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .meat-thumb, .meat-thumb-empty { width: 52px; height: 52px; }
  .meat-actions {
    justify-content: flex-start;
    padding-top: 0.3rem;
  }
  .meat-actions .btn { flex: 1 1 auto; }
}

/* ---------- Admin delete-confirm dialog (built by admin.js) ---------- */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.confirm-box {
  background: var(--color-charcoal);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 2rem;
  max-width: 340px;
  width: 90%;
  text-align: center;
}
.confirm-box p { margin: 0 0 1.4rem; color: var(--color-text-light); }
.confirm-actions { display: flex; gap: 0.8rem; justify-content: center; }

/* ---------- Loader ---------- */

#loader {
  position: fixed;
  inset: 0;
  background: var(--color-black);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
#loader-mark { width: 200px; max-width: 60vw; }
.loader-stroke {
  stroke: var(--color-barn-red);
  stroke-width: 3;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
}
