/**
 * =============================================================================
 * DH-KID Common Styles
 * =============================================================================
 *
 * Shared CSS patterns for both Generator and Branding modules:
 *   - CSS custom properties for theming
 *   - Loading overlay
 *   - Toast notifications
 *   - Button styles
 *   - Form controls
 *   - Typography
 *
 * =============================================================================
 */

/* =============================================================================
   CSS Custom Properties (Theming)
   ============================================================================= */
:root {
  --dh-kid-primary: #811DD1;
  --dh-kid-accent: #D11D8D;
  --dh-kid-success: #10B981;
  --dh-kid-error: #EF4444;
  --dh-kid-warning: #F59E0B;
  --dh-kid-info: #3B82F6;
  --dh-kid-text: #1F2937;
  --dh-kid-text-muted: #6B7280;
  --dh-kid-border: #E5E7EB;
  --dh-kid-bg: #FFFFFF;
  --dh-kid-bg-muted: #F9FAFB;
  --dh-kid-radius: 8px;
  --dh-kid-radius-lg: 12px;
  --dh-kid-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --dh-kid-shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
  --dh-kid-font: 'Inter', 'Montserrat', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --dh-kid-transition: 0.2s ease;
}

/* =============================================================================
   Base Typography
   ============================================================================= */
.dh-kid-wrapper {
  font-family: var(--dh-kid-font);
  color: var(--dh-kid-text);
  line-height: 1.5;
}

/* =============================================================================
   Error/Info Messages
   ============================================================================= */
.dh-kid-error {
  color: var(--dh-kid-error);
  padding: 1rem;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--dh-kid-radius);
}

.dh-kid-info {
  color: var(--dh-kid-info);
  padding: 1rem;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: var(--dh-kid-radius);
}

/* =============================================================================
   Loading Overlay
   ============================================================================= */
.dh-kid-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(3px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

.dh-kid-loading-overlay.is-visible {
  display: flex;
}

.dh-kid-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--dh-kid-border);
  border-top-color: var(--dh-kid-primary);
  border-radius: 50%;
  background: var(--dh-roundel-url) center / contain no-repeat;
  animation: dh-roundel-spin 1.2s ease-in-out infinite;
}

/* Inline loading state for containers */
.is-loading {
  position: relative;
  pointer-events: none;
}

.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(2px);
  z-index: 100;
}

.is-loading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid var(--dh-kid-border);
  border-top-color: var(--dh-kid-primary);
  border-radius: 50%;
  background: var(--dh-roundel-url) center / contain no-repeat;
  animation: dh-roundel-spin 1.2s ease-in-out infinite;
  z-index: 101;
}

/* =============================================================================
   Toast Notifications
   ============================================================================= */
.dh-kid-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #323232;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--dh-kid-radius);
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: var(--dh-kid-shadow-lg);
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  z-index: 10001;
  max-width: 360px;
  transition: opacity 0.25s, transform 0.25s;
}

.dh-kid-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dh-kid-toast.success {
  background: var(--dh-kid-success);
}

.dh-kid-toast.error {
  background: var(--dh-kid-error);
}

.dh-kid-toast.warning {
  background: var(--dh-kid-warning);
  color: #1F2937;
}

/* =============================================================================
   Button Styles
   ============================================================================= */
.dh-kid-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-family: var(--dh-kid-font);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  border: none;
  border-radius: var(--dh-kid-radius);
  cursor: pointer;
  transition: all var(--dh-kid-transition);
  text-decoration: none;
}

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

.dh-kid-btn-primary {
  background: var(--dh-kid-primary);
  color: #fff;
}

.dh-kid-btn-primary:hover:not(:disabled) {
  background: #6d16b1;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(129, 29, 209, 0.25);
}

.dh-kid-btn-secondary {
  background: var(--dh-kid-bg-muted);
  color: var(--dh-kid-text);
  border: 1px solid var(--dh-kid-border);
}

.dh-kid-btn-secondary:hover:not(:disabled) {
  background: #F3F4F6;
  border-color: #D1D5DB;
}

.dh-kid-btn-danger {
  background: #FEE2E2;
  color: var(--dh-kid-error);
  border: 1px solid #FECACA;
}

.dh-kid-btn-danger:hover:not(:disabled) {
  background: #FEF2F2;
  border-color: #FCA5A5;
}

.dh-kid-btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.dh-kid-btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* Saving state */
.dh-kid-btn.is-saving {
  cursor: wait;
  opacity: 0.75;
}

.dh-kid-btn.is-saving::after {
  content: " Saving...";
  margin-left: 0.25rem;
}

/* =============================================================================
   Form Controls
   ============================================================================= */
.dh-kid-form-group {
  margin-bottom: 1rem;
}

.dh-kid-form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  color: var(--dh-kid-text);
}

.dh-kid-input,
.dh-kid-select,
.dh-kid-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: var(--dh-kid-font);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--dh-kid-text);
  background: var(--dh-kid-bg);
  border: 1px solid var(--dh-kid-border);
  border-radius: var(--dh-kid-radius);
  transition: border-color var(--dh-kid-transition), box-shadow var(--dh-kid-transition);
}

.dh-kid-input:focus,
.dh-kid-select:focus,
.dh-kid-textarea:focus {
  outline: none;
  border-color: var(--dh-kid-primary);
  box-shadow: 0 0 0 3px rgba(129, 29, 209, 0.15);
}

.dh-kid-input::placeholder {
  color: var(--dh-kid-text-muted);
}

.dh-kid-textarea {
  min-height: 100px;
  resize: vertical;
}

.dh-kid-static-value {
  padding: 0.625rem 0.875rem;
  background: var(--dh-kid-bg-muted);
  border: 1px solid var(--dh-kid-border);
  border-radius: var(--dh-kid-radius);
  font-size: 0.9375rem;
  color: var(--dh-kid-text-muted);
}

/* =============================================================================
   Card Containers
   ============================================================================= */
.dh-kid-card {
  background: var(--dh-kid-bg);
  border: 1px solid var(--dh-kid-border);
  border-radius: var(--dh-kid-radius-lg);
  padding: 1.25rem;
  box-shadow: var(--dh-kid-shadow);
}

.dh-kid-card-header {
  margin: -1.25rem -1.25rem 1rem;
  padding: 1rem 1.25rem;
  background: var(--dh-kid-bg-muted);
  border-bottom: 1px solid var(--dh-kid-border);
  border-radius: var(--dh-kid-radius-lg) var(--dh-kid-radius-lg) 0 0;
}

.dh-kid-card-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--dh-kid-text);
}

/* =============================================================================
   Responsive
   ============================================================================= */
@media (max-width: 768px) {
  .dh-kid-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}
