/* Font Imports */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600&family=DM+Serif+Display&display=swap');

/* Reset and Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Space Grotesk', sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  background: linear-gradient(to bottom, #ffffff 0%, #FFF6F0 100%);
  min-height: 100vh;
  color: #18181b;
  line-height: 1.6;
}

/* Animated gradient for input border */
@keyframes gradientMove {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Decorative Circles */
.decorative-circle {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFBD94 0%, rgba(255, 189, 148, 0) 70%);
  opacity: 1;
  pointer-events: none;
  z-index: -1;
}

.decorative-circle-top-right {
  top: 0;
  right: 0;
  transform: translate(30%, -30%);
}

.decorative-circle-bottom-left {
  bottom: 0;
  left: 0;
  transform: translate(-50%, 50%);
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Logo */
.logo-container {
  text-align: center;
  margin-bottom: 0.75rem;
}

.logo {
  width: 60px;
  height: 60px;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 3rem;
}

header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 2.5rem;
  font-weight: normal;
  color: #18181b;
  margin-bottom: 0.5rem;
  letter-spacing: 0.025em;
  line-height: 1.05;
}

.subtitle {
  color: #71717a;
  font-size: 1.1rem;
  font-weight: 400;
}

/* Step Cards - Glassmorphism */
.step {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.1);
  transition: opacity 0.3s, transform 0.3s;
}

.step.hidden {
  display: none;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.step-number {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #DE5D0D, #F59E0B);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  font-size: 0.9rem;
}

.step-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  font-weight: normal;
  color: #18181b;
}

.results-subtitle {
  font-size: 0.85rem;
  color: #71717a;
  margin-top: 0.25rem;
}

/* Input Group with Gradient Border */
.input-group {
  display: flex;
  border-radius: 12px;
  overflow: hidden;
  background-image: linear-gradient(#fff, #fff), linear-gradient(to right, #DE5D0D, #F59E0B, #FBBF24, #DE5D0D);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  background-size: 100% 100%, 400% 100%;
  animation: gradientMove 4s ease infinite;
  border: 3px solid transparent;
  box-shadow: 0 0 20px rgba(222, 93, 13, 0.2), 0 4px 16px rgba(0, 0, 0, 0.08);
}

.input-group:focus-within {
  background-image: linear-gradient(#fff, #fff), linear-gradient(to right, #FFBD94, #FFD4B4, #FFECC4, #FFBD94);
  box-shadow: 0 0 25px rgba(255, 189, 148, 0.4), 0 4px 20px rgba(0, 0, 0, 0.1);
}

.input-group input {
  flex: 1;
  padding: 1rem;
  border: none;
  background: #fff;
  color: #18181b;
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
}

.input-group input::placeholder {
  color: #a1a1aa;
}

.input-group button {
  padding: 0.5rem 1.25rem;
  margin: 0.25rem;
  background: #18181b;
  border: none;
  border-radius: 9px;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.input-group button:hover {
  background: #27272a;
}

.input-group button:active {
  transform: scale(0.95);
}

.input-group button:disabled {
  background: #a1a1aa;
  cursor: not-allowed;
  transform: none;
}

/* Standalone Buttons */
button {
  padding: 0.5rem 1.25rem;
  background: #18181b;
  border: none;
  border-radius: 9px;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

button:hover {
  background: #27272a;
  transform: translateY(-1px);
}

button:active {
  transform: scale(0.95);
}

button:disabled {
  background: #a1a1aa;
  cursor: not-allowed;
  transform: none;
}

/* Info Box */
.info-box {
  background: rgba(222, 93, 13, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(222, 93, 13, 0.3);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  color: #18181b;
  font-weight: 500;
}

.info-box.hidden {
  display: none;
}

.info-box strong {
  color: #DE5D0D;
}

/* Error Box */
.error-box {
  background: rgba(254, 226, 226, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  color: #ef4444;
  font-weight: 500;
}

.error-box.hidden {
  display: none;
}

/* Table List */
.table-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.table-item {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.table-item:hover {
  border-color: #FFBD94;
  background: rgba(255, 189, 148, 0.15);
  transform: translateY(-2px);
}

.table-item.selected {
  border-color: #DE5D0D;
  background: rgba(255, 189, 148, 0.2);
}

.table-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.table-item .table-icon {
  display: flex;
  align-items: center;
  color: #DE5D0D;
  flex-shrink: 0;
}

.table-item .table-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #18181b;
  font-weight: 500;
  flex: 1;
}

.table-item .badge {
  background: linear-gradient(135deg, #DE5D0D, #F59E0B);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.table-item.disabled .badge {
  background: #a1a1aa;
  color: #fff;
}

/* Results Table Wrapper */
.table-wrapper {
  overflow-x: auto;
  margin-top: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#resultsTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

#resultsTable th {
  background: rgba(255, 189, 148, 0.2);
  color: #18181b;
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
  border-bottom: 2px solid rgba(222, 93, 13, 0.2);
  transition: background 0.2s;
}

#resultsTable th:hover {
  background: rgba(255, 189, 148, 0.3);
}

#resultsTable th .th-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

#resultsTable th .th-label {
  cursor: pointer;
  flex: 1;
}

#resultsTable th .sort-indicator {
  margin-left: 0.5rem;
  opacity: 0.5;
  color: #DE5D0D;
}

#resultsTable th.sorted .sort-indicator {
  opacity: 1;
}

#resultsTable th .hide-column-btn {
  opacity: 0;
  background: transparent;
  border: none;
  color: #71717a;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
  box-shadow: none;
}

#resultsTable th:hover .hide-column-btn {
  opacity: 1;
}

#resultsTable th .hide-column-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #18181b;
  transform: none;
}

