/*
 * version: 1.0.0
 * revision: 2026.05.11.14.32.52
 */

/* ============================================================
   BlockForge — Base Styles
   ============================================================ */

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#app {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1a1a1a;
  background: #f5f5f5;
  overflow: hidden;
}

/* ============================================================
   Layout Primitives (used by container-block)
   ============================================================ */

.bf-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.bf-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bf-grid {
  display: grid;
  gap: 8px;
}

/* ============================================================
   Block Shell
   ============================================================ */

[data-block-id] {
  position: relative;
}

/* ============================================================
   List Block — Four mutually exclusive states
   ============================================================ */

.bf-list {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: auto;
  flex: 1;
}

/* State message (rendered by JS) */
.bf-list .bf-state-msg {
  padding: 24px;
  text-align: center;
}
.bf-list.loading .bf-state-msg { color: #888; }
.bf-list.error   .bf-state-msg { color: #c0392b; }
.bf-list.empty   .bf-state-msg { color: #888; }

/* ============================================================
   List Table
   ============================================================ */

.bf-list table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.bf-list th {
  background: #f0f0f0;
  border-bottom: 2px solid #ddd;
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bf-list td {
  border-bottom: 1px solid #eee;
  padding: 8px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bf-list tr:hover td {
  background: #f9f9f9;
  cursor: pointer;
}

.bf-list tr.selected td {
  background: #e8f0fe;
}

/* Active-row highlight — row whose field matches activeKey state value */
.bf-list tr.bf-row--active td {
  background: #ecfdf5;
}
.bf-list tr.bf-row--active:hover td {
  background: #d1fae5;
}

/* Row indicators */
.bf-list tr.dirty td:first-child::before {
  content: '●';
  color: #f39c12;
  margin-right: 6px;
  font-size: 10px;
}

.bf-list tr.failed td:first-child::before {
  content: '✕';
  color: #c0392b;
  margin-right: 6px;
  font-size: 10px;
}

.bf-list tr.dirty.failed td:first-child::before {
  content: '✕●';
  color: #c0392b;
  margin-right: 6px;
  font-size: 10px;
}

/* Row checkbox column */
.bf-list td.bf-row-check,
.bf-list th.bf-row-check {
  width: 32px;
  text-align: center;
  padding: 8px 4px;
}

/* ============================================================
   Detail Block
   ============================================================ */

.bf-detail {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 16px;
  min-width: 280px;
}

.bf-detail-header {
  font-weight: 600;
  font-size: 13px;
  color: #555;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.bf-field {
  margin-bottom: 12px;
}

.bf-field label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  font-weight: 500;
}

.bf-field input,
.bf-field textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 14px;
  font-family: inherit;
}

.bf-field input:focus,
.bf-field textarea:focus {
  outline: none;
  border-color: #4285f4;
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

.bf-field input[readonly],
.bf-field textarea[readonly] {
  background: #f5f5f5;
  color: #555;
  border-color: #e0e0e0;
  cursor: default;
}

/* field-blocks in a row container share width equally */
.bf-row > .bf-field {
  flex: 1;
  min-width: 0;
}

.bf-field .bf-field-display {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  font-size: 14px;
  background: #f5f5f5;
  color: #555;
}

/* Nested bf-detail inside a modal panel or bf-detail wrapper */
.bf-modal-panel .bf-detail,
.bf-detail .bf-detail {
  border: none;
  background: transparent;
  padding: 0;
  min-width: 0;
  border-radius: 0;
}

.bf-field select {
  width: 100%;
  padding: 6px 28px 6px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 14px;
  font-family: inherit;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  appearance: none;
  cursor: pointer;
}

.bf-field select:focus {
  outline: none;
  border-color: #4285f4;
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

.bf-detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

/* ============================================================
   Action Controls Block
   ============================================================ */

.bf-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.bf-controls-filters-row {
  flex-wrap: wrap;
  gap: 6px;
}

.bf-search-input {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 14px;
  min-width: 200px;
}

.bf-search-input:focus {
  outline: none;
  border-color: #4285f4;
}

/* ============================================================
   Buttons
   ============================================================ */

.bf-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.bf-btn:hover {
  background: #f5f5f5;
}

.bf-btn-primary {
  background: #4285f4;
  color: #fff;
  border-color: #3367d6;
}

.bf-btn-primary:hover {
  background: #3367d6;
}

.bf-btn-danger {
  background: #fff;
  color: #c0392b;
  border-color: #c0392b;
}

.bf-btn-danger:hover {
  background: #fdf0ef;
}

.bf-btn[hidden] {
  display: none;
}

/* ============================================================
   Config Menu Block
   ============================================================ */

.bf-config-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.bf-config-panel {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 12px;
  min-width: 240px;
  z-index: 100;
}

.bf-config-panel[hidden] {
  display: none;
}

.bf-config-section {
  margin-bottom: 12px;
}

.bf-config-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.bf-config-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}

/* Drag-over highlight for column reorder rows */
.bf-config-draggable {
  border: 2px solid transparent;
  border-radius: 3px;
  transition: border-color 0.1s, background 0.1s;
}

.bf-config-draggable.bf-drag-over {
  border-color: #4285f4;
  background: #e8f0fe;
}

/* ============================================================
   Message Block
   ============================================================ */

.bf-messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bf-message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
}

.bf-message.error {
  background: #fdf0ef;
  border: 1px solid #f5c6c2;
  color: #c0392b;
}

.bf-message.info {
  background: #e8f0fe;
  border: 1px solid #c5d8fc;
  color: #1a73e8;
}

.bf-message.success {
  background: #e6f4ea;
  border: 1px solid #b7dfbf;
  color: #1e7e34;
}

.bf-message-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
}

.bf-message-dismiss:hover {
  opacity: 1;
}

/* ============================================================
   Toolbar / App Shell
   ============================================================ */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 16px;
  gap: 12px;
}

.bf-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bf-main {
  display: flex;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

/* ============================================================
   Header Block
   ============================================================ */

.bf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 10px 14px;
  border-bottom: 1px solid #cbd5e1;
  background: #eef3f8;
  flex-shrink: 0;
  margin: 0 -20px;
}

.bf-header-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.bf-header-user {
  position: relative;
  display: flex;
  align-items: center;
}

.bf-header-user-button {
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #111827;
  font: inherit;
  font-size: 13px;
  padding: 6px 28px 6px 10px;
  cursor: pointer;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
}

.bf-header-user-button::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #6b7280;
  transform: translateY(-40%);
}

