/*
//-------------------------//
// styles.css
// Code implemented by Cirface.com / MMG
//
// Stylesheet for Custom Field Exporter - defines layout, components,
// and responsive design for the application interface
//
// Disclaimer: This code was created with the help of Claude.AI
//
// This code is part of Cirface Custom Field Explorer
// Last updated by: 2026FEB10 - LMR
//-------------------------//
*/

/* ================================================================
   Base
   ================================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: #1e293b;
  min-height: 100vh;
}

.screen { display: none; }
.screen:not([hidden]) { display: flex; }

/* ================================================================
   Login Screen
   ================================================================ */

#login-screen {
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  padding: 3rem 2.5rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: #64748b;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 2rem;
}

.error-text {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 1rem;
}

.legal-links {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 1.25rem;
  line-height: 1.5;
}

.legal-links a {
  color: #64748b;
  text-decoration: underline;
}
.legal-links a:hover {
  color: #ffa100;
}

/* ================================================================
   Buttons
   ================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: #293556;
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #ffa100; }

.btn-secondary {
  background: #e2e8f0;
  color: #1e293b;
}
.btn-secondary:hover:not(:disabled) { background: #ffa100; }

.btn-ghost {
  background: transparent;
  color: #fff;
}
.btn-ghost:hover:not(:disabled) { background: rgba(0, 0, 0, 0.05); }

.btn-lg {
  font-size: 1rem;
  padding: 0.75rem 2rem;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

/* ================================================================
   App Header
   ================================================================ */

#app-screen {
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #293556;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 10;
  color: #ffa100;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  height: 36px;
  width: auto;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-name {
  font-size: 0.875rem;
}

/* ================================================================
   Main Content
   ================================================================ */

.app-main {
  flex: 1;
  padding: 1.25rem 1.5rem;
  width: 100%;
}

/* Workspace bar */
.workspace-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.workspace-bar label {
  font-weight: 600;
  font-size: 0.875rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
  font-size: 0.875rem;
  color: #64748b;
  cursor: pointer;
  white-space: nowrap;
}

.workspace-bar select {
  flex: 1;
  min-width: 200px;
}

select, .search-input {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #1e293b;
  outline: none;
  transition: border-color 0.15s;
}

select:focus, .search-input:focus {
  border-color: #2563eb;
}

/* ================================================================
   Loading / Progress
   ================================================================ */

.loading-section {
  margin: 2rem 0;
}

.progress-bar-track {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #ffa100;
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 0.5rem;
}

/* ================================================================
   Stats Bar
   ================================================================ */

.stats-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.stat {
  background: #fff;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  min-width: 100px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #293556;
}

