/* PrintVault module */

.pv-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: calc(100vh - 64px);
  overflow: hidden;
}
.pv-sidebar {
  border-right: 1px solid var(--border-light);
  background: var(--bg-panel);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.pv-sidebar-top {
  padding: .75rem;
  border-bottom: 1px solid var(--border-light);
  position: sticky; top: 0; background: var(--bg-panel); z-index: 1;
  display: flex; flex-direction: column; gap: .5rem;
}
.pv-search {
  display: flex; align-items: center; gap: .4rem;
  background: var(--bg-page); border: 1px solid var(--border-light);
  border-radius: 8px; padding: .35rem .6rem;
}
.pv-search input { border: none; outline: none; background: transparent; font-size: .85rem; color: var(--text-main); flex: 1; }
.pv-search input::placeholder { color: var(--text-muted); }
.pv-main { overflow-y: auto; background: var(--bg-page); }

/* Sidebar nav */
.pv-nav-section { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: .75rem .75rem .25rem; }
.pv-nav-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .75rem; cursor: pointer;
  font-size: .85rem; color: var(--text-muted);
  border-radius: 8px; margin: 1px .5rem;
  transition: background .12s, color .12s;
}
.pv-nav-item:hover { background: var(--bg-page); color: var(--text-main); }
.pv-nav-item.active { background: #eff6ff; color: var(--primary); font-weight: 600; }
.pv-nav-badge { margin-left: auto; font-size: .7rem; font-weight: 700; background: var(--bg-page); color: var(--text-muted); padding: 1px 6px; border-radius: 999px; }
.pv-nav-item.active .pv-nav-badge { background: #dbeafe; color: var(--primary); }
.pv-cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* File type filter chips */
.pv-type-chips { display: flex; gap: .3rem; flex-wrap: wrap; padding: .25rem .75rem .5rem; }
.pv-chip {
  font-size: .72rem; font-weight: 600; padding: .2rem .5rem;
  border-radius: 999px; cursor: pointer; border: 1.5px solid var(--border-light);
  color: var(--text-muted); transition: all .12s;
}
.pv-chip:hover { border-color: var(--primary); color: var(--primary); }
.pv-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pv-chip.stl.active  { background: #8b5cf6; border-color: #8b5cf6; }
.pv-chip.3mf.active  { background: #3b82f6; border-color: #3b82f6; }
.pv-chip.gcode.active { background: #10b981; border-color: #10b981; }

/* Main header */
.pv-main-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; background: var(--bg-panel);
  border-bottom: 1px solid var(--border-light); gap: .75rem; flex-wrap: wrap;
}
.pv-main-header h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.pv-subtitle { font-size: .8rem; color: var(--text-muted); }

/* Models grid */
.pv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1.25rem 1.5rem 2rem;
}
.pv-card {
  background: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  transition: border-color .15s, box-shadow .12s;
  display: flex; flex-direction: column;
}
.pv-card:hover { border-color: #cbd5e1; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.pv-card-thumb {
  aspect-ratio: 4/3; background: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; overflow: hidden;
}
.pv-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pv-card-body { padding: .75rem; flex: 1; display: flex; flex-direction: column; gap: .25rem; }
.pv-card-name { font-size: .875rem; font-weight: 600; color: var(--text-main); line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pv-card-meta { font-size: .72rem; color: var(--text-muted); display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; padding-top: .25rem; }
.pv-type-badge { font-size: .68rem; font-weight: 700; padding: .1rem .4rem; border-radius: 4px; text-transform: uppercase; }
.pv-type-stl   { background: #ede9fe; color: #7c3aed; }
.pv-type-3mf   { background: #dbeafe; color: #1d4ed8; }
.pv-type-gcode { background: #dcfce7; color: #15803d; }
.pv-type-g     { background: #dcfce7; color: #15803d; }
.pv-type-gco   { background: #dcfce7; color: #15803d; }

/* Empty state */
.pv-empty { text-align: center; padding: 4rem 2rem; color: var(--text-muted); }
.pv-empty .icon { font-size: 3rem; opacity: .3; margin-bottom: 1rem; }

/* Modal */
.pv-modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(15,23,42,.5); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 1rem;
}
.pv-modal-backdrop.show { display: flex; }
.pv-modal {
  background: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: 14px; width: 100%; max-width: 520px;
  max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 40px rgba(0,0,0,.15);
  animation: pvModalIn .18s ease;
}
@keyframes pvModalIn { from{opacity:0;transform:scale(.96) translateY(-8px)} to{opacity:1;transform:none} }
.pv-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-light); }
.pv-modal-header h3 { font-size: 1rem; font-weight: 700; margin: 0; }
.pv-modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.2rem; border-radius: 6px; padding: .2rem .4rem; }
.pv-modal-close:hover { background: var(--bg-page); }
.pv-modal-body { padding: 1.25rem; overflow-y: auto; display: flex; flex-direction: column; gap: .9rem; }
.pv-modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: .5rem; }

/* Upload zone */
.pv-drop-zone {
  border: 2px dashed var(--border-light); border-radius: 10px;
  padding: 2rem; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s; color: var(--text-muted);
}
.pv-drop-zone:hover, .pv-drop-zone.over { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
.pv-drop-zone .icon { font-size: 2rem; margin-bottom: .5rem; }
.pv-file-chosen { font-size: .82rem; color: var(--primary); font-weight: 600; margin-top: .4rem; }

/* Form */
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-label { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.form-control { background: #fff; border: 1px solid var(--border-light); color: var(--text-main); border-radius: 8px; padding: .5rem .75rem; font-size: .875rem; width: 100%; outline: none; transition: border-color .15s; font-family: inherit; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .85rem; border-radius: 8px; font-size: .875rem; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: all .15s; white-space: nowrap; }
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-secondary { background: var(--bg-panel); color: var(--text-main); border-color: var(--border-light); }
.btn-secondary:hover { background: var(--bg-page); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: .25rem .55rem; font-size: .78rem; }
.btn-ghost { background: transparent; border: none; color: var(--text-muted); padding: .2rem .4rem; }
.btn-ghost:hover { color: var(--text-main); background: var(--bg-page); border-radius: 6px; }
.btn-icon { padding: .3rem; min-width: 30px; justify-content: center; }

/* Detail panel */
.pv-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .75rem; }
.pv-detail-item { display: flex; flex-direction: column; gap: .1rem; }
.pv-detail-label { font-size: .72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.pv-detail-value { font-size: .875rem; color: var(--text-main); }
.pv-detail-thumb { width: 100%; aspect-ratio: 4/3; background: #f1f5f9; border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 4rem; margin-bottom: .75rem; }
.pv-detail-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Toasts */
.pv-toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.pv-toast { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: 10px; padding: .7rem 1rem; font-size: .875rem; min-width: 200px; color: var(--text-main); box-shadow: 0 4px 16px rgba(0,0,0,.12); border-left: 4px solid var(--primary); animation: pvToastIn .2s ease; }
.pv-toast.error { border-left-color: var(--danger); }
@keyframes pvToastIn { from{opacity:0;transform:translateX(16px)} to{opacity:1;transform:none} }

/* Upload progress */
.pv-progress { height: 4px; background: var(--border-light); border-radius: 999px; overflow: hidden; margin-top: .4rem; }
.pv-progress-bar { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }

/* Responsive */
@media (max-width: 768px) {
  .pv-layout { grid-template-columns: 1fr; height: auto; }
  .pv-sidebar { display: none; }
  .pv-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); padding: .75rem; }
  .pv-main-header { padding: .75rem 1rem; }
}

/* Dark mode */
[data-theme="dark"] .pv-sidebar { background: var(--bg-panel); }
[data-theme="dark"] .pv-card { background: var(--bg-panel); border-color: var(--border-light); }
[data-theme="dark"] .pv-card-thumb { background: #1c2128; }
[data-theme="dark"] .pv-modal { background: var(--bg-panel); }
[data-theme="dark"] .form-control { background: #1c2128; border-color: var(--border-light); color: var(--text-main); }
[data-theme="dark"] .pv-drop-zone { border-color: var(--border-light); }
[data-theme="dark"] .pv-drop-zone:hover { background: rgba(59,130,246,.1); }
[data-theme="dark"] .pv-main-header { background: var(--bg-panel); }
[data-theme="dark"] .pv-type-stl   { background: rgba(139,92,246,.2); }
[data-theme="dark"] .pv-type-3mf   { background: rgba(59,130,246,.2); }
[data-theme="dark"] .pv-type-gcode, [data-theme="dark"] .pv-type-g, [data-theme="dark"] .pv-type-gco { background: rgba(16,185,129,.2); }
