/* ==========================================================================
   Theme Name: ABCD OPAC Default
   Theme URI: https://github.com/ABCD-DEVCOM/ABCD
   Description: The standard, baseline visual theme for the ABCD OPAC interface.
                Built on Bootstrap 5, it provides a clean, highly responsive, 
                and accessible foundation for libraries, archives, and museums.
   Author: ABCD DEVCOM (Lead: Roger C. Guilherme)
   Version: 3.3.0
   License: GNU General Public License v3.0
   Tags: default, base-theme, opac, responsive, bootstrap5
   
   Note: This stylesheet is the architectural foundation for the ABCD Theme 
         Engine. To maintain upgrade compatibility, avoid hardcoding institutional 
         colors here; rely on the dynamic injections from global_style.def.
   ========================================================================== */

/* --------------------------------------------------------------------------
   TABLE OF CONTENTS
   --------------------------------------------------------------------------
   01. CSS Variables & Root Definitions
   02. Base Reset & Typography
   03. Layout & Grid (Container, Header, Footer)
   04. Navigation & Sidebar Facets
   05. Search Interface (Primo-Style Unified Search Bar)
   06. Catalog Results (Cards, Pagination)
   07. Record Details (Full View)
   08. User Dashboard & MyABCD
   09. Utilities & Mobile Overrides (Media Queries)
   10. Dark Mode & Theming
   -------------------------------------------------------------------------- */

/* ==========================================================================
   01. CSS Variables & Root Definitions
   ========================================================================== */
/* Reserved for future global root variables */


/* ==========================================================================
   02. Base Reset & Typography
   ========================================================================== */
mark {
  box-shadow: inset 0 -.3em 0 0 #ffe564;
  background-color: #fdfdfd;
  color: #333;
  padding: 2px 1px;
  border-radius: 3px;
  font-weight: 600;
}


/* ==========================================================================
   03. Layout & Grid (Container, Header, Footer)
   ========================================================================== */
/* Layout structure adjustments go here */


/* ==========================================================================
   04. Navigation & Sidebar Facets
   ========================================================================== */
button.termo {
  text-transform: lowercase;
}

.facet-scroll-list {
  max-height: 40vh;
  overflow-y: auto;
  touch-action: pan-y;
  -ms-touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: auto;
}

/* Remove o padding estático antigo para permitir que a tag <a> gerencie a área clicável */
.facet-scroll-list li {
  transition: background-color 0.2s ease;
}

.facet-scroll-list li:hover {
  background-color: #f8f9fa;
  /* Leve sombreamento no hover da linha inteira */
}

/* Deixa a barra de rolagem mais discreta e fina */
.facet-scroll-list::-webkit-scrollbar {
  width: 6px;
}

.facet-scroll-list::-webkit-scrollbar-thumb {
  background-color: #dcdcdc;
  border-radius: 10px;
}

/* Animação do Acordeão (Gira o Chevron) */
.facet-toggle[aria-expanded="true"] .transition-icon {
  transform: rotate(180deg);
  transition: transform 0.3s ease;
}

.facet-toggle[aria-expanded="false"] .transition-icon {
  transform: rotate(0deg);
  transition: transform 0.3s ease;
}

/* Cor de destaque ao passar o mouse no link da faceta */
.faceta-link:hover {
  color: var(--bs-primary) !important;
}


/* ==========================================================================
   05. Search Interface (Primo-Style Unified Search Bar & Indexes)
   ========================================================================== */
.index-container {
  max-height: 400px;
  overflow-y: auto;
  position: relative;
  border: 1px solid #dee2e6;
  border-radius: .375rem;
  padding: 5px;
}

.index-footer {
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid #dee2e6;
  text-align: right;
}

.index-footer a {
  margin-left: 5px;
}

/* ROUNDED-STYLE SEARCH BAR (Busca Unificada) */
.abcd-search-bar {
  border: 1px solid #ced4da;
  border-radius: 50px;
  background: #fff;
  transition: box-shadow 0.3s ease;
}

