/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Color Palette */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --danger-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);

  --bg-primary: #0a0e27;
  --bg-secondary: #1a1f3a;
  --bg-tertiary: #2a2f4a;
  --bg-glass: rgba(255, 255, 255, 0.1);
  --bg-glass-hover: rgba(255, 255, 255, 0.15);

  --text-primary: #ffffff;
  --text-secondary: #b8c4e0;
  --text-muted: #8892b0;

  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(102, 126, 234, 0.5);

  --shadow-glass: 0 8px 32px rgba(31, 38, 135, 0.37);
  --shadow-elevated: 0 20px 40px rgba(0, 0, 0, 0.3);

  /* Fonts */
  --font-primary: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Fira Code", "Monaco", "Cascadia Code", monospace;

  /* Transitions */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  position: relative;
}

/* Animated Background */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
      circle at 20% 80%,
      rgba(120, 119, 198, 0.3) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(255, 119, 198, 0.3) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 40% 40%,
      rgba(120, 219, 255, 0.2) 0%,
      transparent 50%
    );
  z-index: -1;
  animation: backgroundMove 20s ease-in-out infinite;
}

@keyframes backgroundMove {
  0%,
  100% {
    transform: scale(1) rotate(0deg);
  }
  50% {
    transform: scale(1.1) rotate(1deg);
  }
}

.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Header Styles */
.header {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-img {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(102, 126, 234, 0.3));
}

.logo i {
  font-size: 2rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.button-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.language-selector {
  position: relative;
  display: flex;
  align-items: center;
}

.language-selector select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.75rem 3rem 0.75rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 500;
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  min-width: 120px;
}

.language-selector select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.language-selector select:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--border-focus);
}

.language-selector select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.language-selector i {
  position: absolute;
  right: 1rem;
  pointer-events: none;
  color: var(--text-secondary);
}

.run-btn,
.clear-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.run-btn {
  background: var(--success-gradient);
  color: white;
  box-shadow: var(--shadow-glass);
}

.run-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-elevated);
}

.clear-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.clear-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* Main Content */
.main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
}

/* Panel Styles */
.editor-panel,
.output-panel {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-glass);
}

.panel-header {
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

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

.editor-actions,
.output-actions {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* Editor Container */
.editor-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  border-radius: 0 0 16px 16px;
}

.monaco-editor-container {
  flex: 1;
  height: 100%;
  position: relative;
}

/* Monaco Editor Custom Styling */
.monaco-editor {
  background: transparent !important;
}

.monaco-editor .margin {
  background: rgba(255, 255, 255, 0.02) !important;
  border-right: 1px solid var(--border-color) !important;
}

.monaco-editor .monaco-editor-background {
  background: transparent !important;
}

.monaco-editor .current-line {
  background: rgba(255, 255, 255, 0.05) !important;
  border: none !important;
}

.monaco-editor .line-numbers {
  color: var(--text-muted) !important;
}

.monaco-editor .cursor {
  background: var(--text-primary) !important;
}

.monaco-editor .selected-text {
  background: rgba(102, 126, 234, 0.3) !important;
}

.monaco-editor .monaco-scrollable-element .scrollbar {
  background: rgba(255, 255, 255, 0.05) !important;
}

.monaco-editor .monaco-scrollable-element .slider {
  background: rgba(255, 255, 255, 0.2) !important;
  border-radius: 4px !important;
}

.monaco-editor .monaco-scrollable-element .slider:hover {
  background: rgba(255, 255, 255, 0.3) !important;
}

/* Output Container */
.output-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.output-content {
  height: 100%;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.welcome-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-muted);
}

.welcome-message i {
  font-size: 3rem;
  margin-bottom: 1rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-message p:first-of-type {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.html-preview {
  height: 100%;
  width: 100%;
}

.html-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
  border-radius: 8px;
}

/* Input Container Styles */
.input-container {
  background: rgba(255, 255, 255, 0.05);
  border-top: 1px solid var(--border-color);
  padding: 1rem;
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1002;
  display: flex;
  flex-direction: column;
}

.input-prompt {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  font-family: var(--font-mono);
}

.input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.user-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.user-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
  background: rgba(255, 255, 255, 0.15);
}

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

.send-input-btn {
  background: var(--success-gradient);
  border: none;
  border-radius: 8px;
  padding: 0.75rem;
  color: white;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
}

.send-input-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 172, 254, 0.3);
}

.send-input-btn:active {
  transform: translateY(0);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 39, 0.8);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-spinner p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 500;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 5rem;
  right: 15rem;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  align-items: right;
  gap: 0.5rem;
  max-width: 350px;
  width: auto;
}

.toast {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: var(--shadow-glass);
  transform: translateX(100%);
  transition: var(--transition);
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 200px;
  display: flex;
  justify-content: space-between;
  flex-direction: row;
}

.toast button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color var(--transition);
}

.toast.show {
  transform: translateX(0);
}

.toast.success {
  border-left: 4px solid #4facfe;
}

.toast.error {
  border-left: 4px solid #fa709a;
}

.toast.info {
  border-left: 4px solid #667eea;
}

