/* ==========================================================================
   Zeon OS - GALLERY STYLES
   ========================================================================== */

.gallery-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  min-height: 0;
  background: var(--bg-surface-solid);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow: hidden;
  position: relative;
}

/* Toolbar ----------------------------------------------------------------- */
.gallery-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--window-titlebar-bg);
  border-bottom: var(--glass-border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.gallery-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gallery-toolbar-end {
  margin-left: auto;
}

.gallery-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  min-height: 30px;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  border: var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.gallery-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.gallery-btn:hover {
  background: var(--bg-surface-active);
  color: var(--text-primary);
  border-color: var(--accent);
}

.gallery-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.gallery-btn.primary {
  background: var(--accent);
  color: var(--accent-contrast, #fff);
  border-color: var(--accent);
}

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

.gallery-btn.icon-only {
  padding: 6px;
  width: 32px;
  height: 32px;
  justify-content: center;
}

.gallery-filter-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--bg-surface);
  border: var(--glass-border-subtle);
  border-radius: var(--radius-sm);
}

.gallery-filter {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 5px 14px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.gallery-filter:hover {
  color: var(--text-primary);
}

.gallery-filter.active {
  background: var(--accent);
  color: var(--accent-contrast, #fff);
}

.gallery-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  height: 32px;
  background: var(--bg-surface);
  border: var(--glass-border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.gallery-search svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.gallery-search input {
  width: 130px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
}

.gallery-search input::placeholder {
  color: var(--text-muted);
}

.gallery-sort {
  height: 32px;
  padding: 0 8px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: var(--glass-border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.gallery-sort option {
  background: var(--bg-surface-solid);
  color: var(--text-primary);
}

/* Content ----------------------------------------------------------------- */
.gallery-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 22px;
  position: relative;
}

.gallery-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  min-height: 16px;
}

.gallery-summary-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.7;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 14px;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  background: var(--bg-surface);
  border: var(--glass-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: border-color var(--transition-fast), transform var(--transition-fast), background var(--transition-fast);
}

.gallery-card:hover {
  border-color: var(--accent);
  background: var(--bg-surface-elevated);
  transform: translateY(-2px);
}

.gallery-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gallery-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0b0f16;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="light"] .gallery-thumb {
  background: #e8edf4;
}

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

.gallery-audio-art {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--accent-light);
  border: var(--glass-border);
  border-radius: 50%;
}

.gallery-audio-art svg {
  width: 26px;
  height: 26px;
}

.gallery-play-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 16, 0.78);
  color: #fff;
  border-radius: 50%;
  pointer-events: none;
}

.gallery-play-badge svg {
  width: 13px;
  height: 13px;
  margin-left: 2px;
}

.gallery-type-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 2px 6px;
  background: rgba(8, 10, 16, 0.78);
  color: #e2e8f0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  border-radius: var(--radius-xs);
  pointer-events: none;
}

.gallery-card-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 10px 10px;
  min-width: 0;
}

.gallery-card-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty state ------------------------------------------------------------- */
.gallery-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 320px;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.gallery-empty-icon {
  width: 64px;
  height: 64px;
  color: var(--accent);
  opacity: 0.75;
  margin-bottom: 14px;
}

.gallery-empty-icon svg {
  width: 64px;
  height: 64px;
}

.gallery-empty h3 {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--text-primary);
}

.gallery-empty p {
  margin: 0 0 18px;
  max-width: 380px;
  font-size: 12.5px;
  line-height: 1.6;
}

.gallery-empty-actions {
  display: flex;
  gap: 8px;
}

/* Viewer ------------------------------------------------------------------ */
.gallery-viewer {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.gallery-viewer[hidden] {
  display: none;
}

.gallery-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 12, 0.9);
  backdrop-filter: blur(6px);
}

.gallery-viewer-shell {
  position: relative;
  z-index: 1;
  margin: auto;
  width: calc(100% - 28px);
  height: calc(100% - 28px);
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-solid);
  border: var(--glass-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.gallery-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: var(--glass-border);
  background: var(--window-titlebar-bg);
  flex-shrink: 0;
}

.gallery-viewer-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.gallery-viewer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-viewer-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-viewer-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.gallery-viewer-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: auto;
  background: #070a10;
}

.gallery-viewer-stage.is-image {
  overflow: auto;
}

.gallery-viewer-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform var(--transition-fast);
  user-select: none;
}

.gallery-viewer-video {
  max-width: 100%;
  max-height: 100%;
  background: #000;
  border-radius: var(--radius-xs);
}

.gallery-media-error {
  padding: 18px 22px;
  color: #fca5a5;
  background: rgba(127, 29, 29, 0.28);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  text-align: center;
}

.gallery-viewer-audio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(420px, 100%);
  padding: 26px;
  background: var(--bg-surface);
  border: var(--glass-border);
  border-radius: var(--radius-md);
}

.gallery-audio-large {
  width: 92px;
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--accent-light);
  border: var(--glass-border);
  border-radius: 50%;
}

.gallery-audio-large svg {
  width: 42px;
  height: 42px;
}

.gallery-audio-name {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
  color: var(--text-primary);
}

.gallery-viewer-audio audio {
  width: 100%;
}

.gallery-viewer-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px;
  border-top: var(--glass-border-subtle);
  background: var(--window-titlebar-bg);
  font-size: 11.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.gallery-nav-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  border: var(--glass-border);
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.gallery-nav-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-contrast, #fff);
}

.gallery-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Responsive -------------------------------------------------------------- */
@media (max-width: 720px) {
  .gallery-toolbar-end {
    margin-left: 0;
    width: 100%;
  }

  .gallery-search {
    flex: 1;
  }

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

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
}