.bf-header-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.14);
  z-index: 300;
  overflow: hidden;
}

.bf-header-menu[hidden] {
  display: none;
}

.bf-header-menu-item {
  display: block;
  width: 100%;
  border: 0;
  background: #fff;
  color: #111827;
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 9px 12px;
  cursor: pointer;
}

.bf-header-menu-item:hover,
.bf-header-menu-item:focus {
  background: #f3f4f6;
  outline: none;
}

/* ============================================================
   Tabbed UI Block
   ============================================================ */

.bf-tabbed-ui {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.bf-tabbed-ui-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid #d1d5db;
  flex-wrap: wrap;
}

.bf-tabbed-ui-tab {
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: transparent;
  color: #4b5563;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  min-height: 34px;
  cursor: pointer;
}

.bf-tabbed-ui-tab:hover {
  background: #f3f4f6;
  color: #111827;
}

.bf-tabbed-ui-tab--active {
  background: #fff;
  border-color: #d1d5db;
  color: #1f2937;
  margin-bottom: -1px;
}

.bf-tabbed-ui-panels,
.bf-tabbed-ui-panel {
  min-width: 0;
}

.bf-tabbed-ui-panel[hidden] {
  display: none;
}

/* ============================================================
   Per-field Search Filters
   ============================================================ */

.bf-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bf-search-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bf-search-label {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  font-weight: 500;
}

.bf-field-filter-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 3px 6px;
}

