/**
 * WD Quick Pages - Shadcn/UI Inspired Styles
 * Clean, modern design system for WordPress admin
 */

/* CSS Custom Properties - Shadcn/UI Color Palette */
:root {
  --wd-background: hsl(0 0% 100%);
  --wd-foreground: hsl(222.2 84% 4.9%);
  --wd-card: hsl(0 0% 100%);
  --wd-card-foreground: hsl(222.2 84% 4.9%);
  --wd-popover: hsl(0 0% 100%);
  --wd-popover-foreground: hsl(222.2 84% 4.9%);
  --wd-primary: hsl(222.2 47.4% 11.2%);
  --wd-primary-foreground: hsl(210 40% 98%);
  --wd-secondary: hsl(210 40% 96%);
  --wd-secondary-foreground: hsl(222.2 84% 4.9%);
  --wd-muted: hsl(210 40% 96%);
  --wd-muted-foreground: hsl(215.4 16.3% 46.9%);
  --wd-accent: hsl(210 40% 96%);
  --wd-accent-foreground: hsl(222.2 84% 4.9%);
  --wd-destructive: hsl(0 84.2% 60.2%);
  --wd-destructive-foreground: hsl(210 40% 98%);
  --wd-border: hsl(214.3 31.8% 91.4%);
  --wd-input: hsl(214.3 31.8% 91.4%);
  --wd-ring: hsl(215 20.2% 65.1%);
  --wd-success: hsl(142 71% 45%);
  --wd-warning: hsl(38 92% 50%);
  --wd-radius: 0.5rem;
}

/* Global Reset & Base Styles */
.wd-quick-pages-wrapper {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  color: var(--wd-foreground);
  margin: 0;
  padding: 0;
}

.wd-quick-pages-wrapper * {
  box-sizing: border-box;
}

/* Container & Layout */
.wd-quick-pages-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 2rem 2rem 1rem;
}

/* Header Styles */
.wd-header {
  margin-bottom: 2rem;
}

.wd-header-content {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.wd-title {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--wd-foreground);
  margin: 0 0 0.5rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
}

.wd-description {
  font-size: 1.125rem;
  color: var(--wd-muted-foreground);
  margin: 0;
}

/* Main Content Layout */
.wd-main-content {
  display: grid;
  gap: 1.5rem;
}

/* Card Components */
.wd-card {
  background: var(--wd-card);
  border: 1px solid var(--wd-border);
  border-radius: var(--wd-radius);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  overflow: hidden;
}

.wd-card-header {
  padding: 1.5rem 1.5rem 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.wd-card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--wd-card-foreground);
  margin: 0;
  flex: 1;
}

.wd-card-description {
  font-size: 0.875rem;
  color: var(--wd-muted-foreground);
  margin: 0.25rem 0 0 0;
}

.wd-card-content {
  padding: 1.5rem;
}

/* Form Styles */
.wd-form-group {
  margin-bottom: 1.5rem;
}

.wd-form-group:last-child {
  margin-bottom: 0;
}

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

.wd-label-required {
  color: var(--wd-destructive);
}

/* Textarea with Line Numbers */
.wd-textarea-wrapper {
  position: relative;
  border: 1px solid var(--wd-border);
  border-radius: var(--wd-radius);
  background: var(--wd-background);
  overflow: hidden;
  display: flex;
}

.wd-line-numbers {
  background: var(--wd-muted);
  color: var(--wd-muted-foreground);
  padding: 0.75rem 0.5rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  min-width: 3rem;
  text-align: right;
  user-select: none;
  border-right: 1px solid var(--wd-border);
  white-space: pre-line;
}

.wd-textarea {
  flex: 1;
  border: none;
  outline: none;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  background: transparent;
  color: var(--wd-foreground);
  resize: vertical;
  min-height: 300px;
}

.wd-textarea::placeholder {
  color: var(--wd-muted-foreground);
}

.wd-textarea:focus {
  outline: none;
}

.wd-textarea-wrapper:focus-within {
  ring: 2px;
  ring-color: var(--wd-ring);
  ring-offset: 2px;
  border-color: var(--wd-primary);
}

/* Input & Select Styles */
.wd-select,
.wd-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--wd-border);
  border-radius: var(--wd-radius);
  background: var(--wd-background);
  color: var(--wd-foreground);
  font-size: 0.875rem;
  transition: all 0.2s ease-in-out;
}

.wd-select:focus,
.wd-input:focus {
  outline: none;
  border-color: var(--wd-primary);
  ring: 2px;
  ring-color: var(--wd-ring);
  ring-offset: 2px;
}

/* Settings Row Layout */
.wd-settings-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Button Styles */
.wd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: var(--wd-radius);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  text-decoration: none;
  min-height: 2.5rem;
}

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

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

.wd-btn-primary:hover:not(:disabled) {
  background: hsl(222.2 47.4% 8%);
}

.wd-btn-outline {
  background: transparent;
  border-color: var(--wd-border);
  color: var(--wd-foreground);
}

.wd-btn-outline:hover:not(:disabled) {
  background: var(--wd-accent);
  color: var(--wd-accent-foreground);
}

.wd-btn-ghost {
  background: transparent;
  color: var(--wd-foreground);
}

.wd-btn-ghost:hover:not(:disabled) {
  background: var(--wd-accent);
  color: var(--wd-accent-foreground);
}

.wd-btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  min-height: 2rem;
}

.wd-btn-icon {
  font-size: 1rem;
}

/* Form Actions */
.wd-form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

/* Help Text */
.wd-help-text {
  font-size: 0.8125rem;
  color: var(--wd-muted-foreground);
  margin: 0.5rem 0 0 0;
}

