/* Import Space Grotesk font */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;700&display=swap');

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Anthropic Claude Official Brand Colors */
  --antique-brass: #CC785C;      /* Primary accent - warm terra-cotta */
  --claude-logo: #D97757;         /* Claude logo color */
  --friar-gray: #828179;          /* Mid gray */
  --cararra: #F0EFEA;             /* Off-white background */
  --cod-gray: #141413;            /* Dark text color */
  
  /* Theme Variables */
  --primary: #CC785C;             /* Antique Brass for primary actions */
  --primary-hover: #B86A50;       /* Darker shade of Antique Brass */
  --danger: #D97757;              /* Claude Logo color for warnings/danger */
  --danger-hover: #C86747;        /* Darker shade */
  --secondary: #828179;           /* Friar Gray */
  --secondary-hover: #6F6E66;     /* Darker Friar Gray */
  --success: #CC785C;             /* Antique Brass for success states */
  --error: #D97757;               /* Claude Logo color for errors */
  --border: #E0DED6;              /* Slightly darker than Cararra */
  --bg-gray: #F0EFEA;             /* Cararra */
  --text: #000000;                /* Black text per Anthropic style */
  --text-light: #828179;          /* Friar Gray */
  --shadow: rgba(0, 0, 0, 0.1);
}

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

/* Header */
header {
  background: transparent;
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--primary);
  padding: 2rem 2rem 0.5rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: float 4s ease-in-out infinite;
}

.header-content {
  position: relative;
  z-index: 1;
}

.title-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.sparkle-icon {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--primary);
  filter: drop-shadow(0 0 8px rgba(204,120,92,0.3));
  animation: sparkle-pulse 32 ease-in-out infinite;
}

.mobile-break {
  display: none;
}

header h1 {
  font-size: 3.25rem;
  margin-bottom: 0;
}

.gradient-title {
  color: var(--primary);
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(204, 120, 92, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1);
}

header .subtitle {
  font-size: 1.25rem;
  opacity: 0.85;
  color: var(--primary);
  font-weight: 400;
  max-width: 800px;
  margin: 0 auto;
  text-shadow: 0 1px 3px rgba(204, 120, 92, 0.15), 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Animations */
@keyframes float {
  0%, 100% { 
    transform: translateY(0); 
  }
  50% { 
    transform: translateY(-10px); 
  }
}

@keyframes sparkle-pulse {
  /* Pause at 0 degrees */
  0%, 6.25% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  /* Rotate to 90 degrees */
  18.75% {
    transform: scale(1.1) rotate(90deg);
    opacity: 0.8;
  }
  /* Rotate to 180 degrees */
  31.25% {
    transform: scale(1) rotate(180deg);
    opacity: 1;
  }
  /* Pause at 180 degrees */
  37.5% {
    transform: scale(1) rotate(180deg);
    opacity: 1;
  }
  /* Rotate to 270 degrees */
  50% {
    transform: scale(1.1) rotate(270deg);
    opacity: 0.8;
  }
  /* Rotate back to 360/0 degrees */
  62.5% {
    transform: scale(1) rotate(360deg);
    opacity: 1;
  }
  /* Pause at 360 degrees before loop */
  68.75%, 100% {
    transform: scale(1) rotate(360deg);
    opacity: 1;
  }
}

.animate-float {
  display: inline-block;
  animation: float 3s ease-in-out infinite;
}

/* Responsive header */
@media (max-width: 900px) {
  header {
    padding: 1.5rem 1rem 0.75rem 1rem;
  }
  
  header h1 {
    font-size: 2.2rem;
  }
  
  header .subtitle {
    font-size: 1.1rem;
  }
}

@media (max-width: 640px) {
  header {
    padding: 1rem 1rem;
    margin-top: 2rem;
  }
  
  .title-container {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .sparkle-icon {
    width: 1.75rem;
    height: 1.75rem;
  }
  
  header h1 {
    font-size: 1.5rem;
    line-height: 1.2;
  }
  
  header .subtitle {
    font-size: 0.875rem;
    line-height: 1.4;
  }
  
  .mobile-break {
    display: inline;
  }
}

/* Main container */
main {
  flex: 1;
  padding: 2rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 1200px) {
  main {
    padding: 1.5rem;
  }
  
  .container {
    gap: 1.5rem;
  }
}

@media (max-width: 1024px) {
  .container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  main {
    padding: 1rem;
  }
  
  .container {
    gap: 1rem;
  }
}

/* Panels */
.editor-panel,
.preview-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.06);
}