/* Responsive Toast Notifications */
@media (max-width: 768px) {
  .toast-container {
    top: 4rem;
    right: 12rem;
    max-width: none;
  }

  .toast {
    min-width: auto;
    width: 100%;
  }
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  transition: var(--transition);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 1rem;
  }

  .header-content {
    padding: 0 1rem;
  }

  .main-content {
    padding: 1rem;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 1rem;
  }

  .header-controls {
    gap: 0.5rem;  }
  .run-btn span,
  .clear-btn span {
    display: none;
  }

  .logo span {
    display: none;
  }

  .panel-title span {
    display: none;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 0.75rem;
  }

  .header-content {
    padding: 0;
    gap: 0.5rem;
  }

  .header-controls {
    gap: 0.25rem;
    flex-wrap: wrap;
  }

  .run-btn span,
  .clear-btn span {
    display: block;
  }

  .language-selector select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.8rem;
    min-width: 80px;
  }

  .run-btn,
  .clear-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    min-width: auto;
  }

  .run-btn i,
  .clear-btn i {
    font-size: 0.9rem;
  }
  .logo {
    font-size: 1.2rem;
    gap: 0.5rem;
  }

  .logo i,
  .logo-img {
    font-size: 1.5rem;
    width: 1.5rem;
    height: 1.5rem;
  }
}

@media (max-width: 425px) {
  .header {
    padding: 0.5rem;
  }

  .header-content {
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    width: 100%;
    min-width: 0;
  }

  .logo {
    font-size: 1.1rem;
    gap: 0.5rem;
    text-align: center;
  }
  .logo i,
  .logo-img {
    font-size: 1.4rem;
    width: 1.4rem;
    height: 1.4rem;
  }

  .header-controls {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    width: 100%;
    max-width: 280px;
  }

  .language-selector {
    width: 100%;
  }

  .language-selector select {
    width: 100%;
    text-align: center;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.8rem;
    min-width: auto;
  }

  .button-group {
    display: flex;
    gap: 0.5rem;
    width: 100%;
  }

  .run-btn,
  .clear-btn {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
}

/* Extra small screens */
@media (max-width: 375px) {
  .header {
    padding: 0.4rem;
  }

  .header-content {
    gap: 0.5rem;
  }

  .logo {
    font-size: 1rem;
    gap: 0.4rem;
  }
  .logo i,
  .logo-img {
    font-size: 1.3rem;
    width: 1.3rem;
    height: 1.3rem;
  }

  .header-controls {
    max-width: 260px;
    gap: 0.4rem;
  }

  .language-selector select {
    padding: 0.4rem 1.8rem 0.4rem 0.6rem;
    font-size: 0.75rem;
  }

  .run-btn,
  .clear-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
  }
  .run-btn i,
  .clear-btn i {
    font-size: 0.8rem;
  }

  .footer {
    padding: 0.75rem;
  }

  .footer-content p {
    font-size: 0.8rem;
  }
}

/* Focus and Active States */
.output-content.error {
  color: #ff6b6b;
}

.output-content.success {
  color: #51cf66;
}

/* Animation Classes */
.fade-in {
  animation: fadeIn 0.5s ease-in-out;
}

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

.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
  }
}

/* Footer Styles */
.footer {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  padding: 1rem 2rem;
  margin-top: auto;
  z-index: 50;
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  text-align: center;
}

.footer-content p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 400;
}

.footer-content a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: var(--transition);
}

.footer-content a:hover {
  background: var(--secondary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;  background-clip: text;
  transform: translateY(-1px);
}

/* Auto-save Notification Panel */
.auto-save-panel {
  position: fixed;
  top: 5rem;
  left: 2rem;
  z-index: 1002;
  pointer-events: none;
}

.auto-save-indicator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: rgba(76, 175, 80, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 12px;
  color: #4caf50;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(76, 175, 80, 0.2);
  opacity: 0;
  transform: translateX(-100%) scale(0.8);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 160px;
  pointer-events: auto;
}

.auto-save-indicator.show {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.auto-save-indicator i {
  font-size: 1rem;
  flex-shrink: 0;
}

.auto-save-indicator.saving {
  background: rgba(255, 193, 7, 0.1);
  border-color: rgba(255, 193, 7, 0.3);
  color: #ffc107;
  box-shadow: 0 8px 32px rgba(255, 193, 7, 0.2);
}

.auto-save-indicator.saving i {
  animation: spin 1s linear infinite;
}

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

/* Responsive Auto-save Panel */
@media (max-width: 768px) {
  .auto-save-panel {
    top: 4rem;
    left: 1rem;
    right: 1rem;
  }
  
  .auto-save-indicator {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    min-width: 140px;
    transform: translateY(-100%) scale(0.8);
  }
  
  .auto-save-indicator.show {
    transform: translateY(0) scale(1);
  }
  
  .auto-save-indicator i {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .auto-save-panel {
    top: 3.5rem;
    left: 0.75rem;
    right: 0.75rem;
  }
  
  .auto-save-indicator {
    padding: 0.6rem 0.8rem;
    font-size: 0.75rem;
    min-width: 120px;
    gap: 0.5rem;
  }
  
  .auto-save-indicator span {
    font-size: 0.75rem;
  }
  
  .auto-save-indicator i {
    font-size: 0.8rem;
  }
}