.abcd-search-bar:focus-within {
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
  border-color: #86b7fe;
}

.abcd-search-bar .form-control,
.abcd-search-bar .form-select,
.abcd-search-bar .btn {
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
}

.abcd-search-bar>.form-control:first-child {
  border-top-left-radius: 50px !important;
  border-bottom-left-radius: 50px !important;
}

.abcd-search-bar>.form-select,
.abcd-search-bar>.dropdown-toggle {
  border-left: 1px solid #eaeaea !important;
  color: #555;
  font-size: 0.95rem;
}

.abcd-search-bar .btn-search-abcd {
  padding-left: 25px;
  padding-right: 30px;
  border-top-right-radius: 50px !important;
  border-bottom-right-radius: 50px !important;
}

.abcd-search-bar .btn-search-abcd:hover {
  filter: brightness(0.85);
}

#searchBox.card {
  border: none !important;
  background: transparent !important;
}

/* MOBILE FIX: ABCD SEARCH BAR */
@media (max-width: 768px) {

  /* "Disable" Bootstrap's forced layout behaviour */
  .abcd-search-bar.input-group {
    display: block !important;
    border-radius: 12px !important;
  }

  /* "Force" the 3 elements to act as stacked blocks of 100% width */
  .abcd-search-bar>.form-control:first-child,
  .abcd-search-bar>.dropdown-toggle,
  .abcd-search-bar>.btn-search-abcd {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding-top: 14px !important;
    padding-bottom: 14px !important;
  }

  /* The Text Field (Top)*/
  .abcd-search-bar>.form-control:first-child {
    border-radius: 12px 12px 0 0 !important;
    border-bottom: 1px solid #eaeaea !important;
  }

  /* The Dropdown Menu (Middle) */
  .abcd-search-bar>.dropdown-toggle {
    border-left: none !important;
    border-radius: 0 !important;
    text-align: left !important;
    position: relative;
    max-width: 100% !important;
  }

  /* Move the dropdown arrow to the top right corner on mobile */
  .abcd-search-bar>.dropdown-toggle::after {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
  }

  /* Ensure that the list of databases occupies the full width of the screen */
  .abcd-search-bar .dropdown-menu {
    width: 100% !important;
    margin-top: 0 !important;
    border-radius: 0 0 12px 12px !important;
  }

  /* The Search Button (Base) */
  .abcd-search-bar>.btn-search-abcd {
    border-radius: 0 0 12px 12px !important;
    border-top: 1px solid #eaeaea !important;
  }

  /* Reduce the white space around the box to save screen real estate */
  #searchBox.card {
    padding: 1.5rem 1rem !important;
  }
}


/* ==========================================================================
   06. Catalog Results (Cards, Pagination)
   ========================================================================== */
li.page-item>a.page-link>i.fas {
  line-height: inherit;
}


/* ==========================================================================
   07. Record Details (Full View)
   ========================================================================== */
/* When in full-screen mode, this ensures that the canvas uses the entire screen and maintains the aspect ratio */
.protected-canvas:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  /* This disables Bootstrap's img-fluid in full-screen mode */
  object-fit: contain !important;
  background-color: #000;
}

.protected-canvas:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  object-fit: contain !important;
  background-color: #000;
}


/* ==========================================================================
   08. User Dashboard & MyABCD
   ========================================================================== */
/* MyABCD specific styling */


/* ==========================================================================
   09. Utilities & Mobile Overrides (Media Queries)
   ========================================================================== */
#lightSwitch {
  transform: scale(1);
}

/* SCROLL-TO-TOP */
.smoothscroll-top {
  position: fixed;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  text-align: center;
  z-index: 99;
  color: #fff;
  background-color: var(--bs-blue);
  width: 44px;
  height: 44px;
  line-height: 44px;
  right: 25px;
  bottom: -25px;
  border-radius: 5px;
  transition: all .5s ease-in-out;
  transition-delay: .2s
}

