/*
 * Admin overrides for Tabler UI
 *
 * This file is loaded after tabler.min.css, so anything here takes precedence
 * over Tabler's defaults without needing !important.
 *
 * ─── CSS VARIABLES ───────────────────────────────────────────────────────────
 * Tabler exposes its entire design token set as --tblr-* custom properties.
 * Override them on :root (or a more specific selector) to apply globally.
 *
 * Common variables:
 *
 *   --tblr-body-bg            Page background
 *   --tblr-body-color         Default text colour
 *   --tblr-font-sans-serif    Body font stack
 *   --tblr-font-size-base     Base font size (default: 0.875rem)
 *   --tblr-line-height-base   Base line height
 *   --tblr-border-radius      Default border radius
 *   --tblr-border-color       Default border colour
 *
 *   --tblr-primary            Primary colour (used by .btn-primary, .text-primary, …)
 *   --tblr-primary-rgb        RGB triplet of the primary colour
 *   --tblr-secondary          Secondary colour
 *   --tblr-success            Success colour
 *   --tblr-danger             Danger colour
 *   --tblr-warning            Warning colour
 *   --tblr-info               Info colour
 *
 *   --tblr-navbar-bg          Navbar background
 *   --tblr-card-bg            Card background
 *   --tblr-card-border-color  Card border colour
 *
 * ─── CLASS OVERRIDES ─────────────────────────────────────────────────────────
 * Target any Tabler class below. The extra cascade weight from loading this
 * file last is enough — no !important required in most cases.
 * ─────────────────────────────────────────────────────────────────────────────
 */

/* ── Global variables ──────────────────────────────────────────────────────── */
:root {
  --tblr-body-bg: #f5f7fb;
  --tblr-primary: #228B22;
}

/* ── Component overrides ────────────────────────────────────────────────────── */

.btn-primary {
  --tblr-btn-hover-bg: #167016;
}

/* ── Dropzone (app/javascript/controllers/dropzone_controller.js) ───────────── */

.dz-area {
  padding: 2rem 1rem;
  cursor: pointer;
  border: 2px dashed var(--tblr-border-color);
  border-radius: var(--tblr-border-radius-lg, 8px);
  background: var(--tblr-bg-surface-secondary, #f8fafc);
  transition: border-color 0.15s ease, background-color 0.15s ease, padding 0.15s ease;
}

.dz-area:hover,
.dz-area:focus-visible {
  border-color: var(--tblr-primary);
  outline: none;
}

.dz-area.is-dragover {
  border-style: solid;
  border-color: var(--tblr-primary);
  background: rgba(34, 139, 34, 0.06);
}

.dz-area.has-files {
  padding: 0.75rem;
}

.dz-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  text-align: center;
}

.dz-prompt-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.5rem;
  border-radius: 50%;
  color: var(--tblr-primary);
  background: rgba(34, 139, 34, 0.1);
  transition: transform 0.15s ease;
}

.dz-prompt-icon svg {
  width: 1.75rem;
  height: 1.75rem;
}

.dz-area.is-dragover .dz-prompt-icon {
  transform: translateY(-3px) scale(1.08);
}

.dz-prompt-title,
.dz-prompt-title-short {
  font-weight: 600;
  color: var(--tblr-body-color);
}

.dz-prompt-hint {
  font-size: 0.8125rem;
  color: var(--tblr-secondary);
}

.dz-prompt-title-short {
  display: none;
}

/* With files: previews fill a grid inside the zone, the prompt becomes the last tile */
.dz-area.has-files .dz-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.75rem;
}

.dz-area.has-files .dz-prompt {
  min-height: 10rem;
  border: 2px dashed var(--tblr-border-color);
  border-radius: var(--tblr-border-radius-lg, 8px);
  background: var(--tblr-bg-surface, #fff);
  transition: border-color 0.15s ease;
}

.dz-area.has-files:hover .dz-prompt {
  border-color: var(--tblr-primary);
}

.dz-area.has-files .dz-prompt-title,
.dz-area.has-files .dz-prompt-hint {
  display: none;
}

.dz-area.has-files .dz-prompt-title-short {
  display: block;
  font-size: 0.8125rem;
}

.dz-area.has-files .dz-prompt-icon {
  width: 2.5rem;
  height: 2.5rem;
}

.dz-area.has-files .dz-prompt-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.dz-section-title {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tblr-secondary);
}

.dz-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.75rem;
}

.dz-preview {
  overflow: hidden;
  cursor: default;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--tblr-border-radius-lg, 8px);
  background: var(--tblr-bg-surface, #fff);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  animation: dz-preview-in 0.2s ease-out;
}

.dz-thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--tblr-bg-surface-secondary, #f8fafc);
}

.dz-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dz-remove {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--tblr-body-color);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.dz-preview.is-deleting {
  opacity: 0.5;
  pointer-events: none;
}

.dz-remove svg {
  width: 0.875rem;
  height: 0.875rem;
}

.dz-preview:hover .dz-remove,
.dz-remove:focus-visible {
  opacity: 1;
}

.dz-remove:hover {
  color: #fff;
  background: var(--tblr-danger);
}

/* Touch devices have no hover: keep the remove button visible */
@media (hover: none) {
  .dz-remove {
    opacity: 1;
  }
}

.dz-details {
  padding: 0.5rem 0.625rem;
  border-top: 1px solid var(--tblr-border-color);
}

.dz-name {
  overflow: hidden;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dz-size {
  font-size: 0.75rem;
  color: var(--tblr-secondary);
}

@keyframes dz-preview-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

/* ── Product gallery (admin/products/show) ─────────────────────────────────── */

.product-gallery-main {
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: var(--tblr-border-radius-lg, 8px);
  background: var(--tblr-bg-surface-secondary, #f8fafc);
}

.product-gallery-main img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-gallery-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.product-gallery-thumb {
  overflow: hidden;
  width: 4rem;
  height: 4rem;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--tblr-border-radius, 6px);
  background: var(--tblr-bg-surface-secondary, #f8fafc);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.product-gallery-thumb:hover {
  opacity: 1;
}

.product-gallery-thumb.is-active {
  border-color: var(--tblr-primary);
  opacity: 1;
}

.product-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-gallery-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 14rem;
  border-radius: var(--tblr-border-radius-lg, 8px);
  color: var(--tblr-secondary);
  background: var(--tblr-bg-surface-secondary, #f8fafc);
}

.product-gallery-empty svg {
  width: 2.5rem;
  height: 2.5rem;
}

.product-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.product-price {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--tblr-primary);
}

.product-size {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--tblr-border-radius, 6px);
  background: var(--tblr-bg-surface-secondary, #f8fafc);
}
