/**
 * categories-modal.css
 *
 * Dandiran WooCommerce Theme — Categories Modal
 *
 * Mobile-first: full-page modal by default (dnd-modal--fullscreen,
 * set by DNDModalBase's `fullscreen: true` option in
 * categories-modal.js). From the `lg` breakpoint up it becomes a
 * large centered panel instead of a full-page takeover — same DOM,
 * same two-pane layout, just constrained + rounded.
 *
 * Depends on dnd-tokens.css for --dnd-primary / --dnd-border etc.
 */

/*
|--------------------------------------------------------------------------
| Overlay + dialog shell
|--------------------------------------------------------------------------
*/

.dnd-cat-modal {
  position: fixed;
  inset: 0;
  z-index: 1060;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
}

.dnd-cat-modal.is-active {
  opacity: 1;
  visibility: visible;
}

.dnd-cat-modal .dnd-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 30, 0.4);
  pointer-events: none;
}

.dnd-cat-modal__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--dnd-white);
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.dnd-cat-modal.is-active .dnd-cat-modal__dialog {
  transform: translateX(0);
  z-index: 10001;
}

/*
|--------------------------------------------------------------------------
| Header — back button + reused search trigger
|--------------------------------------------------------------------------
*/

.dnd-cat-modal__header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--dnd-border);
}

.dnd-cat-modal__back {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--dnd-bg-soft);
  color: var(--dnd-text);
  cursor: pointer;
}

.dnd-cat-modal__back svg {
  width: 20px;
  height: 20px;
}

.dnd-cat-modal__search {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 6px 6px;
  border-radius: var(--dnd-radius-pill);
  background: var(--dnd-bg-soft);
}

.dnd-cat-modal__search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--dnd-text);
}

.dnd-cat-modal__search-input::placeholder {
  color: var(--dnd-muted);
}

.dnd-cat-modal__search-input:focus {
  outline: none;
}

.dnd-cat-modal__search-submit {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--dnd-primary);
  color: var(--dnd-white);
  cursor: pointer;
}

.dnd-cat-modal__search-submit svg {
  width: 15px;
  height: 15px;
}

/*
|--------------------------------------------------------------------------
| Body — two panes (main categories / sub-category panels)
|--------------------------------------------------------------------------
| Source order is right-pane markup first, then the panels — with the
| site's global dir="rtl", that already places the main list on the
| right and the panels on the left with a plain `display: flex`, no
| row-reverse needed.
*/

.dnd-cat-modal__body {
  flex: 1 1 auto;
  display: flex;
  overflow: hidden;
}

.dnd-cat-modal__main {
  flex: 0 0 92px;
  overflow-y: auto;
  background: var(--dnd-bg-soft);
  border-inline-start: 1px solid var(--dnd-border);
}

.dnd-cat-modal__main-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 14px 6px;
  border: none;
  border-inline-end: 3px solid transparent;
  background: none;
  color: var(--dnd-text);
  text-align: center;
  cursor: pointer;
}

.dnd-cat-modal__main-item.is-active {
  background: var(--dnd-white);
  border-inline-end-color: var(--dnd-primary);
  color: var(--dnd-primary);
}

.dnd-cat-modal__main-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.dnd-cat-modal__main-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dnd-cat-modal__main-icon svg {
  width: 24px;
  height: 24px;
}

.dnd-cat-modal__main-label {
  font-size: 11.5px;
  line-height: 1.3;
  font-weight: 500;
}

.dnd-cat-modal__panels {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
}

.dnd-cat-modal__panel[hidden] {
  display: none;
}

.dnd-cat-modal__view-all {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
  color: var(--dnd-primary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.dnd-cat-modal__view-all svg {
  width: 16px;
  height: 16px;
}

.dnd-cat-modal__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 10px;
}

.dnd-cat-modal__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--dnd-text);
  text-decoration: none;
  text-align: center;
}

.dnd-cat-modal__card-image {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--dnd-radius-md);
  background: var(--dnd-bg-soft);
  overflow: hidden;
}

.dnd-cat-modal__card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dnd-cat-modal__card-label {
  font-size: 12.5px;
  line-height: 1.4;
}

.dnd-cat-modal__empty {
  color: var(--dnd-muted);
  font-size: 13px;
}

.dnd-cat-modal__grid--products-image-only {
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.dnd-cat-modal__card--image-only {
  gap: 0;
}

/*
|--------------------------------------------------------------------------
| Desktop (lg+) — large centered panel instead of a full-page takeover
|--------------------------------------------------------------------------
*/

@media (min-width: 992px) {
  .dnd-cat-modal__dialog {
    position: absolute;
    top: 80px;
    right: 50%;
    transform: translateX(50%) translateY(-8px);
    width: min(920px, calc(100% - 48px));
    height: min(640px, calc(100% - 120px));
    border-radius: var(--dnd-radius-lg);
    box-shadow: var(--dnd-shadow);
    opacity: 0;
    transition:
      transform 0.2s ease,
      opacity 0.2s ease;
  }

  .dnd-cat-modal.is-active .dnd-cat-modal__dialog {
    transform: translateX(50%) translateY(0);
    opacity: 1;
    z-index: 10001;
  }

  .dnd-cat-modal__main {
    flex-basis: 220px;
  }

  .dnd-cat-modal__main-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 16px;
  }

  .dnd-cat-modal__main-label {
    font-size: 13.5px;
  }

  .dnd-cat-modal__grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
