@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

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

:root {
  --blue:       #40c1ac;
  --blue-light: #66cdbd;
  --blue-glow:  rgba(64, 193, 172, 0.45);
  --gold:       #FFB800;
  --gold-dim:   rgba(255, 184, 0, 0.13);
  --bg:         #253746;
  --glass:      rgba(30, 46, 58, 0.90);
  --border:     rgba(255, 255, 255, 0.09);
  --white:      #FFFFFF;
  --muted:      rgba(255, 255, 255, 0.48);
  --r:          18px;
  --rpill:      999px;
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Nunito', sans-serif;
  color: var(--white);
  -webkit-font-smoothing: antialiased;
}

/* ══ LAYOUT ═════════════════════════════════════════════════ */

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

#main-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* ══ WELCOME SCREEN ═════════════════════════════════════════ */

#welcome-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0;
  background: radial-gradient(ellipse at 50% 38%, #0D1E45 0%, #08091A 68%);
  transition: opacity 0.7s var(--ease);
  z-index: 2;
  overflow: hidden;
}

#welcome-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.welcome-badge {
  width: 140px; height: 140px;
  background: linear-gradient(145deg, var(--blue), var(--blue-light));
  border-radius: 36px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 56px var(--blue-glow), 0 0 120px rgba(64,193,172,.18);
  margin-bottom: 36px;
  animation: badgePulse 3.2s ease-in-out infinite;
  padding: 28px;
}

.welcome-badge svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.15));
}

@keyframes badgePulse {
  0%, 100% {
    box-shadow: 0 0 56px var(--blue-glow), 0 0 120px rgba(64,193,172,.18);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 80px var(--blue-glow), 0 0 160px rgba(64,193,172,.32);
    transform: scale(1.04);
  }
}

.welcome-title {
  font-size: clamp(38px, 5vw, 68px);
  font-weight: 900; margin-bottom: 18px;
  text-align: center;
}

.t-maib {
  color: #ffffff;
}

.t-junior {
  color: #ee2737;
}

.welcome-sub {
  font-size: clamp(17px, 2vw, 27px);
  font-weight: 600; color: var(--muted);
  text-align: center; max-width: 540px;
  line-height: 1.55;
}

/* Particule floating pe welcome screen */
.particle {
  position: absolute; pointer-events: none;
  animation: particleFloat linear infinite;
  opacity: 0;
}

@keyframes particleFloat {
  0%   { opacity: 0; transform: translateY(0) scale(.55); }
  15%  { opacity: .8; }
  85%  { opacity: .8; }
  100% { opacity: 0; transform: translateY(-200px) scale(1.1); }
}

/* ══ IMAGINE GENERATĂ ════════════════════════════════════════ */

#image-container {
  position: absolute; inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 1s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 120px 40px 120px;
}

#image-container.visible { opacity: 1; }

#result-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 20px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
}

/* Gradient jos – face bara de input lizibilă peste imagine */
#image-container::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 180px;
  background: linear-gradient(to top, rgba(8,9,26,.95), transparent);
  pointer-events: none;
}

/* ══ BRAND OVERLAY ══════════════════════════════════════════ */

#brand-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  /* ascuns până apare imaginea — controlled de #image-container.visible */
}

/* Logo maib junior – dreapta jos, mai mare, cu glow ușor */
.overlay-logo--junior {
  position: absolute;
  bottom: 48px;
  right: 140px;
  width: 180px;
  height: auto;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.55));
  transition: opacity 0.6s ease 0.4s;
}

/* Logo maib – stânga jos, mai mic, discret */
.overlay-logo--maib {
  position: absolute;
  bottom: 52px;
  left: 140px;
  width: 110px;
  height: auto;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
  transition: opacity 0.6s ease 0.4s;
}

/* ══ LOADER ═════════════════════════════════════════════════ */

#loader {
  position: absolute; inset: 0;
  z-index: 10;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 30px;
  background: rgba(8, 9, 26, 0.90);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease;
  overflow: hidden;
}

#loader.loader--on {
  opacity: 1;
  pointer-events: all;
}

/* Inelul rotitor */
.orb-ring {
  width: 164px; height: 164px;
  border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(
    from 0deg,
    var(--blue),
    var(--blue-light),
    var(--gold),
    #A855F7,
    #EC4899,
    #0EA5E9,
    var(--blue)
  );
  animation: orbSpin 1.9s linear infinite;
  position: relative;
}

.orb-ring::before {
  content: '';
  position: absolute; inset: 11px;
  border-radius: 50%;
  background: #090B1E;
}

