/* Modern CSS Reset */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Theme Variables */
.light-theme {
  --bg-color: #f7f9fc;
  --text-color: #333;
  --title-color: #2c3e50;
  --input-bg: #fff;
  --input-border: #e1e4e8;
  --input-focus-border: #4a89dc;
  --button-bg: linear-gradient(135deg, #4a89dc 0%, #5e72e4 100%);
  --button-hover-bg: linear-gradient(135deg, #5e72e4 0%, #4a89dc 100%);
  --button-text: #fff;
  --output-bg: #1e293b;
  --output-text: #e2e8f0;
  --copy-button-bg: #2d3748;
  --copy-button-color: #a0aec0;
  --copy-button-hover-bg: #4a5568;
  --copy-button-hover-color: #e2e8f0;
  --copy-button-copied-bg: #2c7a7b;
  --footer-text: #718096;
  --footer-border: #e2e8f0;
  --link-color: #3498db;
  --link-hover: #2980b9;
  --json-string: #a5d6ff;
  --json-number: #f97583;
  --json-boolean: #ffab70;
  --json-null: #cdcdcd;
  --json-key: #7ee787;
  --empty-message: #94a3b8;
  --error-message: #f56565;
  --toggle-button-bg: #f0f4f8;
  --toggle-button-color: #4a5568;
}

.dark-theme {
  --bg-color: #1a202c;
  --text-color: #e2e8f0;
  --title-color: #90cdf4;
  --input-bg: #2d3748;
  --input-border: #4a5568;
  --input-focus-border: #63b3ed;
  --button-bg: linear-gradient(135deg, #3182ce 0%, #4c51bf 100%);
  --button-hover-bg: linear-gradient(135deg, #4c51bf 0%, #3182ce 100%);
  --button-text: #fff;
  --output-bg: #2d3748;
  --output-text: #e2e8f0;
  --copy-button-bg: #1a202c;
  --copy-button-color: #a0aec0;
  --copy-button-hover-bg: #2d3748;
  --copy-button-hover-color: #e2e8f0;
  --copy-button-copied-bg: #2c7a7b;
  --footer-text: #a0aec0;
  --footer-border: #4a5568;
  --link-color: #63b3ed;
  --link-hover: #90cdf4;
  --json-string: #9cdbff;
  --json-number: #ff8a85;
  --json-boolean: #ffc078;
  --json-null: #a0aec0;
  --json-key: #9ae6a0;
  --empty-message: #718096;
  --error-message: #fc8181;
  --toggle-button-bg: #2d3748;
  --toggle-button-color: #a0aec0;
}

/* Global Styles */
body {
  font-family: 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  margin: 0;
  padding: 2rem;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Title styling */
body::before {
  content: "JSON Formatter";
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--title-color);
  margin-bottom: 1.5rem;
  text-align: center;
  transition: color 0.3s ease;
}

/* Theme Toggle Container */
.theme-toggle-container {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 100;
}

/* Theme Toggle Button */
#theme-toggle {
  background-color: var(--toggle-button-bg);
  color: var(--toggle-button-color);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

#theme-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#theme-toggle:active {
  transform: translateY(1px);
}

/* Textarea Styling */
textarea {
  width: 100%;
  max-width: 900px;
  padding: 1rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background-color: var(--input-bg);
  color: var(--text-color);
  font-family: 'Consolas', 'Monaco', 'Andale Mono', monospace;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s, color 0.3s;
  resize: vertical;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

textarea:focus {
  outline: none;
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px rgba(74, 137, 220, 0.25);
}

/* Input Textarea Specific Styling */
#jsoninput {
  border-left: 4px solid var(--input-focus-border);
  position: relative;
}

#jsoninput::after {
  content: "Input JSON";
  position: absolute;
  top: -25px;
  left: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--input-focus-border);
  transition: color 0.3s;
}

/* Output Container Styling */
.output-container {
  width: 100%;
  max-width: 900px;
  position: relative;
}

/* Output JSON Container Styling */
#jsonoutput {
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--input-border);
  border-left: 4px solid #2ecc71;
  border-radius: 6px;
  background-color: var(--output-bg);
  font-family: 'Consolas', 'Monaco', 'Andale Mono', monospace;
  font-size: 0.95rem;
  overflow-x: auto;
  position: relative;
  color: var(--output-text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  margin: 0;
  line-height: 1.5;
  min-height: 150px;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.output-container::before {
  content: "Formatted JSON";
  position: absolute;
  top: -25px;
  left: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #2ecc71;
  transition: color 0.3s;
}

/* Copy button styling */
#copy-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: var(--copy-button-bg);
  color: var(--copy-button-color);
  border: none;
  border-radius: 50px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
}

#copy-button i {
  font-size: 0.9rem;
  transition: transform 0.2s ease;
}

#copy-button:hover {
  background-color: var(--copy-button-hover-bg);
  color: var(--copy-button-hover-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

#copy-button:hover i {
  transform: scale(1.1);
}

#copy-button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#copy-button.copied {
  background-color: var(--copy-button-copied-bg);
  color: #e6fffa;
  animation: pulse 1.5s ease-in-out;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(44, 122, 123, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(44, 122, 123, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(44, 122, 123, 0);
  }
}

/* Button Styling */
#button {
  padding: 0.75rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  background-color: #4a89dc;
  background-image: var(--button-bg);
  color: var(--button-text);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 15px rgba(74, 137, 220, 0.3);
  position: relative;
  overflow: hidden;
}

#button::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, transparent 0%, rgba(255, 255, 255, 0.15) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

#button:hover {
  background-image: var(--button-hover-bg);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(74, 137, 220, 0.5);
}

#button:hover::before {
  transform: translateX(100%);
}

#button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 10px rgba(74, 137, 220, 0.4);
}

/* Syntax Highlighting Styles */
#jsonoutput .string {
  color: var(--json-string);
}

#jsonoutput .number {
  color: var(--json-number);
}

#jsonoutput .boolean {
  color: var(--json-boolean);
}

#jsonoutput .null {
  color: var(--json-null);
}

#jsonoutput .key {
  color: var(--json-key);
  font-weight: 600;
}

/* Status messages */
#jsonoutput .empty-message {
  color: var(--empty-message);
  font-style: italic;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 150px;
  transition: color 0.3s;
}

#jsonoutput .error-message {
  color: var(--error-message);
  font-weight: bold;
  transition: color 0.3s;
}

/* Add some spacing between JSON elements for better readability */
#jsonoutput span {
  line-height: 1.5;
  transition: color 0.3s;
}

/* Button group styling */
.button-group {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 900px;
}

/* Attribution footer styling */
.attribution {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--footer-text);
  width: 100%;
  max-width: 900px;
  padding: 1rem;
  border-top: 1px solid var(--footer-border);
  transition: color 0.3s, border-color 0.3s;
}

.attribution a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.2s;
}

.attribution a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  body::before {
    font-size: 1.8rem;
    margin-bottom: 1rem;
  }

  textarea, #jsonoutput {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  #button {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }

  #copy-button {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
  }
}