@font-face {
  font-family: 'AquaMoons';
  src: url('fonts/AquaMoons.woff2') format('woff2');
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;700&display=swap');

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

  --color-accent: #667eea;
  --color-bg-primary: #0f172a;
  --color-bg-secondary: #764ba2;
  --color-bg-card: rgba(30, 41, 59, 0.7);
  --color-bg-edit: #141e2e;
  --color-bg-focus: rgba(99, 102, 241, 0.1);
  --color-border: rgba(255, 255, 255, 0.2);
  --color-border-highlight: #3b4f74;
  --color-box-shadow: rgba(99, 102, 241, 0.3);
  --color-text-primary: #f8fafc;
  --color-text-muted: #94a3b8;
  --color-primary-dark: #475569;
  --color-primary-light: #a0aec0;
  --color-bg-event-dark: rgba(102, 126, 234, 0.25);
  --color-bg-event-light: rgba(102, 126, 234, 0.15);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-xl: 12px;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 4px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.08);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s ease;
}

body {
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
  overflow-x: hidden;
}

#stars-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: radial-gradient(ellipse at bottom, #1B2735 0%, #090A0F 100%);
  overflow: hidden;
}

body::selection {
  background: var(--color-bg-secondary);
  color: white;
}

.title {
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  text-align: center;
  margin: 0 1rem 0.5rem;
  background: var(--gradient-primary);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin: 0 1rem 2rem;
}

.lang-switcher {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  gap: 0.5rem;
  z-index: 100;
}

select,
input {
  width: 100%;
  background: var(--color-bg-edit);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  padding: 0.5rem 2.5rem 0.5rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

select:hover,
input:hover {
  border-color: var(--color-accent);
  color: var(--color-text-primary);
}

select:hover {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

select:focus,
input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-box-shadow);
}

input:focus {
  background: var(--color-bg-focus);
}

select option {
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  padding: 10px;
}

.title-icon {
  height: 2rem;
  width: auto;
  vertical-align: middle;
  margin-right: 1rem;
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.3));
  transition: transform 0.3s ease;
  animation: float 3s ease-in-out infinite;
}

.title:hover .title-icon {
  transform: scale(1.1) rotate(15deg);
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}

.container {
  width: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.glass-card {
  background: var(--color-bg-card);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1rem 2rem 1.5rem;
  box-shadow: var(--shadow-card);
  animation: fadeIn 0.8s ease-out forwards;
}

.glass-card:hover {
  border-color: var(--color-border-highlight);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.controls-section h2,
.editor-section h2,
.calendar-section h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;

  color: var(--color-accent);
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  color: var(--color-text-muted);
}

input[type="time"]::-webkit-calendar-picker-indicator {
  position: absolute;
  right: 10px;
  filter: invert(67%) sepia(5%) saturate(1221%) hue-rotate(176deg) brightness(96%) contrast(86%);
}

.btn {
  width: 100%;
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.btn:not(:disabled):hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.btn:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-muted);
  cursor: default;
  box-shadow: none;
  border: 1px solid var(--color-border);
}

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

.btn-secondary {
  background: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
  margin-top: 1rem;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-replace {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.search-inputs {
  display: flex;
  gap: 1rem;
}

.search-inputs .form-group {
  flex: 1;
  margin-bottom: 0;
}

.search-replace input {
  width: 100%;
}

.search-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
  flex: 1;
}

.editor-wrapper {
  display: flex;
  background: #000;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  overflow: hidden;
  height: 500px;
}

#line-numbers {
  width: 50px;
  background: #111;
  border-right: 1px solid var(--color-border);
  color: var(--color-text-muted);
  padding: 1rem 0.5rem;
  text-align: right;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre;
  user-select: none;
  overflow: hidden;
  scrollbar-width: none;
}

#line-numbers::-webkit-scrollbar {
  display: none;
}

#json-editor {
  flex: 1;
  height: 100%;
  background: transparent;
  color: #4ade80;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 1rem;
  border: none;
  outline: none;
  resize: none;
  white-space: pre;
  overflow: auto;
}

