@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* --- DESIGN SYSTEM & TOKENS --- */
:root {
  --font-primary: 'Plus Jakarta Sans', sans-serif;
  --bg-main: #05070F;
  --bg-card: rgba(13, 20, 38, 0.5);
  --border-color: rgba(255, 255, 255, 0.07);
  
  --primary-glow: linear-gradient(135deg, #8B5CF6 0%, #D946EF 100%);
  --secondary-glow: rgba(139, 92, 246, 0.1);
  --accent-color: #8B5CF6;
  
  --color-text-main: #F3F4F6;
  --color-text-muted: #9CA3AF;
  
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-elastic: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.25);
}

/* --- RESET & GLOBAL STYLES --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-main);
  color: var(--color-text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 20% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(217, 70, 239, 0.06) 0%, transparent 40%);
  background-attachment: fixed;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* --- HEADER --- */
header {
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  background: rgba(5, 7, 15, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo {
  font-weight: 800;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #FFF;
}

/* --- GLASS PANEL --- */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  animation: fadeIn 0.4s ease-out;
}

/* --- LANGUAGE SELECTOR BAR --- */
.language-selector-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 0.6rem;
  border-radius: 16px;
}

.language-selector-bar select {
  flex: 1;
  background: transparent;
  color: #FFF;
  border: none;
  font-family: var(--font-primary);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.5rem 0.2rem;
  outline: none;
  cursor: pointer;
}

.language-selector-bar select option {
  background: #0D1426;
  color: #FFF;
}

.btn-swap {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.04);
  color: #FFF;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-elastic);
}

.btn-swap:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.35);
  transform: rotate(180deg);
}

/* --- ALERT BOX --- */
.alert-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #F87171;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  text-align: center;
}

/* --- TRANSLATION BOX --- */
.translation-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
}

.translation-box.target-box {
  background: rgba(139, 92, 246, 0.015);
  border-color: rgba(139, 92, 246, 0.08);
}

.box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.box-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  letter-spacing: 0.5px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition-smooth);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #FFF;
}

textarea {
  width: 100%;
  min-height: 120px;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-primary);
  font-size: 1.05rem;
  color: #FFF;
  resize: none;
  line-height: 1.4;
  margin-bottom: 0.8rem;
}

textarea::placeholder {
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.95rem;
}

/* --- INPUT ACTION BAR --- */
.input-action-bar {
  display: flex;
  gap: 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 0.8rem;
}

.action-btn {
  flex: 1;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.03);
  color: var(--color-text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-smooth);
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.btn-voice {
  border-color: rgba(139, 92, 246, 0.25);
  background: rgba(139, 92, 246, 0.06);
  color: #A78BFA;
}

.btn-voice:hover {
  background: rgba(139, 92, 246, 0.12);
}

/* Listening pulsating state */
.btn-voice.listening {
  background: #EF4444 !important;
  color: #FFF !important;
  border-color: #EF4444 !important;
  animation: pulseMic 1.2s infinite alternate;
}

@keyframes pulseMic {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  100% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.btn-photo {
  border-color: rgba(217, 70, 239, 0.25);
  background: rgba(217, 70, 239, 0.06);
  color: #F472B6;
}

.btn-photo:hover {
  background: rgba(217, 70, 239, 0.12);
}

/* --- OUTPUT ACTION BAR --- */
.output-action-bar {
  display: flex;
  gap: 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 0.8rem;
}

.btn-tts {
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.06);
  color: #34D399;
}

.btn-tts:hover {
  background: rgba(16, 185, 129, 0.12);
}

.btn-copy {
  border-color: rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.06);
  color: #60A5FA;
}

.btn-copy:hover {
  background: rgba(59, 130, 246, 0.12);
}

/* --- OCR STATUS & PROGRESS BAR --- */
.ocr-status-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(217, 70, 239, 0.05);
  border: 1px solid rgba(217, 70, 239, 0.15);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin-top: 0.8rem;
  animation: slideDown 0.3s ease-out;
}

.ocr-spinner {
  font-size: 1.2rem;
  animation: spin 2s linear infinite;
}

.ocr-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#ocr-status-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: #F472B6;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #D946EF 0%, #8B5CF6 100%);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* --- IMAGE PREVIEW --- */
.image-preview-container {
  margin-top: 0.8rem;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  animation: slideDown 0.3s ease-out;
  display: flex;
  flex-direction: column;
}

#image-preview {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  background: #000;
}

.btn-remove-img {
  background: rgba(239, 68, 68, 0.9);
  color: #FFF;
  border: none;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.4rem;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-smooth);
}

.btn-remove-img:hover {
  background: #EF4444;
}

/* --- FOOTNOTE --- */
.app-footnote {
  margin-top: 1.5rem;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.45;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 1rem;
}

.app-footnote strong {
  color: #FFF;
}

/* --- GLOBAL BUTTONS --- */
.btn {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.6rem 1.4rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: var(--transition-elastic);
  text-decoration: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

/* --- ANIMATIONS & TRANSITIONS --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; overflow: hidden; }
  to { opacity: 1; max-height: 250px; }
}

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

/* --- RESPONSIVE STYLE --- */
@media (max-width: 480px) {
  .container {
    padding: 1rem 0.5rem;
  }
  
  .glass-panel {
    padding: 1rem;
    border-radius: 20px;
  }

  .input-action-bar, .output-action-bar {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .action-btn {
    padding: 0.65rem;
  }
}
