/* Library Manager page - full-page dashboard for product_inventory */
/* Scoped to #library-manager-root to avoid affecting Product Library modal */
/* Natural page scroll – content flows, no locked viewport frame */

/* Allow page to scroll naturally; no viewport lock */
#page-content:has(.library-manager-page) {
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0 !important;
  padding-bottom: 40px !important;
  margin-bottom: 0 !important;
  height: auto !important;
  min-height: calc(100vh - 60px);
}

#library-manager-root.library-manager-page {
  margin-left: var(--sidebar-width, 260px);
  width: calc(100% - var(--sidebar-width, 260px));
  min-height: calc(100vh - 60px);
  padding: 84px 20px 40px 20px;
  max-width: none;
  margin-right: 0;
  margin-bottom: 0;
  box-sizing: border-box;
  background: var(--content-area-bg, #f8fafc);
  overflow: visible;
  display: flex;
  flex-direction: column;
}

#library-manager-root .lm-header {
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

#library-manager-root .lm-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 0.15rem 0;
  line-height: 1.3;
}

#library-manager-root .lm-subtitle {
  font-size: 0.9rem;
  color: #6b7280;
  margin: 0;
  line-height: 1.3;
}

#library-manager-root .lm-breadcrumb {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: #374151;
  flex-shrink: 0;
}

#library-manager-root .lm-breadcrumb-link {
  color: #4f46e5;
  text-decoration: none;
}

#library-manager-root .lm-breadcrumb-link:hover {
  text-decoration: underline;
}

#library-manager-root .lm-breadcrumb-sep {
  margin: 0 0.35rem;
  color: #9ca3af;
}

#library-manager-root .lm-stats {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

/* Main layout: sidebar + main side by side; grows with content */
#library-manager-root .lm-layout {
  display: flex;
  gap: 1rem;
  flex: 1;
  min-height: 300px;
  overflow: visible;
}

#library-manager-root .lm-sidebar {
  width: 200px;
  flex-shrink: 0;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.6rem;
  background: #f9fafb;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#library-manager-root .lm-folder-tree {
  min-height: 0;
}

#library-manager-root .lm-tree-folder {
  padding: 0.45rem 0.5rem;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.3;
}

#library-manager-root .lm-tree-folder:hover {
  background: #e5e7eb;
}

#library-manager-root .lm-tree-folder.lm-current {
  background: #ddd6fe;
  color: #4338ca;
}

#library-manager-root .lm-btn-new-folder {
  margin-top: 0.4rem;
  width: 100%;
  padding: 0.45rem 0.5rem;
  font-size: 0.875rem;
  border: 1px dashed #9ca3af;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  color: #6b7280;
}

#library-manager-root .lm-btn-new-folder:hover {
  background: #f3f4f6;
  color: #374151;
}

#library-manager-root .lm-main {
  flex: 1;
  min-width: 0;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow: visible;
}

#library-manager-root .lm-quick-add {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  background: #fff;
  flex-shrink: 0;
}

#library-manager-root .lm-quick-add-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  line-height: 1.3;
}

#library-manager-root .lm-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

#library-manager-root .lm-form-row:last-child {
  margin-bottom: 0;
}

#library-manager-root .lm-form-row label {
  display: block;
  font-size: 0.825rem;
  color: #6b7280;
  margin-bottom: 0.15rem;
}

#library-manager-root .lm-form-field {
  flex: 1;
  min-width: 100px;
}

#library-manager-root .lm-form-field input,
#library-manager-root .lm-form-field textarea {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  box-sizing: border-box;
  line-height: 1.35;
}

#library-manager-root .lm-form-field textarea {
  min-height: 48px;
  resize: vertical;
  max-height: 80px;
}

#library-manager-root .lm-btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

#library-manager-root .lm-btn-primary {
  background: #4f46e5;
  color: #fff;
}

#library-manager-root .lm-btn-primary:hover:not(:disabled) {
  background: #4338ca;
}