/* Drag and drop styles */
#resultsTable th[draggable="true"] {
  cursor: grab;
}

#resultsTable th.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

#resultsTable th.drag-over {
  background: rgba(222, 93, 13, 0.3);
  box-shadow: inset 0 0 0 2px #DE5D0D;
}

/* Column resize handle */
#resultsTable th {
  position: relative;
}

#resultsTable th .resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.2s;
}

#resultsTable th .resize-handle:hover,
#resultsTable th .resize-handle:active {
  background: rgba(222, 93, 13, 0.5);
}

/* Hidden columns bar */
.hidden-columns-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  color: #a1a1aa;
}

.hidden-columns-bar button {
  padding: 0.125rem 0.375rem;
  font-size: 0.7rem;
  background: transparent;
  border: none;
  color: #DE5D0D;
  box-shadow: none;
  text-decoration: underline;
}

.hidden-columns-bar button:hover {
  color: #F59E0B;
  transform: none;
}

#resultsTable td {
  padding: 0.75rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #18181b;
}

#resultsTable tr:hover td {
  background: rgba(255, 189, 148, 0.1);
}

#resultsTable td.expanded {
  white-space: normal;
  word-break: break-word;
}

/* Loading States */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  color: #71717a;
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(222, 93, 13, 0.2);
  border-top-color: #DE5D0D;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 1000;
}

.loading-overlay.hidden {
  display: none;
}

.loading-overlay .spinner {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

.loading-overlay span {
  color: #18181b;
  font-weight: 500;
}

/* Filter Container */
.filter-container {
  margin-bottom: 1rem;
}

.filter-container input {
  width: 100%;
  max-width: 300px;
  padding: 0.75rem 1rem;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  color: #18181b;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-container input:focus {
  outline: none;
  border-color: #FFBD94;
  box-shadow: 0 0 0 3px rgba(255, 189, 148, 0.2);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: #71717a;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h3 {
  font-family: 'DM Serif Display', serif;
  color: #18181b;
  font-size: 1.2rem;
  font-weight: normal;
}

.modal-close {
  background: transparent;
  border: none;
  color: #71717a;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
  box-shadow: none;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #18181b;
  transform: none;
  box-shadow: none;
}

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

.record-field {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.record-field:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.record-field-name {
  color: #DE5D0D;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.record-field-value {
  color: #18181b;
  word-break: break-word;
  white-space: pre-wrap;
}

.record-field-value.empty {
  color: #a1a1aa;
  font-style: italic;
}

/* Clickable table rows */
#resultsTable tbody tr {
  cursor: pointer;
}

/* Links in table and modal */
#resultsTable a,
.record-field-value a {
  color: #DE5D0D;
  text-decoration: underline;
  transition: color 0.2s;
}

#resultsTable a:hover,
.record-field-value a:hover {
  color: #F59E0B;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  header h1 {
    font-size: 1.75rem;
  }

  .input-group {
    flex-direction: column;
    background: none;
    border: none;
    box-shadow: none;
    gap: 0.75rem;
    animation: none;
  }

  .input-group input {
    border: 2px solid rgba(222, 93, 13, 0.3);
    border-radius: 9px;
    box-shadow: 0 0 15px rgba(222, 93, 13, 0.15);
  }

  .input-group button {
    margin: 0;
    padding: 1rem 1.5rem;
    width: 100%;
  }

  .table-list {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}
