/* ===== 전체 갤러리 탭 ===== */

.aigall-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 14px 16px;
  background: #FDFAF5;
  border: 1px solid #E8DFD0;
  border-radius: 12px;
  margin-bottom: 16px;
}

.aigall-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.aigall-summary-text {
  font-size: 0.9rem;
  color: #3D3830;
  font-weight: 600;
}

.aigall-category-filter {
  width: auto;
  min-width: 160px;
  border: 1px solid #D9D0C1;
  background-color: #FFFDF8;
  color: #3D3830;
  font-weight: 600;
}

.aigall-category-filter:focus {
  border-color: #8B6F47;
  box-shadow: 0 0 0 0.15rem rgba(139, 111, 71, 0.15);
}

.aigall-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.aigall-bulk {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #FFFDF8;
  border: 1px solid #E8DFD0;
  border-radius: 999px;
  flex-wrap: wrap;
}

/* 정렬 컨트롤 (방향 토글 + 기준 select) */
.aigall-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.aigall-sort-dir {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 7px;
}
.aigall-sort-arrow { display: block; }
.aigall-sort-key {
  width: auto;
  min-width: 84px;
}

.aigall-search {
  position: relative;
  display: flex;
  align-items: center;
}

.aigall-search i {
  position: absolute;
  left: 10px;
  color: #8A7F72;
  pointer-events: none;
  font-size: 0.85rem;
}

.aigall-search input {
  padding-left: 30px;
  width: 200px;
  border: 1px solid #D9D0C1;
  background: #FFFDF8;
  border-radius: 6px;
}

.aigall-search input:focus {
  border-color: #8B6F47;
  box-shadow: 0 0 0 0.15rem rgba(139, 111, 71, 0.15);
}

.aigall-btn-primary {
  background: #8B6F47;
  border: 1px solid #8B6F47;
  color: #FDFAF5;
  font-weight: 600;
}

.aigall-btn-primary:hover:not([disabled]) {
  background: #6E5736;
  border-color: #6E5736;
  color: #FFFDF8;
}

.aigall-btn-secondary {
  background: #FDFAF5;
  border: 1px solid #D9D0C1;
  color: #3D3830;
  font-weight: 600;
}

.aigall-btn-secondary:hover:not([disabled]) {
  background: #E8DFD0;
  border-color: #8B6F47;
  color: #8B6F47;
}

.aigall-btn-danger {
  background: #B14848;
  border: 1px solid #B14848;
  color: #FFFDF8;
  font-weight: 600;
}

.aigall-btn-danger:hover:not([disabled]) {
  background: #8F3232;
  border-color: #8F3232;
}

.aigall-btn-danger-soft {
  background: #FFFDF8;
  border: 1px solid #E5B5B0;
  color: #B14848;
  font-weight: 600;
}

.aigall-btn-danger-soft:hover:not([disabled]) {
  background: #FFEEEA;
  border-color: #B14848;
  color: #8F3232;
}

.aigall-count-badge {
  background: #8B6F47;
  color: #FFFDF8;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 5px 10px;
}

.aigall-count-badge.is-empty {
  background: #D9D0C1;
  color: #6B6358;
}

.aigall-clear-link {
  color: #8A7F72;
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0 4px;
  font-weight: 600;
}

.aigall-clear-link:hover:not([disabled]) {
  color: #8B6F47;
  text-decoration: underline;
}

.aigall-clear-link[disabled] {
  color: #C7BFAE;
  cursor: default;
}

.aigall-categories {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.aigall-loading,
.aigall-error,
.aigall-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #8A7F72;
  font-size: 0.9rem;
  background: #FBF8F2;
  border: 1px dashed #D9D0C1;
  border-radius: 10px;
}

.aigall-error {
  color: #B14848;
  background: #FFF4F2;
  border-color: #E5B5B0;
}

.aigall-section {
  border: 1px solid #E8DFD0;
  border-radius: 14px;
  background: #FFFDF8;
  overflow: hidden;
}

.aigall-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 12px 16px;
  background: #F5F0E8;
  border-bottom: 1px solid #E8DFD0;
}

.aigall-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.96rem;
  font-weight: 700;
  color: #1C1A16;
}

.aigall-section-title i {
  color: #8B6F47;
}

.aigall-section-count {
  background: #FDFAF5;
  border: 1px solid #D9D0C1;
  color: #8B6F47;
  font-weight: 600;
  font-size: 0.78rem;
  margin-left: 4px;
}