.bf-field-filter-label {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.bf-filter-op {
  padding: 4px 4px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
  max-width: 100px;
}

.bf-filter-value {
  padding: 5px 7px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 13px;
  width: 110px;
  font-family: inherit;
}

.bf-filter-value:focus {
  outline: none;
  border-color: #4285f4;
  box-shadow: 0 0 0 2px rgba(66,133,244,0.15);
}

.bf-filter-clear {
  padding: 3px 5px;
  font-size: 11px;
  line-height: 1;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  color: #888;
}
.bf-filter-clear:hover { color: #c0392b; border-color: #c0392b; }

/* "+ Filter" dropdown */
.bf-filter-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 200;
  min-width: 140px;
  overflow: hidden;
}

.bf-filter-dropdown[hidden] { display: none; }

.bf-filter-dropdown-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}
.bf-filter-dropdown-item:hover { background: #f5f5f5; }

.bf-filter-dropdown-empty {
  padding: 8px 12px;
  font-size: 12px;
  color: #999;
}

/* select-field-block — custom dropdown */
.bf-select-field {
  margin-bottom: 12px;
}
.bf-select-field-label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  font-weight: 500;
}
.bf-select-field-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}
.bf-select-field-trigger {
  flex: 1;
  padding: 6px 28px 6px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 14px;
  font-family: inherit;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  user-select: none;
  color: #333;
  min-height: 32px;
  box-sizing: border-box;
}
.bf-select-field-trigger--empty { color: #999; }
.bf-select-field-trigger:focus {
  outline: none;
  border-color: #4285f4;
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}
.bf-select-field-clear {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
.bf-select-field-clear:hover { color: #333; }
.bf-select-field-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 3px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 200;
  max-height: 240px;
  flex-direction: column;
}
.bf-select-field-dropdown:not([hidden]) { display: flex; }
.bf-select-field-search {
  border: none;
  border-bottom: 1px solid #eee;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  flex-shrink: 0;
}
.bf-select-field-list {
  overflow-y: auto;
  flex: 1;
}
.bf-select-field-option {
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  color: #333;
}
.bf-select-field-option:hover { background: #f5f5f5; }
.bf-select-field-option--selected {
  background: #e8f0fe;
  font-weight: 500;
}
.bf-select-field-empty {
  padding: 8px 10px;
  font-size: 13px;
  color: #999;
}

/* Seamless extension of a .bf-detail card — no top border/radius, matching padding */
.bf-detail:has(+ .bf-form-extension) {
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}
.bf-form-extension {
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 4px 4px;
  padding: 0 16px 12px;
  min-width: 280px;
}

/* ============================================================
   Vertical Menu Block
   ============================================================ */

.bf-vertical-menu {
  flex-shrink: 0;
  width: 200px;
  height: 100vh;
  background: #fff;
  border-right: 1px solid #ddd;
  padding: 8px 0;
  align-self: flex-start;
  position: sticky;
  top: 0;
  overflow-y: auto;
}

.bf-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 14px;
  color: #333;
  user-select: none;
}

.bf-menu-item:hover {
  background: #f5f5f5;
}

.bf-menu-toggle {
  font-size: 10px;
  color: #888;
  width: 12px;
  flex-shrink: 0;
}

.bf-menu-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bf-menu-item--active {
  background: #e8f0fe;
  color: #1a73e8;
  font-weight: 500;
}

.bf-menu-children {
  padding-left: 20px;
}

.bf-vertical-menu > .bf-menu-item:last-child {
  border-top: 1px solid #eee;
  margin-top: 8px;
}

.bf-list .bf-list-footer-cell {
  font-weight: 600;
  border-top: 2px solid #ddd;
  padding: 6px 8px;
  background: #f5f5f5;
  color: #444;
  white-space: normal;
  overflow: visible;
}

/* Pagination */
.bf-pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid #eee;
  font-size: 13px;
  color: #555;
}

/* ============================================================
   Login Page
   ============================================================ */

.bf-login-card {
  max-width: 360px;
  width: 100%;
  padding: 32px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.10);
  display: flex;
  flex-direction: column;
}

.bf-login-title {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 600;
  color: #1a1a2e;
  text-align: center;
}

.bf-login-card .bf-btn {
  width: 100%;
  justify-content: center;
}
