/*
  shadcn-inspired UI tokens and components
  Scoped via [data-ui="shadcn"] to avoid global overrides
*/

:root {
  --ui-background: #0b0c10;          /* page background (kept subtle behind shapes) */
  --ui-foreground: #0f172a;          /* text base */
  --ui-card: #ffffff;                 /* surface */
  --ui-card-foreground: #0b1220;
  --ui-muted: #f3f4f6;
  --ui-muted-foreground: #6b7280;
  --ui-border: #e5e7eb;
  --ui-input: #f9fafb;
  --ui-ring: #6366f1;                 /* indigo */
  --ui-primary: #4f46e5;              /* indigo-600 */
  --ui-primary-foreground: #ffffff;
  --ui-secondary: #111827;            /* gray-900 */
  --ui-secondary-foreground: #ffffff;
  --ui-accent: #22c55e;               /* green-500 */
  --ui-destructive: #ef4444;          /* red-500 */
  --ui-warning: #f59e0b;              /* amber-500 */

  --ui-radius: 12px;
  --ui-radius-sm: 8px;
  --ui-radius-lg: 16px;
  --ui-shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --ui-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --ui-shadow-lg: 0 18px 60px rgba(15, 23, 42, 0.12);
}

[data-ui="shadcn"] .modal-container {
  background: var(--ui-card);
  color: var(--ui-card-foreground);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow-lg);
  padding: 28px;
  /* Override base 8vh vertical margins to avoid large top gap */
  margin: 20px auto;
  position: relative;
  z-index: 1;
}

[data-ui="shadcn"] .error-page-container,
[data-ui="shadcn"] .success-page-container {
  max-width: 880px;
}

/* Background shapes should not take layout space */
[data-ui="shadcn"] .background-shapes-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Hide navigation bar */
[data-ui="shadcn"] .dynamic-navigation {
  display: none !important;
}

/* Fix copy icon and optimize button layout */
[data-ui="shadcn"] .copy-btn {
  background: #ffffff;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  padding: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  flex-grow: 0;
  box-sizing: border-box;
  position: relative;
  font-size: 0;
  text-indent: -9999px;
  overflow: hidden;
}

[data-ui="shadcn"] .copy-btn i {
  font-size: 14px;
  color: var(--ui-foreground);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-indent: 0;
}

/* Optimize spacing and sizing */
[data-ui="shadcn"] .success-title,
[data-ui="shadcn"] .error-title {
  font-size: 24px;
  margin: 8px 0 6px 0;
}

[data-ui="shadcn"] .success-description,
[data-ui="shadcn"] .error-description {
  margin-bottom: 16px;
}

[data-ui="shadcn"] .benefit-code-section,
[data-ui="shadcn"] .project-info-section,
[data-ui="shadcn"] .usage-instructions {
  margin: 16px 0;
}

[data-ui="shadcn"] .benefit-code-section h3,
[data-ui="shadcn"] .project-info-section h3,
[data-ui="shadcn"] .usage-instructions h3 {
  font-size: 16px;
  margin: 0 0 10px 0;
}

[data-ui="shadcn"] .success-actions,
[data-ui="shadcn"] .error-actions {
  margin: 20px 0 16px 0;
  gap: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

[data-ui="shadcn"] .btn {
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
  flex: 0 0 auto;
}

[data-ui="shadcn"] .btn i {
  font-size: 14px;
}

/* Hide unnecessary email-related elements */
[data-ui="shadcn"] .important-notice {
  display: none;
}

/* Optimize code display */
[data-ui="shadcn"] .benefit-code-section .code-display-container {
  display: flex;
  flex-direction: row;
  padding: 8px 10px;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
  margin-bottom: 0;
}

[data-ui="shadcn"] .benefit-code {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--ui-primary);
}

