/* ═══════════════════════════════════════════════════
   HDG Document Library — Styles
   ISO 9001:2014 compliant Document Library UI
═══════════════════════════════════════════════════ */

/* ── PAGE LAYOUT ───────────────────────────────── */
.library-page {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.library-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.library-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-text-primary, #1a1a2e);
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.library-title-icon {
  font-size: 1.8rem;
}

.library-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted, #888);
  margin: 0;
  font-style: italic;
}

/* ── CATEGORY TABS ──────────────────────────────── */
.library-category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.lib-tab {
  padding: 8px 18px;
  border-radius: 20px;
  border: 2px solid var(--color-border, #ddd);
  background: white;
  color: var(--color-text-secondary, #555);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.lib-tab:hover {
  border-color: var(--color-accent, #e8b84b);
  color: var(--color-accent, #e8b84b);
  background: #fffbf0;
}

.lib-tab.active {
  background: var(--color-accent, #e8b84b);
  border-color: var(--color-accent, #e8b84b);
  color: white;
  font-weight: 600;
}

/* ── SEARCH BAR ────────────────────────────────── */
.library-search-bar {
  position: relative;
  margin-bottom: 20px;
}

.library-search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1.5px solid var(--color-border, #ddd);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--color-text-primary, #1a1a2e);
  background: white;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.library-search-input:focus {
  border-color: var(--color-accent, #e8b84b);
  outline: none;
}

.library-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
}

/* ── GRID ─────────────────────────────────────── */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.library-loading,
.library-error,
.library-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted, #888);
  font-size: 0.95rem;
}

.library-empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* ── CARD ─────────────────────────────────────── */
.lib-card {
  border: 1.5px solid var(--color-border, #e0e0e0);
  border-radius: 10px;
  background: white;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
  position: relative;
}

.lib-card:hover {
  box-shadow: 0 4px 18px rgba(0,0,0,0.12);
  transform: translateY(-2px);
  border-color: var(--color-accent, #e8b84b);
}

.lib-card-selected {
  border-color: var(--color-accent, #e8b84b) !important;
  box-shadow: 0 0 0 3px rgba(232, 184, 75, 0.25) !important;
}

.lib-card-preview {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f8f8;
  border-bottom: 1px solid #eee;
}

.lib-card-image {
  background-size: cover;
  background-position: center;
}

.lib-card-icon {
  font-size: 3.5rem;
}

.lib-card-body {
  padding: 12px;
}

.lib-card-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-primary, #1a1a2e);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.lib-badge {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 10px;
  background: #f0f0f0;
  color: #555;
  white-space: nowrap;
}

.lib-badge-ext {
  background: #e8f4fd;
  color: #2d7dca;
  font-weight: 600;
}

.lib-badge-version {
  background: #fff3cd;
  color: #856404;
  font-weight: 600;
}

.lib-card-desc {
  font-size: 0.75rem;
  color: #777;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-card-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #aaa;
}

/* ── SELECTION CHECKBOX ───────────────────────── */
.lib-select-checkbox {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 1.4rem;
  line-height: 1;
  background: white;
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  z-index: 2;
  transition: color 0.2s;
  color: #aaa;
}

.lib-select-checkbox.checked {
  color: var(--color-accent, #e8b84b);
}

/* ── SELECTION BAR ────────────────────────────── */
.lib-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-accent, #e8b84b);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-weight: 600;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── MODALS ───────────────────────────────────── */
.lib-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.lib-modal {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
}

.lib-modal-wide {
  max-width: 780px;
}

.lib-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #eee;
}

.lib-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--color-text-primary, #1a1a2e);
}

.lib-modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #999;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.lib-modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

.lib-modal-body {
  padding: 20px 24px;
  flex: 1;
}

.lib-modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ── FORM ─────────────────────────────────────── */
.lib-form-group {
  margin-bottom: 18px;
}

.lib-form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lib-form-group input[type="text"],
.lib-form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #333;
  background: white;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.lib-form-group input:focus,
.lib-form-group select:focus {
  border-color: var(--color-accent, #e8b84b);
  outline: none;
}

.lib-input-readonly {
  background: #f8f8f8 !important;
  color: #888 !important;
  font-family: monospace;
  font-size: 0.75rem !important;
}

.lib-form-group small {
  display: block;
  font-size: 0.75rem;
  color: #888;
  margin-top: 4px;
}

/* ── FILE DROP AREA ───────────────────────────── */
.lib-file-drop-area {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.lib-file-drop-area:hover,
.lib-drop-active {
  border-color: var(--color-accent, #e8b84b);
  background: #fffbf0;
}

.lib-drop-icon {
  font-size: 2rem;
}

.lib-drop-text {
  font-size: 0.88rem;
  color: #555;
}

.lib-drop-hint {
  font-size: 0.75rem;
  color: #999;
}

/* ── FILE PREVIEW (in upload modal) ───────────── */
.lib-file-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f8fff8;
  border: 1.5px solid #b7e4b7;
  border-radius: 6px;
}

.lib-file-preview-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  font-size: 0.85rem;
  color: #333;
  overflow: hidden;
}

#libFileIcon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

#libFileName {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#libFileSize {
  color: #888;
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.lib-remove-file {
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  font-size: 1rem;
  padding: 4px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.2s;
}

.lib-remove-file:hover {
  color: #e05;
}

/* ── DETAIL MODAL ─────────────────────────────── */
.lib-detail-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 24px;
}

@media (max-width: 600px) {
  .lib-detail-layout {
    grid-template-columns: 1fr;
  }
}

.lib-detail-preview {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #f8f8f8;
  border-radius: 8px;
  padding: 16px;
  min-height: 200px;
}

.lib-detail-img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 4px;
  object-fit: contain;
}

.lib-detail-icon-large {
  font-size: 5rem;
  margin: auto;
}

.lib-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.lib-info-table td {
  padding: 7px 4px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}

.lib-info-table td:first-child {
  color: #888;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  padding-right: 16px;
  width: 120px;
}

/* ── VERSION HISTORY ───────────────────────────── */
.lib-version-history {
  margin-top: 20px;
}

.lib-version-history h4 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin: 0 0 10px 0;
}

.lib-version-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  margin-bottom: 4px;
  background: #f9f9f9;
}

.lib-version-archived {
  opacity: 0.6;
}

.lib-version-status {
  font-weight: 600;
}

/* ── DETAIL ACTIONS ───────────────────────────── */
.lib-detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── TOAST ─────────────────────────────────────── */
.lib-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 99999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  animation: libToastIn 0.3s ease;
  white-space: nowrap;
}

.lib-toast-success {
  background: #1a7a45;
  color: white;
}

.lib-toast-error {
  background: #c0392b;
  color: white;
}

.lib-toast-warning {
  background: #e8b84b;
  color: white;
}

@keyframes libToastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── BUTTON DANGER ─────────────────────────────── */
.btn-danger {
  background: #e74c3c !important;
  border-color: #e74c3c !important;
  color: white !important;
}

.btn-danger:hover {
  background: #c0392b !important;
}


/* ── DETAIL MODAL FOOTER SPACING ───────────────────── */
.lib-modal-overlay .modal-actions {
  padding: 16px 24px 24px !important;
  border-top: 1px solid #eee;
  gap: 10px;
}
.lib-modal-overlay .modal-actions .button {
  flex: 0 0 auto;
}
