/* Wolf Gordon Email Processor - Web Interface Styles */

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --success-color: #16a34a;
  --warning-color: #ca8a04;
  --danger-color: #dc2626;
  --info-color: #0891b2;
  --light-color: #f3f4f6;
  --dark-color: #1f2937;
  --border-color: #e5e7eb;
  --text-color: #374151;
  --text-muted: #6b7280;
  --bg-color: #f9fafb;
  --card-bg: #ffffff;
}

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navigation */
.navbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand a {
  color: var(--dark-color);
  text-decoration: none;
  display: flex;
  align-items: center;
}

.nav-brand svg {
  display: block;
}

.nav-links a {
  color: var(--text-color);
  text-decoration: none;
  margin-left: 1.5rem;
  font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary-color);
}

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  flex: 1;
}

/* Page Header */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.75rem;
  color: var(--dark-color);
  margin-bottom: 0.5rem;
}

.page-header .subtitle {
  color: var(--text-muted);
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.back-link:hover {
  color: var(--primary-color);
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h3 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  color: var(--dark-color);
}

/* Email List */
.email-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 60vh; /* Consistent height to prevent layout shift between pages */
  width: 100%;
}

.email-card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 1rem 1.5rem;
  text-decoration: none;
  color: var(--text-color);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.email-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.email-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.email-from {
  font-weight: 600;
  color: var(--dark-color);
}

.email-date {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.email-subject {
  font-size: 0.9375rem;
  margin-bottom: 0.5rem;
}

.email-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Email Detail */
.email-detail {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
}

.email-meta-detail {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.meta-row {
  display: flex;
  margin-bottom: 0.5rem;
}

.meta-label {
  font-weight: 600;
  width: 100px;
  flex-shrink: 0;
}

.meta-value {
  color: var(--text-color);
}

.attachment-tag {
  display: inline-block;
  background: var(--light-color);
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  margin-right: 0.5rem;
}

.email-body {
  padding: 1.5rem;
}

.email-body h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--dark-color);
}

.body-content {
  background: var(--bg-color);
  padding: 1rem;
  border-radius: 0.25rem;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.875rem;
  max-height: 400px;
  overflow-y: auto;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #e0f2fe;
  color: #0c4a6e;
}

.badge-secondary {
  background: #f3f4f6;
  color: #4b5563;
}

.badge-light {
  background: #f9fafb;
  color: #6b7280;
  border: 1px solid var(--border-color);
}

/* Confidence badges */
.badge-confidence {
  font-variant-numeric: tabular-nums;
}

.badge-confidence.confidence-high {
  background: #dcfce7;
  color: #166534;
}

.badge-confidence.confidence-medium {
  background: #fef3c7;
  color: #92400e;
}