.panel-header {
  background: white;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.panel-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--cod-gray);
}

@media (max-width: 640px) {
  .panel-header {
    padding: 0.875rem 1rem;
  }
  
  .panel-header h2 {
    font-size: 1.1rem;
  }
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 640px) {
  .action-buttons {
    justify-content: flex-end;
  }
}

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

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

/* Format Selector */
.format-selector {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  transition: all 0.2s;
  margin-right: 0.5rem;
}

.format-selector:hover {
  background: var(--bg-gray);
  border-color: var(--primary);
}

.format-selector:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

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

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

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

.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

/* Icon buttons */
.btn-icon {
  padding: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn .icon,
.btn svg {
  width: 18px;
  height: 18px;
  display: inline-block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Screen-reader only text */
.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;
}

/* Functions list */
.functions-list {
  padding: 1.5rem;
  min-height: 62vh;
  max-height: 62vh;
  overflow-y: auto;
  background: #F8F7F4;
}

@media (max-width: 640px) {
  .functions-list {
    padding: 1rem;
    min-height: 48vh;
    max-height: 48vh;
  }
}

.empty-state {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-light);
}

/* Function card */
.function-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: #FAFAF8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

@media (max-width: 640px) {
  .function-card {
    padding: 1rem;
    margin-bottom: 1rem;
  }
}

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

.function-name {
  flex: 1;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1.1rem;
  font-family: inherit;
  background: white;
}

.function-actions {
  display: flex;
  gap: 0.5rem;
}

.function-description {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 1rem;
  font-family: inherit;
  resize: vertical;
  background: white;
}

/* Parameters */
.params-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0 0.75rem;
}

.params-header h4 {
  font-size: 1rem;
  font-weight: 600;
}

.params-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.empty-message {
  color: var(--text-light);
  font-size: 0.9rem;
  font-style: italic;
}

.param-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.param-row .param-key {
  flex: 1 1 180px;
  min-width: 120px;
}

.param-row .param-type {
  flex: 0 1 140px;
  min-width: 100px;
}

.param-row .param-description {
  flex: 2 1 220px;
  min-width: 180px;
}

.param-row .checkbox-label {
  flex: 0 0 auto;
  white-space: nowrap;
}

.param-row .btn-icon {
  flex: 0 0 auto;
}

/* Responsive parameter rows */
@media (max-width: 1100px) {
  .param-row {
    gap: 0.4rem;
  }
  
  .param-row .param-key {
    flex: 1 1 140px;
    min-width: 100px;
  }
  
  .param-row .param-type {
    flex: 0 1 120px;
    min-width: 90px;
  }
  
  .param-row .param-description {
    flex: 1 1 160px;
    min-width: 140px;
  }
  
  .param-key,
  .param-type,
  .param-description {
    font-size: 0.85rem;
    padding: 0.45rem;
  }
  
  .checkbox-label {
    font-size: 0.8rem;
  }
}

@media (max-width: 800px) {
  .param-row {
    gap: 0.5rem;
  }
  
  .param-row .param-key {
    flex: 1 1 100%;
    order: 1;
  }
  
  .param-row .param-type {
    flex: 1 1 auto;
    min-width: 100px;
    order: 2;
  }
  
  .param-row .param-description {
    flex: 2 1 200px;
    min-width: 150px;
    order: 3;
  }
  
  .param-row .checkbox-label {
    order: 4;
  }
  
  .param-row .btn-icon:nth-of-type(1) {
    order: 5;
  }
  
  .param-row .btn-icon:nth-of-type(2) {
    order: 6;
  }
}

@media (max-width: 640px) {
  .param-row {
    gap: 0.5rem;
  }
  
  .param-row .param-key,
  .param-row .param-type,
  .param-row .param-description {
    flex: 1 1 100%;
    min-width: 100%;
  }
  
  .param-row .checkbox-label {
    flex: 0 1 auto;
    margin-right: auto;
  }
}