/* Code notice styling */
[data-ui="shadcn"] .code-notice {
  font-size: 12px;
  line-height: 1.3;
  margin-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Optimize share section */
[data-ui="shadcn"] .share-section {
  margin: 16px 0 0 0;
}

[data-ui="shadcn"] .share-section p {
  font-size: 13px;
  margin: 0 0 8px 0;
  color: var(--ui-muted-foreground);
}

[data-ui="shadcn"] .share-buttons {
  gap: 6px;
}

[data-ui="shadcn"] .share-btn {
  width: 32px;
  height: 32px;
  padding: 8px;
  font-size: 14px;
}

/* Make success page more compact on small screens */
@media (max-width: 640px) {
  [data-ui="shadcn"] .modal-container {
    margin: 6px auto;
    padding: 10px 8px;
    max-width: calc(100vw - 16px);
  }
  
  [data-ui="shadcn"] .success-title,
  [data-ui="shadcn"] .error-title {
    font-size: 20px;
    margin: 6px 0 4px 0;
  }
  
  [data-ui="shadcn"] .benefit-code-section,
  [data-ui="shadcn"] .project-info-section,
  [data-ui="shadcn"] .usage-instructions {
    margin: 12px 0;
  }
  
  [data-ui="shadcn"] .success-actions,
  [data-ui="shadcn"] .error-actions {
    margin: 16px 0 12px 0;
    gap: 6px;
    flex-direction: row;
  }
  
  [data-ui="shadcn"] .btn {
    padding: 8px;
    font-size: 0;
    min-width: 0;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    justify-content: center;
    align-items: center;
    position: relative;
  }
  
  [data-ui="shadcn"] .btn i {
    font-size: 16px;
  }
  
  /* Hide text content on mobile, keep only icons */
  [data-ui="shadcn"] .btn {
    text-indent: -9999px;
    overflow: hidden;
  }
  
  [data-ui="shadcn"] .btn i {
    text-indent: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  
  [data-ui="shadcn"] .project-details-card,
  [data-ui="shadcn"] .usage-content,
  [data-ui="shadcn"] .benefits-recommendation,
  [data-ui="shadcn"] .advertisement-section {
    padding: 12px;
  }
  
  /* Ensure copy button doesn't wrap on mobile */
  [data-ui="shadcn"] .benefit-code-section .code-display-container {
    padding: 6px 8px;
    gap: 6px;
  }
  
  [data-ui="shadcn"] .copy-btn {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }
  
  [data-ui="shadcn"] .copy-btn i {
    font-size: 12px;
  }
  
  /* Mobile code notice - smaller font to keep on one line */
  [data-ui="shadcn"] .code-notice {
    font-size: 11px;
    line-height: 1.2;
    margin-top: 6px;
  }
}

[data-ui="shadcn"] .error-title,
[data-ui="shadcn"] .success-title {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 12px 0 8px 0;
  color: var(--ui-foreground);
}

[data-ui="shadcn"] .error-description,
[data-ui="shadcn"] .success-description {
  color: var(--ui-muted-foreground);
  font-size: 15px;
}

[data-ui="shadcn"] .error-icon-container,
[data-ui="shadcn"] .success-icon-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ui-input);
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow-sm);
}

[data-ui="shadcn"] .error-icon { color: var(--ui-destructive); font-size: 28px; }
[data-ui="shadcn"] .success-icon { color: var(--ui-accent); font-size: 28px; }

/* Buttons: reuse existing .btn semantics with shadcn look */
[data-ui="shadcn"] .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--ui-border);
  background: #ffffff;
  color: #0f172a;
  transition: transform 0.05s ease, background 0.2s ease, border-color 0.2s ease;
  will-change: transform;
}
[data-ui="shadcn"] .btn:active { transform: translateY(1px); }
[data-ui="shadcn"] .btn i { font-size: 16px; }

[data-ui="shadcn"] .btn.btn-primary {
  background: var(--ui-primary);
  color: var(--ui-primary-foreground);
  border-color: transparent;
}
[data-ui="shadcn"] .btn.btn-primary:hover {
  filter: brightness(1.05);
}

[data-ui="shadcn"] .btn.btn-secondary {
  background: #ffffff;
  color: var(--ui-foreground);
}
[data-ui="shadcn"] .btn.btn-secondary:hover {
  background: var(--ui-input);
}

[data-ui="shadcn"] .btn.btn-outline {
  background: transparent;
  color: var(--ui-foreground);
}
[data-ui="shadcn"] .btn.btn-outline:hover {
  background: var(--ui-input);
}

@media (max-width: 640px) {
  [data-ui="shadcn"] .success-actions .btn,
  [data-ui="shadcn"] .error-actions .btn {
    width: 40px;
    height: 40px;
    padding: 8px;
    font-size: 0 !important;
    text-indent: -9999px;
    overflow: hidden;
    justify-content: center;
    align-items: center;
    position: relative;
  }

  [data-ui="shadcn"] .success-actions .btn i,
  [data-ui="shadcn"] .error-actions .btn i {
    font-size: 16px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-indent: 0;
  }
}

/* Sections */
[data-ui="shadcn"] .benefit-code-section .code-display-container {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ui-input);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
  padding: 10px 12px;
}

[data-ui="shadcn"] .benefit-code-section .copy-btn {
  background: #ffffff;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 8px 10px;
}

[data-ui="shadcn"] .project-details-card,
[data-ui="shadcn"] .usage-content,
[data-ui="shadcn"] .benefits-recommendation,
[data-ui="shadcn"] .advertisement-section {
  background: #ffffff;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
  box-shadow: var(--ui-shadow);
  padding: 18px;
}

[data-ui="shadcn"] .recommended-projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* Footer */
[data-ui="shadcn"] .footer {
  color: var(--ui-muted-foreground);
}

/* Small helpers */
[data-ui="shadcn"] details > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--ui-foreground);
}
[data-ui="shadcn"] details > summary::-webkit-details-marker { display: none; }