#json-editor::placeholder {
  font-style: italic;
}

.status-bar {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Calendar Preview Styles */
.calendar-section {
  margin-top: 0;
  padding-bottom: 2rem;
  grid-column: 1 / -1;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.month-card {
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-md);
  padding: 1rem;
  border: 1px solid var(--color-border);
  transition: all 0.3s ease;
  max-width: 360px;
  margin: 0 auto;
  width: 100%;
}

.month-card:hover {
  border-color: var(--color-primary-light);
  transform: translateY(-2px);
}

.month-title {
  text-align: center;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--color-primary-light);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
}

.days-header {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  width: 100%;
}

.day-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  transition: background 0.2s;
  min-width: 0;
  padding: 2px;
}

.day-cell.has-event {
  background: var(--color-bg-event-dark);
  border: 1px solid rgba(79, 70, 229, 0.3);
}

.day-number {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-bottom: 0;
}

.day-cell.has-event .day-number {
  color: var(--color-primary-light);
}

.moon-symbol {
  font-family: 'AquaMoons', serif;
  font-size: 0.95rem;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.phase-name {
  font-size: 0.48rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 1px;
  line-height: 1.1;
  font-weight: 400;
}

/* Light Mode adaptations */
body.light-theme .month-card {
  background: rgba(255, 255, 255, 0.8);
  color: var(--color-primary-dark);
}

body.light-theme .month-title {
  color: var(--color-primary-dark);
}

body.light-theme .days-header {
  color: var(--color-primary-dark);
}

body.light-theme .day-cell .day-number {
  color: var(--color-primary-dark);
}

body.light-theme .day-cell.has-event {
  background: var(--color-bg-event-light);
  border: 1px solid rgba(79, 70, 229, 0.3);
}

body.light-theme .day-cell.has-event .day-number {
  color: var(--color-primary-dark);
}

body.light-theme .moon-symbol {
  color: var(--color-primary-dark);
  text-shadow: none;
}

body.light-theme .phase-name {
  color: var(--color-primary-dark);
}

/* Footer Styling */
.app-footer {
  width: 100%;
  max-width: 1100px;
  margin-top: auto;
  padding: 1.5rem 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: center;
  position: relative;
}

.footer-content {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 0 1rem;
  color: var(--color-text-muted);
}

.footer-title {
  font-weight: 500;
  font-size: 0.85rem;
}

.footer-separator {
  color: var(--color-border);
  user-select: none;
}

.footer-content a {
  color: #a78bfa;
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.footer-content a:hover {
  color: #764ba2;
  filter: brightness(1.2);
}

@media (max-width: 1300px) {
  .lang-switcher {
    position: static;
    margin: 1rem 0 0.75rem;
    justify-content: center;
    width: 100%;
    display: flex;
  }

  .lang-select {
    width: auto;
  }

  .title {
    font-size: 1.8rem;
    line-height: 1.2;
  }
}

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

@media (max-width: 600px) {
  .footer-content {
    gap: 0.75rem;
  }
}

/* Scroll Top Button */
.scroll-top-btn {
  position: fixed;
  right: 2rem;
  bottom: 2rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: 1px solid var(--color-border);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

.scroll-top-btn.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-top-btn svg {
  transition: transform 0.3s ease;
}

.scroll-top-btn:hover {
  transform: translateY(-5px) scale(1.1);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.scroll-top-btn:hover svg {
  transform: translateY(-2px);
}

.scroll-top-btn:active {
  transform: scale(0.95);
}

@media (max-width: 600px) {
  .scroll-top-btn {
    right: 1.5rem;
    bottom: 1.5rem;
  }
}

/* Custom Scrollbar for Textarea */
#json-editor::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

#json-editor::-webkit-scrollbar-track {
  background: transparent;
}

#json-editor::-webkit-scrollbar-thumb {
  background: var(--color-box-shadow);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}

#json-editor::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-accent);
}

#json-editor::-webkit-scrollbar-corner {
  background: transparent;
}