.smoothscroll-top:hover {
  background-color: #671f6c;
  color: #fff;
  transition: all .2s ease-in-out;
  transition-delay: 0s
}

.smoothscroll-top.show {
  visibility: visible;
  cursor: pointer;
  opacity: 1;
  bottom: 25px
}

.smoothscroll-top i.fa {
  line-height: inherit
}

/* GENERAL ADJUSTMENTS FOR MOBILE TABLES/CARDS */
@media (max-width: 768px) {

  .container,
  .card,
  .table-responsive {
    padding-left: 5px;
    padding-right: 5px;
  }

  .card,
  .table {
    margin-left: 0;
    margin-right: 0;
  }

  /* More compact buttons */
  .btn,
  button {
    padding: 4px 8px;
    font-size: 0.8rem;
  }

  /* Icons within the buttons */
  .btn i {
    font-size: 1rem;
  }

  /* Table Adjusting not to break */
  .table td,
  .table th {
    white-space: normal;
    word-break: break-word;
  }

  th {
    width: 50px;
    font-size: 14px;
    word-break: break-word;
  }

  td {
    width: 180px;
    font-size: 14px;
    word-break: break-word;
  }

  table.responsive-stack {
    width: 100%;
  }

  table.responsive-stack thead {
    display: none;
  }

  table.responsive-stack tr {
    display: block;
    margin-bottom: 1rem;
    border-bottom: 1px solid #ddd;
  }

  table.responsive-stack td {
    display: block;
    width: 100%;
    text-align: left;
  }

  table.responsive-stack td::before {
    content: attr(data-label);
    border-bottom: none;
    font-weight: bold;
    display: block;
    margin-bottom: 0.25rem;
    color: #555;
  }
}


/* ==========================================================================
   10. Dark Mode & Theming
   ========================================================================== */
body.dark-mode {
  /* Color variables for the dark theme */
  --bs-body-color: #eee;
  --bs-body-bg: #121212;
  --bs-card-bg: #1e1e1e;
  --bs-link-color: #a0c4ff;
  --bs-table-bg: #1e1e1e;
  --bs-table-striped-bg: #2c2c2c;
  --bs-table-hover-bg: #3a3a3a;
  --bs-border-color: #444;
  --bs-secondary-bg: #2b2b2b;

  background-color: var(--bs-body-bg) !important;
  color: var(--bs-body-color) !important;
}

body.dark-mode a {
  color: var(--bs-link-color) !important;
}

/* General rule for elements that were white/light */
body.dark-mode .bg-white,
body.dark-mode .bg-light,
body.dark-mode .text-bg-light {
  background-color: var(--bs-card-bg) !important;
  color: var(--bs-body-color) !important;
}

/* Styles for cards, navbars, search boxes, etc. */
body.dark-mode .card,
body.dark-mode #searchBox,
body.dark-mode .navbar,
body.dark-mode .jumbotron,
body.dark-mode .list-group-item,
body.dark-mode .custom-searchbox,
body.dark-mode .custom-footer,
body.dark-mode .custom-sidebar {
  background-color: var(--bs-card-bg) !important;
  color: var(--bs-body-color) !important;
  border-color: var(--bs-border-color) !important;
}

body.dark-mode a.custom-top-link {
  color: var(--bs-link-color) !important;
}

/* Table */
body.dark-mode .table {
  --bs-table-color: var(--bs-body-color) !important;
  --bs-table-bg: var(--bs-table-bg) !important;
  --bs-table-border-color: var(--bs-border-color) !important;
  --bs-table-striped-bg: var(--bs-table-striped-bg) !important;
  --bs-table-hover-bg: var(--bs-table-hover-bg) !important;
  color: var(--bs-body-color) !important;
}

/* Forms (text fields, selects) */
body.dark-mode .form-control,
body.dark-mode .form-select {
  background-color: #333 !important;
  color: var(--bs-body-color) !important;
  border-color: #555 !important;
}

