/* Shared list and detail layout. Loaded after page-specific styles. */

.ke-list-page {
  --ke-list-thumb-size: 84px;
  display: block;
  width: 100%;
  max-width: var(--layout-max-width, 1200px);
  margin: 0 auto;
  box-sizing: border-box;
  color: var(--ke-text);
}

.ke-list-page > center {
  display: block;
  width: 100%;
}

.ke-list-page h1 {
  line-height: 1.2;
  margin-top: 0;
}

.ke-list-page table {
  width: 100%;
  max-width: var(--layout-max-width, 1200px);
  margin: 0 auto;
  border-collapse: collapse;
  border-spacing: 0;
}

.ke-list-page tr.swipe-row {
  display: table-row !important;
  height: auto !important;
}

.ke-list-page tr.swipe-row > td.action {
  display: none !important;
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  pointer-events: none !important;
}

.ke-list-page tr.swipe-row > td.swipe-element {
  display: table-cell !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  padding: 10px !important;
  border: 1px solid var(--ke-border) !important;
  border-radius: var(--ke-radius, 8px);
  background: var(--ke-surface) !important;
  box-sizing: border-box;
  overflow: hidden;
}

.ke-list-page tr.swipe-row .item-info,
.ke-list-page tr.done-row .item-info {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box;
}

.ke-list-page--todo tr.swipe-row .item-info {
  padding-right: 150px !important;
}

.ke-list-page tr.swipe-row .image,
.ke-list-page tr.swipe-row .square-thumbnail,
.ke-list-page tr.done-row .image,
.ke-list-page tr.done-row .square-thumbnail {
  width: var(--ke-list-thumb-size) !important;
  height: var(--ke-list-thumb-size) !important;
  max-width: var(--ke-list-thumb-size) !important;
  max-height: var(--ke-list-thumb-size) !important;
  flex: 0 0 var(--ke-list-thumb-size);
  object-fit: cover;
  box-sizing: border-box;
}

.ke-list-page tr.swipe-row .image,
.ke-list-page tr.done-row .image {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--ke-radius-sm, 4px);
  background: var(--ke-surface-2);
}

.ke-list-page tr.swipe-row .item-details,
.ke-list-page tr.done-row .item-details {
  display: flex !important;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0 !important;
  max-width: none !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  gap: 5px;
  box-sizing: border-box;
}

.ke-list-page tr.swipe-row .item-details > .centered,
.ke-list-page tr.done-row .item-details > .centered,
.ke-list-page tr.swipe-row .item-details strong,
.ke-list-page tr.done-row .item-details strong {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
  white-space: normal !important;
  line-height: 1.25;
}

.ke-list-page tr.group-header td,
.ke-list-page tr.category-header td {
  padding: 8px 10px;
  border: 0;
  color: var(--ke-text-muted);
  background: transparent;
  font-size: var(--ke-font-sm, 12px);
  font-weight: 700;
  text-align: left;
}

.ke-list-page .top-actions,
.ke-list-page .button-container,
.ke-list-page .category-actions,
.ke-list-page .category-footer-actions,
.ke-list-page .speisen-bottom-actions,
.ke-list-page .erl-btn-row,
.ke-list-page .erl-chips-ctrl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ke-list-page .ke-btn,
.ke-detail-page .ke-btn {
  min-height: 36px;
  line-height: 1.2;
}

.ke-list-page .ke-btn--sm,
.ke-list-page .ke-btn-sm,
.ke-detail-page .ke-btn--sm,
.ke-detail-page .ke-btn-sm {
  min-height: 30px;
}

.ke-list-page--einkauf .buy-button-wrapper {
  justify-content: flex-start;
}

.ke-list-page--einkauf .kaufe-ich-button {
  width: auto !important;
  min-width: 120px;
  min-height: 36px;
  margin: 0;
  padding: 6px 12px;
}

.ke-list-page .erl-stat-btn,
.ke-list-page .back-button,
.ke-list-page .tb-save-btn,
.ke-list-page .tb-skip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--ke-border);
  border-radius: var(--ke-radius-sm, 4px);
  font-family: var(--ke-font-family);
  font-size: var(--ke-font);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}

.ke-list-page .erl-stat-btn,
.ke-list-page .back-button {
  background: var(--ke-surface-2);
  color: var(--ke-text);
}

.ke-list-page .tb-save-btn {
  background: var(--ke-success);
  border-color: var(--ke-success);
  color: #fff;
}

.ke-list-page .tb-skip-btn {
  background: transparent;
  color: var(--ke-text-muted);
}

/* Completed ToDos use cards rather than table rows. */
.ke-list-page--todo-completed .erl-page {
  width: 100%;
  max-width: var(--layout-max-width, 1200px);
  padding-left: 0;
  padding-right: 0;
}

.ke-list-page--todo-completed .erl-card {
  min-height: 76px;
}

/* Detail pages share the same outer rhythm and action wrapping. */
.ke-detail-page {
  display: block;
  width: 100%;
  max-width: var(--layout-max-width, 1200px);
  margin: 0 auto;
  box-sizing: border-box;
  color: var(--ke-text);
}

.ke-detail-page .detail-section,
.ke-detail-page .info-block {
  border-radius: var(--ke-radius, 8px);
  margin: 12px auto;
  padding: 16px;
  box-sizing: border-box;
}

.ke-detail-page .detail-actions,
.ke-detail-page .header-actions,
.ke-detail-page .bottom-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ke-detail-page .info-row {
  min-height: 36px;
  gap: 12px;
  line-height: 1.35;
}

.ke-detail-page .section-title,
.ke-detail-page .detail-title {
  line-height: 1.3;
}

@media (max-width: 640px) {
  .ke-list-page,
  .ke-detail-page {
    max-width: 100%;
  }

  .ke-list-page {
    --ke-list-thumb-size: 72px;
  }

  .ke-list-page tr.swipe-row > td.swipe-element {
    padding: 8px !important;
  }

  .ke-list-page--todo tr.swipe-row .item-info {
    padding-right: 120px !important;
  }

  .ke-detail-page .detail-section,
  .ke-detail-page .info-block {
    padding: 12px;
    margin: 8px auto;
  }

  .ke-detail-page .detail-actions,
  .ke-detail-page .header-actions,
  .ke-detail-page .bottom-buttons {
    align-items: stretch;
  }

  .ke-detail-page .detail-actions .ke-btn,
  .ke-detail-page .header-actions .ke-btn,
  .ke-detail-page .bottom-buttons .ke-btn {
    flex: 1 1 auto;
  }
}