.orb-ring::after {
  content: '✨';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 54px;
  animation: emojiPop 1.6s ease-in-out infinite;
}

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

@keyframes emojiPop {
  0%, 100% { transform: scale(1) rotate(-5deg); }
  50%       { transform: scale(1.28) rotate(8deg); }
}

.loader-msg {
  font-size: clamp(19px, 2.4vw, 30px);
  font-weight: 700; color: white;
  text-align: center; letter-spacing: .02em;
  min-height: 2em;
  transition: opacity 0.4s ease;
}

/* Punctele animate */
.dots {
  display: flex; gap: 10px;
}

.dots span {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--gold);
  animation: dotBounce 1.3s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(.5); opacity: .35; }
  40%            { transform: scale(1.1); opacity: 1; }
}

/* Sparkle-uri care plutesc în loader */
.sparkle {
  position: absolute; pointer-events: none;
  animation: sparkleDrift ease-in-out infinite;
  opacity: 0;
}

@keyframes sparkleDrift {
  0%   { opacity: 0; transform: translateY(50px) scale(.4); }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-90px) scale(1.4); }
}

/* ══ BARA DE JOS ════════════════════════════════════════════ */

#bottom-bar {
  flex-shrink: 0;
  padding: 14px 44px 24px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--glass);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-top: 1px solid var(--border);
  position: relative; z-index: 5;
}

/* Chips teme */
#themes-row {
  display: flex; gap: 10px;
  overflow-x: auto; scrollbar-width: none;
  -ms-overflow-style: none;
}
#themes-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 8px 22px;
  border-radius: var(--rpill);
  border: 1.5px solid var(--border);
  background: rgba(255,255,255,.05);
  color: var(--muted);
  font-family: 'Nunito', sans-serif;
  font-size: clamp(13px, 1.3vw, 16px);
  font-weight: 700; cursor: pointer;
  transition: all .22s var(--ease);
  white-space: nowrap; user-select: none;
}

.chip:hover {
  background: rgba(255,255,255,.10);
  color: white; border-color: rgba(255,255,255,.26);
}

.chip--active {
  background: var(--blue);
  border-color: var(--blue-light);
  color: white;
  box-shadow: 0 0 18px var(--blue-glow);
}

/* Rândul de input */
#controls-row {
  display: flex; gap: 12px; align-items: center;
}

#prompt-input {
  flex: 1; height: 58px;
  background: rgba(255,255,255,.07);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 0 24px;
  font-family: 'Nunito', sans-serif;
  font-size: clamp(15px, 1.7vw, 20px);
  font-weight: 600; color: white; outline: none;
  transition: all .22s var(--ease);
}

#prompt-input::placeholder { color: rgba(255,255,255,.28); }

#prompt-input:focus {
  border-color: var(--blue-light);
  background: rgba(64,193,172,.12);
  box-shadow: 0 0 0 3px rgba(64,193,172,.18);
}


#btn-surprise {
  height: 58px; padding: 0 26px;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--gold-dim);
  color: var(--gold);
  font-family: 'Nunito', sans-serif;
  font-size: clamp(13px, 1.4vw, 17px);
  font-weight: 800; cursor: pointer;
  transition: all .22s var(--ease); white-space: nowrap;
}

#btn-surprise:hover {
  background: rgba(255,184,0,.22);
  box-shadow: 0 0 20px rgba(255,184,0,.28);
  transform: translateY(-1px);
}

#btn-generate {
  height: 58px; padding: 0 48px;
  border-radius: var(--r); border: none;
  background: linear-gradient(135deg, var(--blue), var(--blue-light));
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: clamp(15px, 1.7vw, 21px);
  font-weight: 900; cursor: pointer;
  transition: all .22s var(--ease);
  white-space: nowrap; letter-spacing: .03em;
  box-shadow: 0 4px 24px var(--blue-glow);
}

#btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 36px rgba(64,193,172,.65);
}

#btn-generate:active { transform: translateY(0); }

#btn-generate:disabled,
#btn-surprise:disabled {
  opacity: .42; cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ══ TOAST (mesaje de eroare) ══════════════════════════════ */

.toast {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(20, 20, 40, 0.96);
  border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(16px);
  color: white; padding: 13px 36px;
  border-radius: var(--rpill);
  font-size: clamp(14px, 1.4vw, 17px);
  font-weight: 700; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}

.toast--on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast--err { border-color: rgba(239,68,68,.40); }
