/* ===== main.css (revised) ===== */

:root,
[data-coreui-theme="light"] {
  --cui-body-bg: #fffcf7;
  --bs-body-bg: #fffcf7;
}

html,
body {
  background-color: #fffcf7 !important;
}

.header {
  padding: 0;
  background-color: #fbf5ed !important;
}

.header .breadcrumb-bar {
  background-color: #fffcf7 !important;
}

.header .breadcrumb-bar .breadcrumb {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  background-color: transparent !important;
}

#sidebar.sidebar {
  background-color: #fefaf2 !important;
  box-shadow: inset -1px 0 0 #fbf5ed !important;
}

#sidebar .sidebar-header,
#sidebar .sidebar-footer {
  background-color: transparent !important;
}

#sidebar .nav-link.active,
#sidebar .nav-link[aria-current="page"],
#sidebar .nav-group.show > .nav-group-items .nav-link.active {
  background-color: #fbf5ed !important;
}

/* --- Sidebar push layout -------------------------------------------------- */
.sidebar.sidebar-fixed ~ .wrapper {
  padding-left: var(--cui-sidebar-width, 16rem);
}
@media (min-width: 992px) {
  .sidebar.sidebar-fixed.sidebar-narrow ~ .wrapper,
  .sidebar.sidebar-fixed.sidebar-narrow-unfoldable ~ .wrapper {
    padding-left: 4rem;
  }
  .sidebar.sidebar-fixed.hide ~ .wrapper {
    padding-left: 0;
  }
}
@media (max-width: 991.98px) {
  .sidebar.sidebar-fixed ~ .wrapper {
    padding-left: 0;
  }
}

/* --- Minor utilities ------------------------------------------------------ */
.toast-container {
  z-index: 1080;
}
.avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.avatar-32 {
  width: 32px;
  height: 32px;
}
.avatar-sm {
  width: 28px;
  height: 28px;
}

/* --- Page vertical gaps --------------------------------------------------- */
main.body {
  padding-top: var(--page-gap-y);
  padding-bottom: var(--page-gap-y);
}
@media (max-width: 575.98px) {
  main.body {
    padding-top: var(--page-gap-y-sm) !important;
    padding-bottom: var(--page-gap-y-sm) !important;
  }
}

