/*************************************************
 * Library Filters
 *************************************************/

#library-filters {
  margin-bottom: 8px;
}

/*************************************************
 * Filter Rows
 *************************************************/

.filter-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 4px;
}

.filter-row.top {
  margin-bottom: 4px;
}

.filter-row.bottom {
  margin-bottom: 6px;
}

/*************************************************
 * Filter Buttons
 *************************************************/

.filter-row button {
  padding: 6px 12px;
  min-width: 90px;

  background: linear-gradient(
    to bottom,
    #f0f2f4,
    #e3e6ea
  );

  border: 1px solid #b8bec7;
  border-radius: 6px;

  font-size: 14px;
  font-weight: 500;
  color: #0b2d4f;

  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  cursor: pointer;

  transition:
    background 0.15s ease,
    box-shadow 0.15s ease,
    font-weight 0.15s ease;
}

.filter-row.bottom button {
  min-width: 70px;
  padding: 6px 10px;
}

.filter-row button.active {
  background: linear-gradient(
    to bottom,
    #e0e4ea,
    #d2d7df
  );

  font-weight: 700;
  border-color: #9ea5af;

  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.25),
    inset 0 -1px 0 rgba(255, 255, 255, 0.4);
}

.filter-row button:not(.active):hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/*************************************************
 * Library Search
 *************************************************/

.library-search {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}

.library-search input {
  width: 100%;
  max-width: 280px;

  padding: 8px 12px;
  font-size: 14px;

  border-radius: 6px;
  border: 1px solid #b8bec7;

  background: linear-gradient(
    to bottom,
    #f7f8fa,
    #e9ecf0
  );

  color: #0b2d4f;

  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}

.library-search input:focus {
  outline: none;
  border-color: #0b2d4f;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(11, 45, 79, 0.15);
}

/*************************************************
 * File Library Container
 *
 * Portrait: Fixed height to align:
 *   - Top edge with bottom of upload buttons
 *   - Bottom edge with bottom of theme cards
 *
 * Landscape: Fixed height for 12 rows + header
 *************************************************/

#file-library {
  margin-top: 4px;

  background: #ffffff;
  border-radius: 14px;
  padding: 12px;

  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3);

  display: flex;
  flex-direction: column;

  overflow-y: auto;
  min-height: 0;

  /*
   * Portrait mode: fixed height
   * flex: none overrides flex: 1 from layout.css
   * Adjust height value to fine-tune alignment.
   */
  flex: none;
  height: 890px;
}

/*************************************************
 * Empty State
 *************************************************/

.library-empty {
  padding: 24px;
  text-align: center;
  color: #6b7280;
}

/*************************************************
 * Library Table
 *************************************************/

.library-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.library-table th {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
}

.library-table td {
  padding: 8px;
}

.library-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid rgba(0, 0, 0, 0.10);
}

.library-table tbody tr {
  cursor: pointer;
}

.library-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.04);
}

/*************************************************
 * Selection State
 *************************************************/

.library-table tr.selected {
  background: rgba(11, 45, 79, 0.08);
}

.library-table tr.selected td:first-child {
  box-shadow: inset 6px 0 0 #02a8ff;
}

.library-table tr.selected:hover {
  background: rgba(11, 45, 79, 0.12);
}

/*************************************************
 * Library Actions
 *************************************************/

.library-table td button {
  background: none;
  border: none;
  padding: 0;
  margin-right: 12px;

  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.library-table .btn-secondary {
  color: #0b2d4f;
}

.library-table .btn-secondary:hover {
  text-decoration: underline;
}

.library-table .btn-danger {
  color: #b91c1c;
}

.library-table .btn-danger:hover {
  text-decoration: underline;
}

/*************************************************
 * Type Cell (with preview button below)
 *************************************************/

.library-table .type-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

/*************************************************
 * Download Spinner in Type Cell
 *
 * Hidden by default, shown when row has .downloading class
 * Replaces the type label and preview button
 *************************************************/

.library-table .download-spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 3px solid #d1d5db;
  border-top-color: #0b2d4f;
  border-radius: 50%;
  animation: type-cell-spin 0.8s linear infinite;
}

@keyframes type-cell-spin {
  to {
    transform: rotate(360deg);
  }
}

/* When downloading: show spinner, hide type label and preview */
.library-table tr.downloading .download-spinner {
  display: block;
}

.library-table tr.downloading .type-label,
.library-table tr.downloading .btn-preview {
  display: none;
}

/* Dim the row slightly and prevent clicks */
.library-table tr.downloading {
  opacity: 0.6;
  pointer-events: none;
}

/*************************************************
 * Preview Button (Eyeball Icon)
 *************************************************/

.library-table .btn-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 3px;

  background: none;
  border: 1px solid #d1d5db;
  border-radius: 4px;

  color: #6b7280;
  cursor: pointer;

  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.library-table .btn-preview:hover {
  background: rgba(11, 45, 79, 0.08);
  border-color: #0b2d4f;
  color: #0b2d4f;
}

.library-table .btn-preview .preview-icon {
  width: 14px;
  height: 14px;
}

/*************************************************
 * Landscape Layout: Fixed height for 12 rows + header
 * Reduced by 10% from 492px = 443px
 *************************************************/

body[data-layout="landscape"] #file-library {
  height: 443px;
}

/*************************************************
 * Bundle Rows
 *************************************************/

.library-table tr.bundle-row {
  background: rgba(11, 45, 79, 0.03);
}

.library-table tr.bundle-row:hover {
  background: rgba(11, 45, 79, 0.07);
}

.bundle-count {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  background: #e5e7eb;
  border-radius: 4px;
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
}

/* Stacked EXCEL/BUNDLE type label */
.library-table .type-label .type-excel,
.library-table .type-label .type-bundle {
  display: block;
  line-height: 1.1;
}

.library-table .type-label .type-excel {
  font-size: 11px;
  color: #059669;
  font-weight: 600;
}

.library-table .type-label .type-bundle {
  font-size: 10px;
  color: #6b7280;
  font-weight: 500;
}