/* Buttons */
body.dark-mode .btn-light,
body.dark-mode .btn-outline-default,
body.dark-mode .btn-secondary,
body.dark-mode .btn-outline-secondary,
body.dark-mode .btn-outline-info,
body.dark-mode .btn-outline-primary,
body.dark-mode .btn-outline-success,
body.dark-mode .original-btn-submit {
  color: #e9e9e9 !important;
  border-color: #6c757d !important;
  background-color: #3a3a3a !important;
}

body.dark-mode .btn-light:hover,
body.dark-mode .btn-outline-default:hover,
body.dark-mode .btn-outline-secondary:hover,
body.dark-mode .btn-outline-info:hover,
body.dark-mode .btn-outline-primary:hover,
body.dark-mode .btn-outline-success:hover {
  color: #ffffff !important;
  background-color: #5a5a5a !important;
}

/* Modals */
body.dark-mode .modal-content {
  background-color: var(--bs-card-bg) !important;
  border-color: var(--bs-border-color) !important;
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
  background-color: var(--bs-secondary-bg) !important;
  border-bottom-color: var(--bs-border-color) !important;
  border-top-color: var(--bs-border-color) !important;
}

/* Pagination */
body.dark-mode .page-link {
  background-color: var(--bs-card-bg) !important;
  color: var(--bs-link-color) !important;
  border-color: var(--bs-border-color) !important;
}

body.dark-mode .page-item.active .page-link {
  background-color: var(--bs-link-color) !important;
  border-color: var(--bs-link-color) !important;
  color: #121212 !important;
}

/* E -dropdowns texts */
body.dark-mode .text-secondary,
body.dark-mode .text-muted {
  color: #adb5bd !important;
}

body.dark-mode .dropdown-menu {
  background-color: var(--bs-secondary-bg) !important;
  border-color: var(--bs-border-color) !important;
}

body.dark-mode .text-dark,
body.dark-mode .text-primary,
body.dark-mode ::placeholder,
body.dark-mode .dropdown-item {
  color: var(--bs-body-color) !important;
}

/* Conteúdo de Cards e Tabelas */
body.dark-mode .card table,
body.dark-mode .card table td,
body.dark-mode .card table .textbody03,
body.dark-mode .card table tr,
body.dark-mode .card b {
  color: var(--bs-body-color) !important;
}

body.dark-mode mark {
  box-shadow: inset 0 -.3em 0 0 #ffe564;
  background-color: #949494;
  color: #333;
  padding: 2px 1px;
  border-radius: 3px;
  font-weight: 600;
}

/* Final components */
body.dark-mode .bg-dark-subtle,
body.dark-mode .card-body,
body.dark-mode .card-header {
  background-color: var(--bs-secondary-bg) !important;
  border-bottom-color: var(--bs-border-color) !important;
}

body.dark-mode #searchBox.card.bg-white,
.card.text-bg-light,
body.dark-mode a.list-group-item:hover,
body.dark-mode button.list-group-item:hover {
  background-color: var(--bs-secondary-bg) !important;
}

body.dark-mode .input-group-text {
  background-color: var(--bs-secondary-bg) !important;
  border-color: #555 !important;
  color: var(--bs-body-color) !important;
}

/* Ensures that the sun icon (SVG) becomes white in dark mode */
body.dark-mode .form-check-label svg {
  color: #f8f9fa;
}

/* Removes any logo image filter to keep the brand's original colors */
body.dark-mode #logo {
  filter: none;
}

body.dark-mode .alert.alert-light {
  background-color: #2c3034;
  color: #ced4da;
  border-color: #495057;
  border-left-color: #0d6efd !important;
}

/* Ajusta a cor do texto em negrito dentro do alerta no modo escuro */
body.dark-mode .alert.alert-light strong {
  color: #e9ecef;
}

/* Ajusta a cor do texto "muted" (Termo pesquisado, Detalhes) no modo escuro */
body.dark-mode .alert.alert-light .text-muted {
  color: #adb5bd !important;
}