/* BAFU-2025 LCIA Web-Viewer – Zero Heroes Style */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Eurostile", "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #403152;
  /* Zero Heroes Dark Purple/Grey */
  background-color: #ffffff;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header */
.header {
  background-color: #f3f3f3;
  padding: 1.5rem 0 2rem;
  border-bottom: 1px solid #000;
}

.header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 700;
  color: #403152;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header .subtitle {
  margin: 0 0 0.5rem;
  color: #403152;
  font-weight: 300;
  max-width: 72ch;
}

.header .source {
  margin: 0;
  font-size: 0.9rem;
  color: #666;
}

.header .source a {
  color: #403152;
  text-decoration: underline;
  font-weight: 600;
}

.header .source a:hover {
  text-decoration: none;
}

/* Main */
.main {
  padding: 1.5rem 0 3rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}

.search-label {
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #403152;
}

.search-input {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid #000;
  border-radius: 0;
  /* Sharp corners */
  background: #fff;
  color: #403152;
}

.search-input::placeholder {
  color: #aaa;
}

.search-input:focus {
  outline: none;
  border-color: #403152;
  box-shadow: 0 0 0 1px #403152;
}

.status {
  font-size: 0.875rem;
  color: #666;
}

.table-wrapper {
  border: 1px solid #000;
  border-radius: 0;
  background: #fff;
  overflow: hidden;
  height: 60vh;
  min-height: 400px;
  box-shadow: none;
  /* No shadow (Flat) */
}

.table-wrapper #table {
  height: 100%;
  min-height: 0;
}

/* Tabulator Overrides */
.table-wrapper .tabulator {
  height: 100% !important;
  min-height: 0;
  font-size: 0.9rem;
  border: none;
  background: #fff;
}

.tabulator-header {
  background: #f3f3f3;
  border-bottom: 1px solid #000;
  color: #403152;
}

.tabulator-col {
  background: #f3f3f3;
  border-right: 1px solid #ddd;
}

.tabulator-col .tabulator-col-content {
  padding: 0.6rem 0.5rem;
}

.tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
  font-weight: 700;
  color: #403152;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.tabulator .tabulator-header .tabulator-col.tabulator-sortable .tabulator-col-content {
  padding-right: 1.5rem;
}

.tabulator-row {
  min-height: 2.25rem;
  border-bottom: 1px solid #eee;
}

.tabulator-row.tabulator-row-even,
.tabulator-row.tabulator-row-odd {
  background: #fff;
  color: #403152;
}

.tabulator-row.tabulator-selectable:hover {
  background: #f3f3f3 !important;
}

.tabulator-cell {
  border-right: 1px solid #f3f3f3;
  padding: 0.45rem 0.5rem;
}

.tabulator-cell:last-of-type {
  border-right: none;
}

/* Filter inputs in header */
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input,
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter select {
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  border: 1px solid #ccc;
  border-radius: 0;
  font-family: inherit;
  color: #403152;
  width: 100%;
  box-sizing: border-box;
}

.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input:focus,
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter select:focus {
  outline: none;
  border-color: #403152;
}

/* Styled Dropdown List (Tabulator Popup) */
.tabulator-popup-container {
  background: #fff;
  border: 1px solid #000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-width: 400px;
  /* Constrain wide content */
  border-radius: 0;
}

.tabulator-list .tabulator-list-item {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 6px 10px;
  color: #403152;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabulator-list .tabulator-list-item:hover {
  background-color: #f3f3f3;
  cursor: pointer;
}

.tabulator-list .tabulator-list-item.tabulator-list-item-active {
  background-color: #403152;
  color: #fff;
}

.tabulator-placeholder {
  color: #666;
  font-size: 0.95rem;
}

/* Loading */
.loading {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  color: #403152;
  background: #f3f3f3;
  border: 1px solid #000;
  border-radius: 0;
}

.loading[hidden] {
  display: none;
}

/* Error */
.error {
  color: #d32f2f;
  font-size: 0.95rem;
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  background: #ffebee;
  border: 1px solid #ef5350;
  border-radius: 0;
}

/* Footer */
.footer {
  padding: 1.25rem 0;
  border-top: 1px solid #000;
  background: #fff;
  margin-top: 2rem;
}

.footer p {
  margin: 0;
  font-size: 0.8rem;
  color: #666;
}

/* Responsive */
@media (max-width: 640px) {
  .header h1 {
    font-size: 1.4rem;
  }

  .container {
    padding: 0 1rem;
  }

  .search-input {
    max-width: none;
  }

  .table-wrapper {
    margin: 0 -1rem;
    border-left: none;
    border-right: none;
  }
}

/* Modal Styles */
.modal {
  display: flex;
  /* Hidden by default via hidden attribute, but flex when shown */
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.close-modal {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

/* Detail Table in Modal */
.detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.detail-table th,
.detail-table td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.detail-table th {
  background-color: #f2f2f2;
  width: 200px;
}

/* Button & Select Styles */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  margin-left: 1rem;
}

.btn-secondary {
  background-color: #403152;
  color: white;
}

.btn-secondary:hover {
  background-color: #2e233b;
}

.category-select {
  padding: 0.5rem;
  border-radius: 4px;
  border: 1px solid #000;
  font-family: inherit;
  font-size: 0.95rem;
  margin-left: 1rem;
  background-color: white;
  min-width: 200px;
}

.chart-container {
  background: white;
  padding: 1rem;
  border-radius: 0;
  box-shadow: none;
  border: 1px solid #000;
}

/* Chatbot UI Styles */
.chat-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #403152;
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 2000;
  transition: transform 0.2s;
}

.chat-button:hover {
  transform: scale(1.1);
}

.chat-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 350px;
  height: 500px;
  background-color: white;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.chat-window[hidden] {
  display: none !important;
}

.chat-header {
  background-color: #403152;
  color: white;
  padding: 10px 15px;
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header h3 {
  margin: 0;
  font-size: 1rem;
}

.chat-close {
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

.chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  background-color: #f9f9f9;
}

.message {
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  max-width: 80%;
  font-size: 0.9rem;
}

.message.bot {
  background-color: #eee;
  align-self: flex-start;
  border-bottom-left-radius: 0;
}

.message.user {
  background-color: #403152;
  color: white;
  align-self: flex-end;
  margin-left: auto;
  border-bottom-right-radius: 0;
}

.chat-input-area {
  padding: 10px;
  border-top: 1px solid #ddd;
  display: flex;
  gap: 10px;
}

.chat-input-area input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.chat-input-area button {
  padding: 8px 15px;
  background-color: #403152;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.suggestion-btn {
  display: block;
  margin-top: 5px;
  background: #403152;
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

/* Mobile Warning Overlay */
.mobile-warning {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.98);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.mobile-warning h2 {
  color: #403152;
  margin-bottom: 1rem;
}

.mobile-warning p {
  color: #666;
  max-width: 400px;
  line-height: 1.6;
  font-size: 1.1rem;
}

.mobile-warning i {
  font-size: 3rem;
  color: #403152;
  margin-bottom: 1rem;
}