@media (max-width: 900px) {
  .function-header {
    gap: 0.75rem;
  }
  
  .function-name {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .function-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .function-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }
}

.param-key,
.param-type,
.param-description {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9rem;
}

.param-key {
  font-family: 'Courier New', monospace;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Preview panel */
.preview-panel {
  position: sticky;
  top: 2rem;
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
}

@media (max-width: 1024px) {
  .preview-panel {
    position: static;
    min-height: 55vh;
    max-height: 55vh;
  }
  
  .schema-output {
    min-height: 45vh;
  }
}

@media (max-width: 640px) {
  .preview-panel {
    min-height: 48vh;
    max-height: 48vh;
  }
  
  .schema-output {
    min-height: 38vh;
  }
}

.validation-status {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: none; /* Hidden by default, shown via JS when there are errors */
}

.validation-status:not(:empty) {
  display: block;
}

.status-success {
  color: var(--success);
  font-weight: 600;
}

.status-error {
  background: linear-gradient(135deg, #FFF5F0 0%, #FFEBE5 100%);
  border-radius: 8px;
  padding: 1.25rem;
  margin: -1rem -1.5rem 0;
  box-shadow: 0 4px 12px rgba(217, 119, 87, 0.2);
}

.status-error strong {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--error);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.status-error strong::before {
  content: "⚠";
  font-size: 1.5rem;
  line-height: 1;
}

.status-error ul {
  margin: 0 0 0 2rem;
  color: #8B3A2A;
}

.status-error li {
  margin: 0.5rem 0;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
}

.schema-output {
  flex: 1;
  min-height: 52vh;
  overflow: auto;
  padding: 1.5rem;
  background: #F8F7F4;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
  border-top: 1px solid var(--border);
}

.schema-output code {
  display: block;
  white-space: pre;
}

.schema-output .error {
  color: var(--error);
}

/* Invalid field highlighting */
.function-name.invalid,
.function-description.invalid,
.param-key.invalid,
.param-description.invalid {
  border: 2px solid var(--error) !important;
  background-color: rgba(217, 119, 87, 0.1) !important;
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 8px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px var(--shadow);
}

.modal-small {
  max-width: 450px;
}

@media (max-width: 640px) {
  .modal {
    padding: 1rem;
  }
  
  .modal-content {
    max-height: 90vh;
  }
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.75rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
  padding: 0;
  width: 2rem;
  height: 2rem;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-body p {
  margin: 0;
  line-height: 1.6;
  color: var(--text);
}

.modal-body label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.modal-body textarea,
.modal-body input[type="text"],
.modal-body input[type="number"] {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
}

.modal-body textarea {
  font-family: 'Courier New', monospace;
  resize: vertical;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Form groups */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9rem;
}

.note {
  background: var(--bg-gray);
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

/* Nested properties */
.nested-props {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.nested-prop-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
}

@media (max-width: 900px) {
  .nested-prop-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  
  .nested-prop-row input[type="text"] {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .nested-prop-row {
    grid-template-columns: 1fr;
  }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  background: var(--text);
  color: white;
  border-radius: 4px;
  box-shadow: 0 4px 12px var(--shadow);
  opacity: 0;
  transform: translateY(1rem);
  transition: all 0.3s;
  pointer-events: none;
  z-index: 2000;
  max-width: calc(100vw - 4rem);
  word-wrap: break-word;
}

@media (max-width: 640px) {
  .toast {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: none;
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
  }
  
  .toast-error {
    font-size: 1rem;
    padding: 1.125rem 1.25rem;
  }
}

.toast-show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

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

.toast-error {
  background: var(--error);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 1.25rem 1.75rem;
  box-shadow: 0 6px 20px rgba(217, 119, 87, 0.4);
}

/* Focus styles for accessibility */
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Share URL input */
#share-url {
  margin-bottom: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
}

/* Footer */
.site-footer {
  background: transparent;
  text-align: center;
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text);
}

.site-footer a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
  font-weight: 500;
}

.site-footer a:hover {
  color: var(--primary-hover);
}

.site-footer a:focus {
  outline: none;
}

.footer-separator {
  margin: 0 0.75rem;
  color: var(--text-light);
  font-weight: 400;
}

.github-link {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.github-link i {
  width: 18px;
  height: 18px;
}

