/* ---------------------------------------------------------------------------
 * assets.css — page-specific styles for the Assets / Image library template
 * ---------------------------------------------------------------------------
 * Extracted from the former inline <style> block in templates/assets.ts
 * (App-Building Bible principle 5: no inline <style>). Loaded via the layout's
 * headExtra <link href=asset("assets.css")>.
 *
 * Behavior-preserving with one principle-17 refinement: the upload modal is now
 * shown/hidden with the `hidden` attribute instead of a `display:none` + a
 * `.visible` class toggle. The overlay is `display:flex` when visible; the
 * `[hidden]` attribute (global `display:none`) hides it, so no `.visible` rule
 * is needed and no inline style="display:none" is emitted.
 * ------------------------------------------------------------------------- */

.assets-layout {
  display: flex;
  gap: 20px;
}

.assets-main { flex: 1; min-width: 0; }

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.asset-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
  position: relative;
}
.asset-card:hover { border-color: var(--text-3); box-shadow: var(--shadow-md); }
.asset-card:focus-within { outline: 2px solid var(--primary); outline-offset: -2px; }
.asset-card.selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

.asset-thumb {
  width: 100%;
  height: 140px;
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.asset-thumb svg { width: 36px; height: 36px; color: var(--text-3); }

.asset-thumb-label {
  position: absolute;
  bottom: 6px;
  right: 6px;
}

.asset-info { padding: 10px 12px; }

.asset-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.asset-alt {
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 6px;
}

.asset-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.asset-meta .chip { font-size: 10px; padding: 1px 6px; }

.asset-size {
  font-size: 11px;
  color: var(--text-2);
  margin-left: auto;
  white-space: nowrap;
}

/* Detail panel */
.asset-detail {
  width: 340px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: sticky;
  top: 72px;
  align-self: flex-start;
}

.detail-preview {
  width: 100%;
  height: 220px;
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-light);
  overflow: hidden;
}
.detail-preview img { width: 100%; height: 100%; object-fit: contain; }
.detail-preview svg { width: 48px; height: 48px; color: var(--text-3); }

.detail-body { padding: 16px; }

.detail-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.detail-field { margin-bottom: 12px; }
.detail-field-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}
.detail-field-value { font-size: 13px; color: var(--text); line-height: 1.4; }
.detail-field-value.muted { color: var(--text-3); font-style: italic; }
/* file value keeps its original monospace stack (differs from --font-mono token) */
.detail-field-value.file { font-family: 'SF Mono','Fira Code',monospace; font-size: 12px; }
/* url value: break long urls */
.detail-field-value.url { word-break: break-all; font-size: 12px; }
/* detail-empty placeholder icon */
.detail-empty-icon { opacity: .4; }
/* assets empty-state description */
.asset-empty-desc { max-width: 440px; margin: 0 auto; }

.detail-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

.detail-actions { display: flex; gap: 6px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-light); }

.detail-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

@media (max-width: 900px) {
  .assets-layout { flex-direction: column; }
  .asset-detail { width: 100%; position: static; }
}

/* Upload form. Visibility is toggled via the [hidden] attribute (principle 17):
   when not hidden the overlay is a flex centering container. */
.upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
  display: flex;
}
.upload-form {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow-md);
}
.upload-form h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px;
}
.upload-form .form-group {
  margin-bottom: 12px;
}
.upload-form .form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 4px;
}
.upload-form .form-group input,
.upload-form .form-group select {
  width: 100%;
  box-sizing: border-box;
}
.upload-form .form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.upload-msg {
  font-size: 13px;
  margin-top: 8px;
  min-height: 20px;
}
.upload-msg.error { color: var(--error); }
.upload-msg.success { color: var(--success); }