.stat-label {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

/* ================================================================
   Info Note
   ================================================================ */

.info-note {
  font-size: 0.8rem;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  margin-bottom: 1rem;
}

/* ================================================================
   Toolbar
   ================================================================ */

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

.search-input {
  flex: 1;
  min-width: 180px;
}

.filter-select {
  min-width: 130px;
}

/* ================================================================
   Footer
   ================================================================ */

.app-footer {
  text-align: center;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.feedback-link {
  font-size: 0.8rem;
  color: #94a3b8;
  text-decoration: none;
}
.feedback-link:hover { color: #ffa100; text-decoration: underline; }

/* Multi-select creator filter */
.multi-select {
  position: relative;
}

.multi-select-trigger {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #1e293b;
  cursor: pointer;
  min-width: 150px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  white-space: nowrap;
  outline: none;
  transition: border-color 0.15s;
}
.multi-select-trigger:hover,
.multi-select-trigger:focus { border-color: #2563eb; }

.multi-select-arrow { font-size: 0.65rem; color: #94a3b8; }

.multi-select-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  z-index: 50;
  min-width: 200px;
  max-height: 280px;
  overflow-y: auto;
}

.multi-select-actions {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
}

.multi-select-action {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.75rem;
  color: #2563eb;
  cursor: pointer;
  padding: 0;
}
.multi-select-action:hover { text-decoration: underline; }

.multi-select-divider {
  height: 1px;
  background: #e2e8f0;
}

.multi-select-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: #1e293b;
}
.multi-select-item:hover { background: #f8fafc; }
.multi-select-item input[type="checkbox"] { cursor: pointer; }

/* ================================================================
   Data Table
   ================================================================ */

.table-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.data-table th {
  background: #f8fafc;
  font-weight: 600;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
  user-select: none;
}

.data-table th.sortable {
  cursor: pointer;
}
.data-table th.sortable:hover {
  background: #f1f5f9;
}

.sort-icon {
  font-size: 0.7rem;
  margin-left: 0.25rem;
  opacity: 0.35;
}
.sort-icon.asc::after { content: '▲'; }
.sort-icon.desc::after { content: '▼'; }

.data-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}

/* GID column should be compact and selectable */
.data-table td:nth-child(2) {
  min-width: 120px;
  max-width: 150px;
  font-family: 'Courier New', monospace;
}

/* Description column — cap width so it doesn't push other columns off screen */
.data-table td:nth-child(4) {
  max-width: 500px;
}

/* Let the locations & options columns breathe */
.data-table td:nth-child(9),
.data-table td:nth-child(10) {
  min-width: 200px;
}

/* Hide Last Used column (8th) when checkbox is unchecked */
.no-last-used .data-table th:nth-child(8),
.no-last-used .data-table td:nth-child(8) {
  display: none;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table tbody tr:nth-child(even) {
  background: #fafbfc;
}
.data-table tbody tr:nth-child(even):hover {
  background: #f1f5f9;
}

/* Cell helpers */
.cell-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: #e2e8f0;
  color: #475569;
}

.project-link {
  color: inherit;
  text-decoration: none;
}
.project-link:hover {
  color: #2563eb;
  text-decoration: underline;
}

.tag.location-project   { background: #e0f2fe; color: #075985; }
.tag.location-portfolio { background: #ede9fe; color: #5b21b6; }
.tag.location-goal      { background: #dcfce7; color: #166534; }

.tag.disabled {
  opacity: 0.5;
  text-decoration: line-through;
}

.type-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.type-badge.enum { background: #dbeafe; color: #1e40af; }
.type-badge.multi_enum { background: #ede9fe; color: #5b21b6; }
.type-badge.text { background: #dcfce7; color: #166534; }
.type-badge.number { background: #fef3c7; color: #92400e; }
.type-badge.date { background: #ffe4e6; color: #9f1239; }
.type-badge.people { background: #e0f2fe; color: #075985; }

.scope-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}
.scope-badge.global { background: #dcfce7; color: #166534; }
.scope-badge.local { background: #f1f5f9; color: #64748b; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.no-results {
  text-align: center;
  color: #94a3b8;
  padding: 2rem;
  font-size: 0.9rem;
}

/* ================================================================
   Error Banner
   ================================================================ */

.error-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  display: none;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 50;
  max-width: 90%;
}
.error-banner:not([hidden]) { display: flex; }

/* ================================================================
   Field Detail Modal
   ================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-overlay:not([hidden]) { display: flex; }

.modal-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
}

.modal-close-btn {
  color: #64748b;
  flex-shrink: 0;
  padding: 0.3rem 0.6rem;
}
.modal-close-btn:hover { color: #dc2626; background: #fef2f2; }

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #f1f5f9;
}

.modal-meta-item label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

.modal-meta-item p {
  font-size: 0.875rem;
  color: #1e293b;
  margin: 0;
  line-height: 1.5;
}

.modal-meta-item.full-width { grid-column: 1 / -1; }

.modal-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 0.75rem;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.modal-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  font-weight: 600;
  white-space: nowrap;
  color: #475569;
}

.modal-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.modal-table tbody tr:last-child td { border-bottom: none; }
.modal-table tbody tr:hover { background: #f8fafc; }

.field-name-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  color: #1e293b;
  text-align: left;
}
.field-name-btn:hover { color: #293556; text-decoration: underline; }

/* ================================================================
   Responsive
   ================================================================ */

@media (max-width: 640px) {
  .app-main { padding: 1rem; }

  .workspace-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .workspace-bar select { min-width: unset; }

  .toolbar { flex-direction: column; align-items: stretch; }

  .stats-bar { gap: 0.5rem; }
  .stat { flex: 1; min-width: 80px; padding: 0.6rem 0.8rem; }
  .stat-value { font-size: 1.15rem; }
}