.aigall-to-dropbox-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 130px;
  padding: 6px 14px;
  border: 1px solid #4F7CB7;
  border-radius: 999px;
  background: linear-gradient(180deg, #6BA0DC 0%, #4F7CB7 100%);
  color: #FFFDF8;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(79, 124, 183, 0.25);
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.aigall-to-dropbox-btn:hover:not([disabled]) {
  background: linear-gradient(180deg, #82B4ED 0%, #5A8DCB 100%);
  border-color: #355E94;
  box-shadow: 0 4px 10px rgba(79, 124, 183, 0.4);
  transform: translateY(-1px);
}

.aigall-to-dropbox-btn:active:not([disabled]) {
  transform: translateY(1px) scale(0.98);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
  background: linear-gradient(180deg, #4F7CB7 0%, #3D6398 100%);
}

.aigall-to-dropbox-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 124, 183, 0.35);
}

.aigall-to-dropbox-btn[disabled] {
  background: linear-gradient(180deg, #C9D4E3 0%, #B5C2D6 100%);
  border-color: #B5C2D6;
  color: #FFFDF8;
  cursor: not-allowed;
  opacity: 0.7;
  box-shadow: none;
}

.aigall-to-dropbox-btn.is-sending {
  background: linear-gradient(180deg, #8B6F47 0%, #6E5736 100%);
  border-color: #6E5736;
  opacity: 1;
  cursor: progress;
}

.aigall-to-dropbox-btn.is-success {
  background: linear-gradient(180deg, #5CAA73 0%, #428958 100%);
  border-color: #428958;
  opacity: 1;
}

.aigall-to-dropbox-btn.is-error {
  background: linear-gradient(180deg, #B14848 0%, #8F3232 100%);
  border-color: #8F3232;
  opacity: 1;
}

.aigall-select-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aigall-select-all,
.aigall-deselect {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #3D3830;
  font-weight: 600;
  cursor: pointer;
  margin: 0;
}

.aigall-select-all input,
.aigall-deselect input {
  cursor: pointer;
}

.aigall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  padding: 14px 16px 18px;
}

.aigall-tile {
  display: flex;
  flex-direction: column;
  background: #FDFAF5;
  border: 1px solid #E8DFD0;
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.aigall-tile:hover {
  border-color: #8B6F47;
  box-shadow: 0 4px 12px rgba(139, 111, 71, 0.12);
  transform: translateY(-1px);
}

.aigall-tile.is-selected {
  border-color: #8B6F47;
  box-shadow: 0 0 0 2px rgba(139, 111, 71, 0.35);
}

.aigall-tile-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  background:
    linear-gradient(45deg, rgba(217, 208, 193, 0.3) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(217, 208, 193, 0.3) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(217, 208, 193, 0.3) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(217, 208, 193, 0.3) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  overflow: hidden;
}

.aigall-tile-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  display: block;
}

.aigall-tile-preview {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: rgba(253, 250, 245, 0.92);
  border: 1px solid #D9D0C1;
  border-radius: 6px;
  color: #8B6F47;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.aigall-tile-preview:hover {
  background: #8B6F47;
  color: #FDFAF5;
}

.aigall-tile-check {
  position: absolute;
  top: 6px;
  left: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: rgba(253, 250, 245, 0.92);
  border: 1px solid #D9D0C1;
  border-radius: 6px;
  cursor: pointer;
  margin: 0;
}

.aigall-tile-check input {
  margin: 0;
  cursor: pointer;
}

.aigall-tile-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px 10px;
}

.aigall-tile-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #1C1A16;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aigall-tile-meta {
  font-size: 0.74rem;
  color: #8A7F72;
}

.aigall-tile-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.aigall-tile-download,
.aigall-tile-save,
.aigall-tile-delete {
  padding: 3px 9px;
  font-size: 0.76rem;
  text-decoration: none;
  flex: 1;
  text-align: center;
  white-space: nowrap;
}

/* 저장(공유) 버튼은 기본 숨김 — 공유 지원 단말의 모바일 폭에서만 노출한다. */
.aigall-tile-save,
.aigall-preview-save {
  display: none;
}

.aigall-preview-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding: 18px;
  max-height: calc(100vh - 200px);
}

.aigall-preview-body img {
  max-width: 100%;
  max-height: calc(100vh - 320px);
  object-fit: contain;
  border: 1px solid #D9D0C1;
  border-radius: 8px;
}

.aigall-preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  justify-content: center;
  color: #8A7F72;
  font-size: 0.85rem;
}

.aigall-preview-badge {
  background: #F5F0E8;
  border: 1px solid #D9D0C1;
  color: #8B6F47;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
}

@media (max-width: 768px) {
  .aigall-toolbar {
    align-items: stretch;
  }

  .aigall-search input {
    width: 100%;
  }

  .aigall-search {
    flex: 1;
    min-width: 0;
  }

  .aigall-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    padding: 10px 12px 14px;
  }

  .aigall-bulk {
    width: 100%;
    justify-content: flex-start;
  }

  /* 공유 지원 단말(주로 모바일/iOS): 막힌 다운로드 앵커를 숨기고 OS 공유 시트를 띄우는
     저장 버튼만 노출한다. 미지원 단말은 다운로드 앵커가 폴백으로 남는다. */
  .aigall-supports-share .aigall-tile-download,
  .aigall-supports-share .aigall-preview-download {
    display: none;
  }

  .aigall-supports-share .aigall-tile-save,
  .aigall-supports-share .aigall-preview-save {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* ===== 휴지통 ===== */
.aigall-modebar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.aigall-trash-actionbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: #FDFAF5;
  border: 1px solid #E8DFD0;
  border-radius: 12px;
  margin-bottom: 16px;
}

.aigall-trash-note {
  font-size: 0.78rem;
  color: #8A7F72;
  margin-left: auto;
}

.aigall-tile-origin {
  font-size: 0.74rem;
  color: #8B6F47;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aigall-trash-empty {
  color: #8A7F72;
}

@media (max-width: 575.98px) {
  .aigall-trash-note {
    width: 100%;
    margin-left: 0;
  }
}