#library-manager-root .lm-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Contents area grows with content; main column scrolls as a whole so footer scrolls with page */
#library-manager-root .lm-contents-wrap {
  flex: 0 0 auto;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.75rem;
  background: #fff;
  min-height: 120px;
}

#library-manager-root .lm-contents {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.65rem;
}

#library-manager-root .lm-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.6rem;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: box-shadow 0.15s;
}

#library-manager-root .lm-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#library-manager-root .lm-card-icon {
  font-size: 1.4rem;
  color: #6b7280;
  display: block;
  margin-bottom: 0.25rem;
}

#library-manager-root .lm-card-thumb {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  margin-bottom: 0.25rem;
  background: #f3f4f6;
}

#library-manager-root .lm-card-name {
  font-size: 0.875rem;
  word-break: break-word;
  display: block;
  line-height: 1.3;
}

#library-manager-root .lm-footer-actions {
  margin-top: 0.25rem;
  padding-top: 0.35rem;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

#library-manager-root .lm-open-full {
  font-size: 0.9rem;
  color: #4f46e5;
  text-decoration: none;
}

#library-manager-root .lm-open-full:hover {
  text-decoration: underline;
}

#library-manager-root .lm-loading,
#library-manager-root .lm-error,
#library-manager-root .lm-empty {
  padding: 1rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
}

#library-manager-root .lm-error {
  color: #dc2626;
}

#library-manager-root .lm-signed-out {
  padding: 2rem;
  text-align: center;
  color: #6b7280;
  font-size: 1rem;
}

#library-manager-root .lm-notification-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#library-manager-root .lm-notification {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#library-manager-root .lm-notification-success {
  background: #d1fae5;
  color: #065f46;
}

#library-manager-root .lm-notification-error {
  background: #fee2e2;
  color: #991b1b;
}

#library-manager-root .lm-notification-info {
  background: #dbeafe;
  color: #1e40af;
}

/* Toolbar row: Select All */
#library-manager-root .lm-toolbar-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

#library-manager-root .lm-toolbar-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

#library-manager-root .lm-toolbar-check input {
  margin: 0;
  cursor: pointer;
}

/* Cards with checkbox and action menu */
#library-manager-root .lm-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#library-manager-root .lm-card-check {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  margin: 0;
  z-index: 2;
  cursor: pointer;
  width: 1rem;
  height: 1rem;
}

#library-manager-root .lm-card-actions {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  z-index: 2;
}

#library-manager-root .lm-ellipsis-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#library-manager-root .lm-ellipsis-btn:hover {
  background: #e5e7eb;
  color: #374151;
}

#library-manager-root .lm-action-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 2px;
  min-width: 140px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  overflow: hidden;
}

#library-manager-root .lm-action-menu.lm-open {
  display: block;
}

#library-manager-root .lm-menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.875rem;
  border: none;
  background: none;
  cursor: pointer;
  color: #374151;
}

#library-manager-root .lm-menu-item:hover {
  background: #f3f4f6;
}

#library-manager-root .lm-breadcrumb-current {
  color: #6b7280;
}

/* Footer section: Trash icon + batch actions */
#library-manager-root .lm-footer-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.25rem;
  padding-top: 0.35rem;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

#library-manager-root .lm-trash-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: #6b7280;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
}

#library-manager-root .lm-trash-icon:hover {
  background: #f3f4f6;
  color: #374151;
}

#library-manager-root .lm-trash-icon i {
  font-size: 1rem;
}

#library-manager-root .lm-footer-actions-divider {
  width: 1px;
  height: 1.25rem;
  background: #e5e7eb;
}

#library-manager-root .lm-batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#library-manager-root .lm-btn-danger {
  background: #dc2626;
  color: #fff;
}

#library-manager-root .lm-btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

#library-manager-root .lm-btn-success {
  background: #16a34a;
  color: #fff;
}

#library-manager-root .lm-btn-success:hover:not(:disabled) {
  background: #15803d;
}