/* Preview Styles */
.wd-preview-tree {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", monospace;
  font-size: 0.875rem;
}

.wd-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--wd-border);
}

.wd-preview-item:last-child {
  border-bottom: none;
}

.wd-preview-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.wd-preview-title {
  font-weight: 500;
  color: var(--wd-foreground);
}

.wd-preview-line {
  font-size: 0.75rem;
  color: var(--wd-muted-foreground);
}

.wd-preview-status {
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.wd-status-new {
  background: hsl(142 71% 45% / 0.1);
  color: var(--wd-success);
}

.wd-status-exists {
  background: hsl(38 92% 50% / 0.1);
  color: var(--wd-warning);
}

/* Depth Indentation */
.wd-depth-1 .wd-preview-title {
  padding-left: 1.5rem;
}
.wd-depth-2 .wd-preview-title {
  padding-left: 3rem;
}
.wd-depth-3 .wd-preview-title {
  padding-left: 4.5rem;
}
.wd-depth-4 .wd-preview-title {
  padding-left: 6rem;
}
.wd-depth-5 .wd-preview-title {
  padding-left: 7.5rem;
}

/* Progress Bar */
.wd-progress-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  max-width: 90vw;
  background: var(--wd-card);
  border: 1px solid var(--wd-border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  z-index: 999999;
}

.wd-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--wd-muted);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.wd-progress-fill {
  height: 100%;
  background: var(--wd-primary);
  border-radius: 6px;
  transition: width 0.3s ease-in-out;
  width: 0%;
}

.wd-progress-text {
  text-align: center;
  font-size: 1rem;
  color: var(--wd-foreground);
  font-weight: 500;
}

/* Results Styles */
.wd-results-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.wd-results-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--wd-border);
}

.wd-results-item:last-child {
  border-bottom: none;
}

.wd-results-content {
  flex: 1;
}

.wd-results-title {
  font-weight: 500;
  color: var(--wd-foreground);
  margin: 0 0 0.25rem 0;
}

.wd-results-meta {
  font-size: 0.75rem;
  color: var(--wd-muted-foreground);
}

.wd-results-status {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.wd-status-created {
  background: hsl(142 71% 45% / 0.1);
  color: var(--wd-success);
}

.wd-status-skipped {
  background: hsl(38 92% 50% / 0.1);
  color: var(--wd-warning);
}

.wd-status-error {
  background: hsl(0 84.2% 60.2% / 0.1);
  color: var(--wd-destructive);
}

/* Footer */
.wd-footer {
  /* margin-top: 3rem; */
  padding-top: 2rem;
  border-top: 1px solid var(--wd-border);
  text-align: center;
}

.wd-footer-text {
  font-size: 0.875rem;
  color: var(--wd-muted-foreground);
  margin: 0;
}

.wd-footer-link {
  color: var(--wd-primary);
  text-decoration: none;
  font-weight: 500;
}

.wd-footer-link:hover {
  text-decoration: underline;
}

/* Preview Errors */
.wd-preview-errors {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: hsl(0, 93%, 94%);
  border: 1px solid hsl(0, 93%, 80%);
  border-radius: var(--wd-radius);
}

.wd-preview-error {
  color: hsl(0, 84%, 40%);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 0.25rem;
}

.wd-preview-error:last-child {
  margin-bottom: 0;
}

/* Toast Notifications */
.wd-toast {
  position: fixed;
  top: 50px;
  right: 1rem;
  background: var(--wd-card);
  border-radius: var(--wd-radius);
  padding: 1rem;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  z-index: 999999;
  min-width: 300px;
  max-width: 400px;
  animation: wd-slide-in 0.3s ease-out;
}

.wd-toast-title {
  font-weight: 600;
  color: var(--wd-foreground);
  margin: 0 0 0.25rem 0;
}

.wd-toast-message {
  font-size: 0.875rem;
  color: var(--wd-muted-foreground);
  margin: 0;
}

@keyframes wd-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

  .wd-title {
    font-size: 1.875rem;
    flex-direction: column;
    gap: 0.5rem;
  }

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

  .wd-settings-row {
    grid-template-columns: 1fr;
  }

  .wd-form-actions {
    flex-direction: column;
  }

  .wd-btn {
    width: 100%;
  }

  .wd-toast {
    left: 1rem;
    right: 1rem;
    min-width: auto;
  }
}

/* WordPress Admin Compatibility - Not needed for centered modal */

/* Dark Mode Support (Future Enhancement) */
@media (prefers-color-scheme: dark) {
  :root {
    --wd-background: hsl(222.2 84% 4.9%);
    --wd-foreground: hsl(210 40% 98%);
    --wd-card: hsl(222.2 84% 4.9%);
    --wd-card-foreground: hsl(210 40% 98%);
    --wd-popover: hsl(222.2 84% 4.9%);
    --wd-popover-foreground: hsl(210 40% 98%);
    --wd-primary: hsl(210 40% 98%);
    --wd-primary-foreground: hsl(222.2 47.4% 11.2%);
    --wd-secondary: hsl(217.2 32.6% 17.5%);
    --wd-secondary-foreground: hsl(210 40% 98%);
    --wd-muted: hsl(217.2 32.6% 17.5%);
    --wd-muted-foreground: hsl(215 20.2% 65.1%);
    --wd-accent: hsl(217.2 32.6% 17.5%);
    --wd-accent-foreground: hsl(210 40% 98%);
    --wd-border: hsl(217.2 32.6% 17.5%);
    --wd-input: hsl(217.2 32.6% 17.5%);
  }
}