@media (max-width: 575.98px) {
  .table-mobile-stack {
    display: block;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }
  .table-mobile-stack colgroup {
    display: none !important;
  }
  .table-mobile-stack thead {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
  }
  .table-mobile-stack tbody {
    display: block;
    width: 100%;
  }

  .table-mobile-stack tr {
    display: block;
    background: var(--cui-body-bg, #fff);
    border-radius: var(--cui-border-radius, 0.5rem);
    border: 1px solid var(--cui-border-color, #e5e7eb);
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
    padding: 0 0.75rem;
    margin-top: 0.75rem;
    width: 100%;
    overflow: hidden;
    transition: background-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
  }
  .table-mobile-stack tr + tr {
    margin-top: 1rem;
  }

  .table-mobile-stack th,
  .table-mobile-stack td {
    display: block;
    width: 100% !important;
    background: transparent !important;
  }

  .table-mobile-stack td {
    display: grid;
    grid-template-columns: minmax(6em, 40%) 1fr;
    place-items: center;
    text-align: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border: 0 !important;
    white-space: normal;
    font-size: 0.9rem;
  }
  .page-user-list .table-mobile-stack tr > td {
    border-top: 1px solid var(--cui-border-color, #e5e7eb) !important;
  }
  .page-user-list .table-mobile-stack tr > td:first-child {
    border-top: 0 !important;
  }
  .page-user-list .table-mobile-stack tr > td.cell-title {
    border-top: 0;
  }
  .table-mobile-stack td::before {
    content: attr(data-th);
    color: var(--cui-secondary-color, #6c757d);
    font-size: 0.8rem;
    line-height: 1.2;
    justify-self: center;
    text-align: center;
  }

  .table-mobile-stack .cell-file,
  .table-mobile-stack .cell-title {
    display: block;
    padding: 0.5rem 0;
    text-align: center;
  }
  .table-mobile-stack .cell-file::before,
  .table-mobile-stack .cell-title::before {
    content: "";
    display: none !important;
  }
  .table-mobile-stack .cell-file a,
  .table-mobile-stack .cell-title a,
  .table-mobile-stack .cell-title > span {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    font-weight: 600;
    line-height: 1.35;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
  }

  .table-mobile-stack .cell-date {
    color: var(--cui-tertiary-color, #6c757d);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
  }

  .table-mobile-stack .cell-check {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    padding-top: 0;
    padding-bottom: 0.25rem;
    text-align: right;
  }
  .table-mobile-stack .cell-check::before {
    content: "";
  }

  .table-mobile-stack.table-hover > tbody > tr:hover > * {
    background-color: transparent !important;
  }
  .table-mobile-stack.table-hover > tbody > tr:hover {
    background-color: transparent !important;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
    transform: none;
  }
  .table-mobile-stack.table-hover > tbody > tr:active {
    background-color: transparent !important;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
  }

  .table-mobile-stack td [class*="btn"] {
    justify-self: center;
  }
  .table-mobile-stack td .badge {
    justify-self: center;
  }
}

/* --- Roots & vars --------------------------------------------------------- */
:root {
  --radius-sm: 0.25rem;

  --cui-border-radius: var(--radius-sm);
  --cui-border-radius-sm: var(--radius-sm);
  --cui-border-radius-lg: var(--radius-sm);

  --bs-border-radius: var(--radius-sm);
  --bs-border-radius-sm: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-sm);

  --page-gap-y: 2.5rem;
  --page-gap-y-sm: 1.5rem;
}

@media (min-width: 768px) {
  .table.table-mobile-stack > tbody > tr:has(.row-check:checked),
  .table.table-mobile-stack > tbody > tr.is-selected {
    background-color: var(--bs-table-active-bg, #eef1f5) !important;
    box-shadow: 0 2px 6px rgba(17, 24, 39, 0.08);
    border-color: var(--cui-border-color, #e5e7eb);
  }
}

@media (max-width: 767.98px) {
  .table-mobile-stack {
    --bs-table-hover-bg: transparent !important;
    --bs-table-active-bg: transparent !important;
  }

  .table-mobile-stack > tbody > tr:has(.row-check:checked),
  .table-mobile-stack > tbody > tr.is-selected {
    background-color: var(--cui-body-bg, #fff) !important;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
    border-color: var(--cui-border-color, #e5e7eb);
  }
  .table-mobile-stack > tbody > tr:has(.row-check:checked) > *,
  .table-mobile-stack > tbody > tr.is-selected > * {
    background-color: transparent !important;
  }

  .table-mobile-stack > tbody > tr.table-active,
  .table-mobile-stack > tbody > tr.table-active > *,
  .table-mobile-stack > tbody > tr.active,
  .table-mobile-stack > tbody > tr.active > *,
  .table-mobile-stack > tbody > tr > .table-active,
  .table-mobile-stack > tbody > tr > .active,
  .table-mobile-stack > tbody > tr:focus-within,
  .table-mobile-stack > tbody > tr:focus-within > * {
    background-color: transparent !important;
  }
}

/* タッチ環境（実機対策）：hover を完全に殺す */
@media (hover: none) {
  .table-mobile-stack {
    --bs-table-hover-bg: transparent !important;
    --bs-table-active-bg: transparent !important;
  }
  .table-mobile-stack.table-hover > tbody > tr:hover,
  .table-mobile-stack.table-hover > tbody > tr:hover > *,
  .table-mobile-stack.table-hover > tbody > tr:active,
  .table-mobile-stack.table-hover > tbody > tr:active > * {
    background-color: transparent !important;
  }
  .table-mobile-stack > tbody > tr.table-active,
  .table-mobile-stack > tbody > tr.table-active > *,
  .table-mobile-stack > tbody > tr.active,
  .table-mobile-stack > tbody > tr.active > * {
    background-color: transparent !important;
  }
}

/* アクセシビリティ：キーボードフォーカス時の可視リング */
.row-check:focus-visible {
  outline: 2px solid var(--cui-link-color, #0d6efd);
  outline-offset: 2px;
  border-radius: 0.25rem;
}

/* ===== 共通：タイトル行（3ページで共通化） ===== */
.page-upload-list .page-title-row,
.page-manage-questions .page-title-row,
.page-user-list .page-title-row {
  gap: 0.5rem;
}
@media (max-width: 575.98px) {
  .page-upload-list .page-title-row,
  .page-manage-questions .page-title-row,
  .page-user-list .page-title-row {
    flex-wrap: nowrap !important;
  }
  .page-upload-list .page-title,
  .page-manage-questions .page-title,
  .page-user-list .page-title {
    font-size: 1.125rem;
    line-height: 1.25;
    margin: 0;
  }
  .page-upload-list .page-title-actions .btn,
  .page-manage-questions .page-title-actions .btn,
  .page-user-list .page-title-actions .btn {
    white-space: nowrap;
  }
}

/* ===== 共通：一括操作バー（カードヘッダー）を #fffcf7・左右paddingゼロ ===== */
.page-upload-list .card-header.bg-body,
.page-upload-list .card-header.bg-body.py-2,
.page-manage-questions .card-header.bg-body,
.page-manage-questions .card-header.bg-body.py-2,
.page-user-list .card-header.bg-body,
.page-user-list .card-header.bg-body.py-2 {
  background-color: #fffcf7 !important;
  --bs-card-cap-bg: #fffcf7;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* ===== 共通：テーブルヘッダー（thead.table-light）を #fbf5ed ===== */
.page-upload-list thead.table-light,
.page-manage-questions thead.table-light,
.page-user-list thead.table-light {
  --bs-table-bg: #fbf5ed;
  --bs-table-striped-bg: #fbf5ed;
  --bs-table-active-bg: #fbf5ed;
  --bs-table-hover-bg: #fbf5ed;
  background-color: #fbf5ed !important;
}
.page-upload-list thead.table-light th,
.page-manage-questions thead.table-light th,
.page-user-list thead.table-light th {
  background-color: #fbf5ed !important;
}

/* ===== 共通：タイトル右上の主ボタンを淡色（#fbf5ed）＋枠線表示 ===== */
.page-upload-list .page-title-row .page-title-actions > .btn.btn-primary,
.page-manage-questions .page-title-row .page-title-actions > .btn.btn-primary,
.page-user-list .page-title-row .page-title-actions > .btn.btn-primary {
  --cui-btn-color: #212529;
  --cui-btn-bg: #fbf5ed;
  --cui-btn-border-color: #e5dacb;

  --cui-btn-hover-color: #212529;
  --cui-btn-hover-bg: #fbf5ed;
  --cui-btn-hover-border-color: #e5dacb;

  --cui-btn-active-color: #212529;
  --cui-btn-active-bg: #fbf5ed;
  --cui-btn-active-border-color: #e5dacb;

  --cui-btn-disabled-color: #adb5bd;
  --cui-btn-disabled-bg: #fbf5ed;
  --cui-btn-disabled-border-color: #e5dacb;

  color: #212529 !important;
  background-color: #fbf5ed !important;
  border: 1px solid #e5dacb !important;
  box-shadow: none;
}
.page-upload-list .page-title-row .page-title-actions > .btn.btn-primary:hover,
.page-upload-list .page-title-row .page-title-actions > .btn.btn-primary:active,
.page-upload-list .page-title-row .page-title-actions > .btn.btn-primary:focus,
.page-manage-questions .page-title-row .page-title-actions > .btn.btn-primary:hover,
.page-manage-questions .page-title-row .page-title-actions > .btn.btn-primary:active,
.page-manage-questions .page-title-row .page-title-actions > .btn.btn-primary:focus,
.page-user-list .page-title-row .page-title-actions > .btn.btn-primary:hover,
.page-user-list .page-title-row .page-title-actions > .btn.btn-primary:active,
.page-user-list .page-title-row .page-title-actions > .btn.btn-primary:focus {
  color: #212529 !important;
  background-color: #fbf5ed !important;
  border-color: #e5dacb !important;
  box-shadow: none !important;
}
.page-upload-list .page-title-row .page-title-actions > .btn.btn-primary:focus-visible,
.page-manage-questions .page-title-row .page-title-actions > .btn.btn-primary:focus-visible,
.page-user-list .page-title-row .page-title-actions > .btn.btn-primary:focus-visible {
  outline: 3px solid color-mix(in oklab, #e5dacb 60%, #fff);
  outline-offset: 2px;
  border-color: #e5dacb !important;
}
.page-upload-list .page-title-row .page-title-actions > .btn.btn-primary:disabled,
.page-manage-questions .page-title-row .page-title-actions > .btn.btn-primary:disabled,
.page-user-list .page-title-row .page-title-actions > .btn.btn-primary:disabled {
  color: #adb5bd !important;
  background-color: #fbf5ed !important;
  border-color: #e5dacb !important;
  opacity: 1;
}

/* --- Final override for layout-no-scroll paddings (exclude chat) ---------- */
body.layout-no-scroll:not(.page-chat-index) main.body {
  padding-top: 0 !important;
  padding-bottom: max(0px, env(safe-area-inset-bottom)) !important;
}

.footer {
  --cui-footer-bg: #fbf5ed;
  background-color: #fbf5ed !important;
  border-top: 1px solid #fbf5ed;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
