/* Bundle View & Interactive Layout Components */

/* Main Content Layout area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 20px;
}

/* Glass Cards */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 32px;
}

.card-title h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 8px 0;
  background: var(--header-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.card-title p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Progress Bar */
.progress-section {
  margin-bottom: 32px;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  border-radius: 100px;
  width: 0%;
  transition: width 0.4s ease;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}

/* Tables styling */
.table-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 20px 0;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th, .data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.data-table th {
  background: rgba(255, 255, 255, 0.01);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

.msg-subject {
  font-weight: 500;
  color: var(--text-primary);
}

.msg-date {
  color: var(--text-secondary);
  white-space: nowrap;
}

.extracted-val {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--popover-preview-bg);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--popover-preview-border);
  display: inline-block;
}

.empty-cell {
  color: rgba(255, 255, 255, 0.15);
  font-style: italic;
}

/* Flow View & Seen/Unseen Styles */
.flow-msg-row {
  cursor: pointer;
}

.flow-msg-row.unseen {
  border-left: 4px solid var(--accent);
  background: rgba(99, 102, 241, 0.03);
}

.unseen-row {
  background-color: rgba(99, 102, 241, 0.02);
  border-left: 3px solid var(--accent);
}

.scribble-input {
  border-bottom: 1px dashed transparent;
  transition: border-color 0.2s, color 0.2s;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

.scribble-input:focus {
  border-bottom-color: var(--accent);
  color: var(--text-primary);
}

/* Thread Expansion Styling */
tr.msg-row {
  cursor: pointer;
}

.flow-msg-row.thread-expanded {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.05);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

tr.msg-row.thread-expanded {
  background: rgba(99, 102, 241, 0.05);
}

tr.msg-row.thread-expanded td {
  border-bottom-color: transparent;
}

.thread-expand-container, .thread-expand-row {
  transition: all 0.3s ease-out;
}

/* Collapsible Flow Bundle Sections */
.flow-bundle-section {
  margin-bottom: 16px;
  transition: margin-bottom 0.3s ease-out;
}

.flow-bundle-section.collapsed {
  margin-bottom: 8px;
}

.flow-bundle-collapsible {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s ease-out;
}

.flow-bundle-section.collapsed .flow-bundle-collapsible {
  grid-template-rows: 0fr;
}

.flow-bundle-collapsible-inner {
  min-height: 0;
  overflow: hidden;
}

.flow-bundle-section.collapsed .chevron-icon {
  transform: rotate(-90deg);
}

.bundle-toggle-header:hover {
  opacity: 0.8;
}

/* Sticky Flow View Header */
.flow-view-header {
  position: sticky;
  top: -40px;
  z-index: 10;
  background: rgba(10, 15, 26, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  margin-left: -40px;
  margin-right: -40px;
  padding-left: 40px;
  padding-right: 40px;
  margin-top: -40px;
  padding-top: 12px;
  padding-bottom: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* Hide scrollbars for top fields container */
.flow-msg-top-fields::-webkit-scrollbar {
  display: none;
}

/* Thread Premium Card View Layout Styles */
.thread-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.thread-card {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px 20px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  position: relative;
  box-sizing: border-box;
}

.thread-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.thread-card.unseen {
  border-left: 4px solid var(--accent);
  background: rgba(99, 102, 241, 0.03);
}

.thread-card.thread-expanded {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.05);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.thread-card-left {
  width: 135px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-self: stretch;
  background: var(--bundle-section-bg);
  border-right: 2px solid var(--bundle-section-border);
  margin: -16px 16px -16px -20px;
  padding: 16px 14px 16px 20px;
  border-radius: 15px 0 0 15px;
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.stacked-card .thread-card-left {
  margin: -16px 16px -10px -20px;
  padding: 16px 14px 10px 20px;
  border-radius: 15px 0 0 0;
}

.thread-card:hover .thread-card-left {
  border-right-color: var(--accent);
}

.thread-card-meta {
  display: flex;
  flex-direction: column;
}

.thread-card-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.thread-card-sender {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: normal;
  word-break: break-word;
  line-height: 1.2;
}

.thread-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}

.thread-card-actions .gmail-link,
.thread-card-actions .seen-toggle-btn,
.thread-card-actions .scribble-dialog-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, transform 0.1s;
}

.thread-card-actions .gmail-link:hover,
.thread-card-actions .seen-toggle-btn:hover,
.thread-card-actions .scribble-dialog-btn:hover {
  color: var(--accent);
  transform: scale(1.15);
}

.thread-card-actions .seen-toggle-btn.unseen-active {
  color: var(--accent);
}

.thread-card-actions .scribble-dialog-btn.has-notes {
  color: var(--warning);
}

.thread-card-middle {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px 24px;
  align-items: center;
  min-width: 0;
}

.extracted-data-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.015);
  border-radius: 12px;
  padding: 10px 14px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  overflow: hidden;
}

.extracted-data-cell:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

@media (max-width: 600px) {
  .extracted-data-cell {
    min-width: 100px;
    padding: 8px 10px;
    border-radius: 10px;
  }
}

.extracted-data-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.extracted-data-value {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-card .extracted-val {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Native Dialog Popup Styling */
.scribble-dialog {
  padding: 0;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  width: 400px;
  color: var(--text-primary);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.scribble-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.scribble-dialog-inner {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.scribble-dialog-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.scribble-dialog-textarea {
  width: 100%;
  height: 100px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  resize: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.scribble-dialog-textarea:focus {
  border-color: var(--accent);
}

/* Stacked Card View Layout Styles */
.stacked-cards-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
  margin: 10px 0;
  box-sizing: border-box;
}

.stacked-cards-container {
  position: relative;
  width: 100%;
  max-width: none;
  height: 120px;
  perspective: 1000px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-top: 24px; /* space for fanning out at the top */
}

.flow-bundle-section.stacked-layout {
  margin-bottom: 12px;
}

.flow-bundle-section.stacked-layout .stacked-cards-container {
  margin-top: 0px;
}

.stacked-card {
  position: absolute;
  width: 100%;
  max-width: none;
  min-height: 200px;
  background: var(--stacked-card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
  cursor: grab;
  user-select: none;
  transform-origin: center bottom;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1), opacity 0.3s ease, z-index 0s;
  padding: 16px 20px 48px 20px;
}

.stacked-card.unseen {
  background: var(--stacked-card-unseen-bg);
}

.stacked-card.thread-expanded {
  background: var(--stacked-card-expanded-bg);
}

.stacked-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.15), 0 15px 35px rgba(0, 0, 0, 0.4);
}

.stacked-card:active {
  cursor: grabbing;
}

.stacked-card-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--stacked-card-footer-border);
  background: var(--stacked-card-footer-bg);
  border-bottom-left-radius: 15px;
  border-bottom-right-radius: 15px;
  box-sizing: border-box;
  z-index: 30;
}

.stacked-card-footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  padding-right: 0;
}

.stack-nav-zone {
  width: 48px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 40;
  color: rgba(255, 255, 255, 0.15);
  transition: background-color 0.2s, color 0.2s;
}

.stack-nav-zone:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.6);
}

.stack-nav-zone.prev-zone {
  border-bottom-left-radius: 15px;
}

.stack-nav-zone.next-zone {
  border-bottom-right-radius: 15px;
}

.stacked-card-counter-badge {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 12px;
  pointer-events: none;
  white-space: nowrap;
}

.stacked-card .thread-card-actions {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
}

.stacked-cards-container .thread-expand-container {
  position: absolute;
  width: 100%;
  max-width: none;
  z-index: 50;
  box-sizing: border-box;
}

turbo-frame {
  display: block;
}