.badge-confidence.confidence-low {
  background: #fee2e2;
  color: #991b1b;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-success:hover {
  background: #15803d;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.form-group input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}

/* Processing Section */
.processing-section {
  margin-top: 1.5rem;
}

.processing-card {
  text-align: center;
}

.progress-container {
  margin: 1.5rem 0;
}

.progress-steps {
  display: flex;
  justify-content: center;
  gap: 2rem;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0.4;
}

.step.active {
  opacity: 1;
}

.step.complete .step-icon {
  background: var(--success-color);
  color: white;
}

.step-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--light-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.step.active .step-icon {
  background: var(--primary-color);
  color: white;
}

.step-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.progress-message {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Spinner */
.spinner-container {
  display: flex;
  justify-content: center;
  padding: 1rem;
}

.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--light-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Result Display */
.result-card {
  text-align: left;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

/* Tabbed layout */
.result-tabs {
  margin: 1.5rem 0;
}

/* Hide radio inputs */
.tab-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Tab navigation */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 0;
}

.tab-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  border-radius: 0.5rem 0.5rem 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -2px;
  transition: all 0.2s ease;
  color: var(--text-muted);
  background: transparent;
}

.tab-label:hover {
  color: var(--text-color);
  background: var(--bg-color);
}

.tab-icon {
  font-size: 1rem;
}

/* Tab badge for "No matches" */
.tab-badge {
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background: #fef3c7;
  color: #92400e;
  margin-left: 0.25rem;
}

.tab-badge-cost {
  background: #ffedd5;
  color: #9a3412;
}

/* Active tab states - Extracted (two-tab layout only) */
.tab-label-extracted {
  border-color: transparent;
}

.result-tabs.two-tabs
  .tab-input:first-of-type:checked
  ~ .tab-nav
  .tab-label-extracted {
  background: #fefefe;
  color: #4b5563;
  border-color: #d1d5db;
  border-bottom-color: #fefefe;
}

/* Active tab states - Matched (two-tab layout only) */
.tab-label-matched {
  border-color: transparent;
}

.result-tabs.two-tabs
  .tab-input:last-of-type:checked
  ~ .tab-nav
  .tab-label-matched {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
  border-bottom-color: #ecfdf5;
}

.result-tabs.two-tabs
  .tab-input:last-of-type:checked
  ~ .tab-nav
  .tab-label-costs {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
  border-bottom-color: #fff7ed;
}

/* Costs tab styling */
.tab-label-costs {
  border-color: transparent;
}

/* Single tab (non-sample request) */
.single-tab .tab-label.active-only {
  background: #fefefe;
  color: #4b5563;
  border-color: #d1d5db;
  border-bottom-color: #fefefe;
  cursor: default;
}

/* Tab panels container */
.tab-panels {
  background: #fefefe;
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 0.5rem 0.5rem;
}

/* Individual tab panels */
.tab-panel {
  display: none;
  padding: 0;
}

/* Two-tab layout: Show extracted panel when first radio checked */
.result-tabs.two-tabs
  .tab-input:first-of-type:checked
  ~ .tab-panels
  .tab-panel.panel-extracted {
  display: block;
}

/* Two-tab layout: Show matched panel when second radio checked */
.result-tabs.two-tabs
  .tab-input:last-of-type:checked
  ~ .tab-panels
  .tab-panel.panel-matched {
  display: block;
}

/* Two-tab layout: Show costs panel when second radio checked */
.result-tabs.two-tabs
  .tab-input:last-of-type:checked
  ~ .tab-panels
  .tab-panel.panel-costs {
  display: block;
}

/* Three-tab layout: Show extracted panel when first radio checked */
.three-tabs
  .tab-input:nth-of-type(1):checked
  ~ .tab-panels
  .tab-panel.panel-extracted {
  display: block;
}

/* Four-tab layout: Show extracted panel when first radio checked */
.four-tabs
  .tab-input:nth-of-type(1):checked
  ~ .tab-panels
  .tab-panel.panel-extracted {
  display: block;
}

/* Three-tab layout: Show matched panel when second radio checked */
.three-tabs
  .tab-input:nth-of-type(2):checked
  ~ .tab-panels
  .tab-panel.panel-matched {
  display: block;
}

/* Four-tab layout: Show matched panel when second radio checked */
.four-tabs
  .tab-input:nth-of-type(2):checked
  ~ .tab-panels
  .tab-panel.panel-matched {
  display: block;
}

/* Three-tab layout: Show API panel when third radio checked */
.three-tabs
  .tab-input:nth-of-type(3):checked
  ~ .tab-panels
  .tab-panel.panel-api {
  display: block;
}

/* Four-tab layout: Show API panel when third radio checked */
.four-tabs
  .tab-input:nth-of-type(3):checked
  ~ .tab-panels
  .tab-panel.panel-api {
  display: block;
}

/* Four-tab layout: Show costs panel when fourth radio checked */
.four-tabs
  .tab-input:nth-of-type(4):checked
  ~ .tab-panels
  .tab-panel.panel-costs {
  display: block;
}

/* Three-tab active states */
.three-tabs .tab-input:nth-of-type(1):checked ~ .tab-nav .tab-label-extracted {
  background: #fefefe;
  color: #4b5563;
  border-color: #d1d5db;
  border-bottom-color: #fefefe;
}

.four-tabs .tab-input:nth-of-type(1):checked ~ .tab-nav .tab-label-extracted {
  background: #fefefe;
  color: #4b5563;
  border-color: #d1d5db;
  border-bottom-color: #fefefe;
}

.three-tabs .tab-input:nth-of-type(2):checked ~ .tab-nav .tab-label-matched {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
  border-bottom-color: #ecfdf5;
}

.four-tabs .tab-input:nth-of-type(2):checked ~ .tab-nav .tab-label-matched {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
  border-bottom-color: #ecfdf5;
}

.three-tabs .tab-input:nth-of-type(3):checked ~ .tab-nav .tab-label-api {
  background: #eff6ff;
  color: #1e40af;
  border-color: #93c5fd;
  border-bottom-color: #eff6ff;
}

.four-tabs .tab-input:nth-of-type(3):checked ~ .tab-nav .tab-label-api {
  background: #eff6ff;
  color: #1e40af;
  border-color: #93c5fd;
  border-bottom-color: #eff6ff;
}

/* Four-tab active states */
.four-tabs .tab-input:nth-of-type(4):checked ~ .tab-nav .tab-label-costs {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
  border-bottom-color: #fff7ed;
}

/* Extracted panel styling */
.tab-panel.panel-extracted {
  border-left: 4px solid #6b7280;
}

/* Matched panel styling */
.tab-panel.panel-matched {
  border-left: 4px solid #10b981;
  background: linear-gradient(135deg, #fefefe 0%, #f0fdf4 100%);
}

/* API panel styling */
.tab-panel.panel-api {
  border-left: 4px solid #3b82f6;
  background: linear-gradient(135deg, #fefefe 0%, #eff6ff 100%);
}

/* Costs panel styling */
.tab-panel.panel-costs {
  border-left: 4px solid #f59e0b;
  background: linear-gradient(135deg, #fefefe 0%, #fff7ed 100%);
}

/* Panel content */
.panel-content {
  padding: 1rem;
}

.panel-content .result-section {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
  margin-bottom: 1rem;
}

.panel-content .result-section:last-child {
  margin-bottom: 0;
}

.panel-content h5 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin: 0 0 0.5rem 0;
}

/* Cost summary */
.cost-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 0.75rem;
}

.costs-table th,
.costs-table td {
  text-align: left;
}

.costs-number {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.costs-table tfoot {
  border-top: 1px solid var(--border-color);
}

.costs-total-row td {
  font-weight: 600;
  color: var(--text-color);
  background: #fff7ed;
}

.costs-subtotal-row td {
  font-weight: 500;
  color: var(--text-muted);
  background: #fefce8;
  font-size: 0.875rem;
  border-top: 1px solid #e5e7eb;
}

.costs-label {
  text-align: right !important;
}

/* Confidence summary in matched panel */
.confidence-summary {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #d1fae5;
  font-size: 0.875rem;
  font-weight: 500;
  color: #059669;
}

/* Not matched badge */
.not-matched-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  background: #fef3c7;
  color: #92400e;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* Warning variant of tab badge */
.tab-badge-warning {
  background: #fef3c7;
  color: #92400e;
}

/* Ready variant of tab badge */
.tab-badge-ready {
  background: #dbeafe;
  color: #1e40af;
}

/* ============================================
   API JSON Panel
   ============================================ */

.api-json-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.api-endpoint {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1e40af;
  background: #dbeafe;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
}

.btn-copy {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

.btn-copy:hover {
  background: #e5e7eb;
  color: #111827;
}

.api-json-content {
  background: #1e293b;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
  max-height: 500px;
  overflow-y: auto;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Syntax highlighting for JSON */
.api-json-content .json-string {
  color: #a5d6ff;
}
.api-json-content .json-number {
  color: #79c0ff;
}
.api-json-content .json-boolean {
  color: #ff7b72;
}
.api-json-content .json-null {
  color: #ff7b72;
}
.api-json-content .json-key {
  color: #7ee787;
}

/* Unmatched section styling */
.unmatched-section {
  background: #fffbeb;
  border-radius: 0.375rem;
  padding: 0.75rem !important;
  margin: 0.5rem 0;
}

.unmatched-section h5 {
  color: #92400e;
}

/* Unmatched table row styling */
.unmatched-row {
  background: #fffbeb;
}

.unmatched-row td {
  color: #78716c;
}

.unmatched-row .product-name {
  color: #78716c;
  font-weight: normal;
}

/* Not matched cell in table */
.not-matched-cell {
  text-align: center;
}

.not-matched-cell .not-matched-badge {
  margin-left: 0;
}

/* Empty state for no matches */
.panel-empty {
  padding: 1.5rem;
  text-align: center;
  color: #9ca3af;
  font-style: italic;
}

/* ID values styling */
.id-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  background: #f3f4f6;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
}

/* Product name styling - highlight the matched name */
.product-name {
  font-weight: 500;
  color: #065f46;
}

/* Notes section outside panels */
.notes-section {
  margin-top: 0;
}

.result-section {
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
  margin-top: 1rem;
}

.result-section h4 {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.result-item {
  display: flex;
  flex-direction: column;
}

.result-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.result-value {
  font-weight: 500;
}

.address-block {
  line-height: 1.8;
}

/* Items Table */
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.items-table th,
.items-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.items-table th {
  font-weight: 600;
  background: var(--bg-color);
}

.items-table tr:last-child td {
  border-bottom: none;
}

/* Resolved Entities */
.resolved-entity,
.resolved-items {
  margin-top: 0.75rem;
}

.resolved-items ul {
  margin-top: 0.5rem;
  padding-left: 1.5rem;
}

.resolved-items li {
  margin-bottom: 0.25rem;
}

/* Notes */
.notes-list {
  padding-left: 1.5rem;
}

.notes-list li {
  margin-bottom: 0.25rem;
  color: var(--text-muted);
}

/* Actions */
.result-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 0.375rem;
  margin: 1rem 0;
}

.alert-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* Footer */
.footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  padding: 1rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Utilities */
.text-muted {
  color: var(--text-muted);
}

/* ============================================
   Email Content Tabs (Body & Attachments)
   ============================================ */

.email-content-tabs {
  background: var(--card-bg);
  border-radius: 0 0 0.5rem 0.5rem;
}

/* Tab navigation for email content - use specific selectors to not conflict with result tabs */
.email-content-tabs > .tab-nav {
  display: flex;
  gap: 0.25rem;
  padding: 0 1.5rem;
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-color);
}

.email-content-tabs > .tab-nav .tab-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 0.5rem 0.5rem 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -2px;
  transition: all 0.2s ease;
  color: var(--text-muted);
  background: transparent;
}

.email-content-tabs > .tab-nav .tab-label:hover {
  color: var(--text-color);
  background: var(--card-bg);
}

/* Active tab state for email body tab */
.email-content-tabs
  > .tab-input:first-of-type:checked
  ~ .tab-nav
  label[for="tab-body"] {
  background: var(--card-bg);
  color: var(--text-color);
  border-color: var(--border-color);
  border-bottom-color: var(--card-bg);
}

/* Active tab state for attachments tab */
.email-content-tabs
  > .tab-input:last-of-type:checked
  ~ .tab-nav
  label[for="tab-attachments"] {
  background: var(--card-bg);
  color: var(--text-color);
  border-color: var(--border-color);
  border-bottom-color: var(--card-bg);
}

/* Tab panels for email content */
.email-content-tabs > .tab-panels {
  background: var(--card-bg);
  border: none;
  border-radius: 0 0 0.5rem 0.5rem;
}

.email-content-tabs > .tab-panels > .tab-panel {
  display: none;
  padding: 1.5rem;
}

/* Show body panel when first radio checked */
.email-content-tabs
  > .tab-input:first-of-type:checked
  ~ .tab-panels
  > #panel-body {
  display: block;
}

/* Show attachments panel when second radio checked */
.email-content-tabs
  > .tab-input:last-of-type:checked
  ~ .tab-panels
  > #panel-attachments {
  display: block;
}

