/**
 * Prompt Builder Component Styles
 * "Warm Intelligence" aesthetic
 * 
 * Soft organic feel, hand-drawn accents, human warmth
 */

/* ========================================
   BASE RESET & GLOBAL STYLES
   ======================================== */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--font-regular);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

/* Display Headings - Instrument Serif */
.heading-display {
  font-family: var(--font-display);
  font-weight: var(--font-regular);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  line-height: var(--leading-tight);
}

.heading-1 {
  font-size: var(--text-5xl);
}

.heading-2 {
  font-size: var(--text-4xl);
}

.heading-3 {
  font-size: var(--text-3xl);
}

.heading-4 {
  font-size: var(--text-2xl);
}

/* Body Text - DM Sans */
.text-body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text);
}

.text-body-lg {
  font-size: var(--text-lg);
}

.text-body-sm {
  font-size: var(--text-sm);
}

.text-secondary {
  color: var(--color-text-secondary);
}

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

/* Monospace */
.text-mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ========================================
   DOODLE ELEMENTS - Hand-drawn accents
   ======================================== */

/* Squiggly underline for emphasis */
.doodle-underline {
  position: relative;
  display: inline-block;
}

.doodle-underline::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 12' preserveAspectRatio='none'%3E%3Cpath d='M0,8 Q10,2 20,8 T40,8 T60,8 T80,8 T100,8' stroke='%232D8A8A' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.doodle-underline--gold::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 12' preserveAspectRatio='none'%3E%3Cpath d='M0,8 Q10,2 20,8 T40,8 T60,8 T80,8 T100,8' stroke='%23E9B44C' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* Hand-drawn circle highlight */
.doodle-circle {
  position: relative;
}

.doodle-circle::before {
  content: '';
  position: absolute;
  inset: -8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cellipse cx='50' cy='50' rx='46' ry='44' stroke='%232D8A8A' stroke-width='2' fill='none' stroke-linecap='round' stroke-dasharray='2,4' transform='rotate(-2 50 50)'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-soft);
}

.doodle-circle:hover::before,
.doodle-circle.active::before {
  opacity: 1;
}

/* Sparkle decoration */
.doodle-sparkle {
  position: relative;
}

.doodle-sparkle::before {
  content: '';
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23E9B44C'%3E%3Cpath d='M12 0L14 8L22 10L14 12L12 20L10 12L2 10L10 8L12 0Z'/%3E%3C/svg%3E");
  background-size: contain;
  animation: sparkle-pulse 2s ease-in-out infinite;
}

@keyframes sparkle-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.1) rotate(15deg); opacity: 0.8; }
}

/* ========================================
   BUTTONS - Warm & Inviting
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  border: var(--border-width-2) solid transparent;
  
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-soft);
  
  background: none;
  outline: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow);
}

/* Primary Button */
.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-button);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: var(--shadow-button-hover);
  transform: translateY(-2px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Secondary Button */
.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-primary-light);
  box-shadow: var(--shadow-glow);
}

/* Accent Button - Gold */
.btn-accent {
  background: var(--color-accent);
  color: var(--color-text);
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.btn-accent:hover:not(:disabled) {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  box-shadow: var(--shadow-glow-accent);
  transform: translateY(-2px);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--color-primary);
  background: var(--color-primary-muted);
}

/* Button Sizes */
.btn-sm {
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
}

.btn-lg {
  font-size: var(--text-base);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-xl);
}

/* ========================================
   CARDS - Soft & Elevated
   ======================================== */

.card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  border: var(--border-width) solid var(--color-border-light);
  box-shadow: var(--shadow-card);
  transition: all var(--duration-base) var(--ease-soft);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  border-color: var(--color-border);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-4px);
}

.card-selected {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

/* Card Padding */
.card-p-sm { padding: var(--space-4); }
.card-p-md { padding: var(--space-6); }
.card-p-lg { padding: var(--space-8); }

/* ========================================
   FORM INPUTS - Clean & Friendly
   ======================================== */

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.input-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text);
}

.input-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.input-field {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  
  padding: var(--space-3) var(--space-4);
  background: var(--color-card);
  border: var(--border-width-2) solid var(--color-border);
  border-radius: var(--radius-md);
  
  width: 100%;
  transition: all var(--duration-fast) var(--ease-soft);
}

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

.input-field:hover:not(:focus):not(:disabled) {
  border-color: var(--color-text-muted);
}

.input-field:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow);
}

/* Textarea */
textarea.input-field {
  min-height: 120px;
  resize: vertical;
  line-height: var(--leading-relaxed);
}

/* Select */
select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%235D6D7E' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-position: right var(--space-3) center;
  background-repeat: no-repeat;
  background-size: 1.25rem;
  padding-right: var(--space-10);
}

/* ========================================
   MODAL
   ======================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, 0.4);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal-backdrop);
  
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  
  animation: fadeIn var(--duration-base) var(--ease-soft);
}

.modal {
  background: var(--color-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  
  display: flex;
  flex-direction: column;
  overflow: hidden;
  
  z-index: var(--z-modal);
  animation: slideUp var(--duration-slow) var(--ease-out);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  
  padding: var(--space-5) var(--space-6);
  border-bottom: var(--border-width) solid var(--color-border-light);
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--font-regular);
  color: var(--color-text);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding: var(--space-5) var(--space-6);
  border-top: var(--border-width) solid var(--color-border-light);
  background: var(--color-bg-subtle);
}

/* ========================================
   TOAST / NOTIFICATION
   ======================================== */

.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  
  display: flex;
  align-items: center;
  gap: var(--space-3);
  
  padding: var(--space-4) var(--space-5);
  background: var(--color-text);
  color: var(--color-text-inverse);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  
  z-index: var(--z-toast);
  animation: slideInRight var(--duration-slow) var(--ease-out);
}

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

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

/* ========================================
   PREVIEW PANEL
   ======================================== */

.preview-panel {
  background: var(--color-bg-subtle);
  border-radius: var(--radius-lg);
  border: var(--border-width) solid var(--color-border-light);
  padding: var(--space-5);
  
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.preview-section {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--color-card);
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
  transition: all var(--duration-base) var(--ease-soft);
}

.preview-section.highlighted {
  border-left-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.preview-tag {
  font-weight: var(--font-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.preview-content {
  color: var(--color-text-secondary);
  white-space: pre-wrap;
}

/* ========================================
   LOADING & ANIMATIONS
   ======================================== */

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

/* Staggered animations */
.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }

/* ========================================
   UTILITY CLASSES
   ======================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .modal {
    max-height: 95vh;
    border-radius: var(--radius-lg);
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
}