/* ============================================
   Attachment Cards
   ============================================ */

.attachment-card {
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  margin-bottom: 0.75rem;
  overflow: hidden;
  background: var(--card-bg);
}

.attachment-card:last-child {
  margin-bottom: 0;
}

.attachment-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-color);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}

.attachment-header:hover {
  background: #f0f1f3;
}

.attachment-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.attachment-name {
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.attachment-toggle {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.attachment-card.expanded .attachment-toggle {
  transform: rotate(180deg);
}

/* Attachment preview area */
.attachment-preview {
  display: none;
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background: #fafafa;
}

.attachment-card.expanded .attachment-preview {
  display: block;
}

/* Image preview */
.attachment-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 0.25rem;
  display: block;
}

/* PDF preview */
.attachment-preview iframe {
  width: 100%;
  height: 500px;
  border: none;
  border-radius: 0.25rem;
}

/* Unsupported preview message */
.preview-unsupported {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

/* Attachment actions */
.attachment-actions {
  display: none;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-color);
}

.attachment-card.expanded .attachment-actions {
  display: block;
}

/* Small button variant */
.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-secondary {
  background: var(--light-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: #e5e7eb;
}

/* ============================================
   Pagination
   ============================================ */

.pagination {
  display: flex;
  justify-content: center;
  padding: 1.25rem 0;
}

.pagination-inner {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: linear-gradient(180deg, #fafafa 0%, #f0f0f0 100%);
  border: 1px solid #d4d4d4;
  border-radius: 0.5rem;
  padding: 0.375rem;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #525252;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pagination-btn:hover:not(.disabled):not(.active) {
  background: #ffffff;
  border-color: #d4d4d4;
  color: #171717;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.pagination-btn.active {
  background: #171717;
  border-color: #171717;
  color: #ffffff;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.pagination-btn.disabled {
  color: #a3a3a3;
  cursor: not-allowed;
  opacity: 0.6;
}

.pagination-btn svg {
  flex-shrink: 0;
}

.pagination-prev,
.pagination-next {
  padding: 0;
  width: 2.25rem;
}

.pagination-ellipsis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 2.25rem;
  color: #a3a3a3;
  font-size: 0.875rem;
  letter-spacing: 0.1em;
  user-select: none;
}

/* Page header with meta info */
.header-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.email-range {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.per-page-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.per-page-selector label {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.per-page-selector select {
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  background: var(--card-bg);
  color: var(--text-color);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.per-page-selector select:hover {
  border-color: #a3a3a3;
}

.per-page-selector select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

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

  .navbar {
    padding: 1rem;
  }

  .progress-steps {
    gap: 1rem;
  }

  .step-icon {
    width: 2rem;
    height: 2rem;
    font-size: 0.875rem;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  /* Pagination mobile */
  .pagination-inner {
    gap: 0.25rem;
    padding: 0.25rem;
  }

  .pagination-btn {
    min-width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
  }

  .pagination-prev,
  .pagination-next {
    width: 2rem;
  }

  .pagination-ellipsis {
    width: 1rem;
  }

  .header-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ============================================================================
   Login Page Styles
   ============================================================================ */

.login-body {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 1rem;
}

.login-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  padding: 2.5rem;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header .login-logo {
  color: var(--dark-color);
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.login-form .form-group {
  margin-bottom: 1.25rem;
}

.login-form label {
  display: block;
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-login {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.alert {
  padding: 0.875rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
}

.alert-danger {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

/* ============================================================================
   Navbar User Styles
   ============================================================================ */

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.nav-username {
  font-weight: 500;
  color: var(--text-color);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-admin {
  background-color: #dbeafe;
  color: #1d4ed8;
}

.badge-user {
  background-color: #f3f4f6;
  color: #6b7280;
}

.nav-logout-form {
  display: inline;
}

.btn-logout {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-logout:hover {
  background-color: var(--danger-color);
  border-color: var(--danger-color);
  color: white;
}

/* One-tab layout (single panel, no switching needed) */
.result-tabs.one-tab .tab-nav {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.result-tabs.one-tab .tab-label {
  cursor: default;
  color: var(--text-color);
}

.result-tabs.one-tab .tab-label.active {
  color: var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
}

/* Three-tab layout */
.result-tabs.three-tabs .tab-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
  .login-card {
    padding: 1.5rem;
  }

  .nav-user {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .nav-username {
    font-size: 0.875rem;
  }
}
