/* ============================================================
   VARIABLES
   ============================================================ */
:root {
  /* Backgrounds */
  --bg-page:       #080b12;
  --bg-card:       #0e1120;
  --bg-card2:      #131729;
  --bg-input:      #0a0d18;
  --bg-hover:      #161b2e;

  /* Borders */
  --border:        #1e2540;
  --border-light:  #252d4a;

  /* Accent — violet/indigo */
  --accent:        #6c63ff;
  --accent-soft:   #8b85ff;
  --accent-dim:    rgba(108,99,255,.18);
  --accent-glow:   rgba(108,99,255,.45);

  /* Secondary accent — cyan */
  --cyan:          #22d3ee;
  --cyan-dim:      rgba(34,211,238,.12);

  /* Text */
  --text-primary:  #eef0f8;
  --text-secondary:#9ba3c2;
  --text-muted:    #555e80;

  /* States */
  --success:       #34d399;
  --success-bg:    rgba(52,211,153,.1);
  --error:         #f87171;
  --error-bg:      rgba(248,113,113,.1);
  --info-text:     #60a5fa;
  --info-bg:       rgba(96,165,250,.1);

  /* Misc */
  --radius-sm:     8px;
  --radius:        14px;
  --radius-lg:     20px;
  --shadow:        0 8px 40px rgba(0,0,0,.6);
  --shadow-sm:     0 2px 12px rgba(0,0,0,.4);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 36px 20px 64px;
  /* Subtle radial glow in the top center */
  background-image:
    radial-gradient(ellipse 80% 40% at 50% -10%, rgba(108,99,255,.15) 0%, transparent 70%);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container { max-width: 1140px; margin: 0 auto; }

.main-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 900px) { .main-grid { grid-template-columns: 1fr; } }

/* ============================================================
   HEADER
   ============================================================ */
header {
  text-align: center;
  margin-bottom: 48px;
}
.header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px; height: 68px;
  border-radius: 18px;
  background: var(--accent-dim);
  border: 1px solid rgba(108,99,255,.3);
  font-size: 2rem;
  margin-bottom: 20px;
  box-shadow: 0 0 32px var(--accent-glow);
}
header h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -.03em;
  background: linear-gradient(135deg, #fff 30%, var(--accent-soft));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}
header p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin: 0 auto;
  line-height: 1.6;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  /* Subtle top-edge highlight */
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(108,99,255,.5), transparent);
}

/* ============================================================
   UPLOAD AREA
   ============================================================ */
.upload-area {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .25s, background .25s, box-shadow .25s;
  background: var(--bg-input);
  position: relative;
}
.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: inset 0 0 40px rgba(108,99,255,.06);
}
.upload-area svg {
  color: var(--accent-soft);
  margin-bottom: 18px;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}
.upload-area p {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 6px;
}
.upload-hint {
  font-size: .8rem !important;
  color: var(--text-muted) !important;
  margin-bottom: 3px !important;
}

/* ============================================================
   PREVIEW
   ============================================================ */
.preview-section { margin-bottom: 22px; text-align: center; }
#previewImage {
  max-width: 100%;
  max-height: 360px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: block;
  margin-inline: auto;
}
.clear-btn {
  padding: 7px 20px;
  background: transparent;
  color: var(--error);
  border: 1px solid rgba(248,113,113,.35);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.clear-btn:hover {
  background: var(--error-bg);
  border-color: var(--error);
}

/* ============================================================
   GENERATE BUTTON
   ============================================================ */
.generate-btn {
  width: 100%;
  padding: 15px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, background .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  position: relative;
  overflow: hidden;
}
.generate-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.08) 0%, transparent 100%);
  pointer-events: none;
}
.generate-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--accent-glow);
}
.generate-btn:active:not(:disabled) { transform: translateY(0); }
.generate-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   LOADER
   ============================================================ */
.loader {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   STATUS MESSAGE
   ============================================================ */
.status-message {
  margin-bottom: 22px;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  display: none;
  text-align: center;
  border: 1px solid transparent;
}
.status-message.info {
  background: var(--info-bg);
  color: var(--info-text);
  border-color: rgba(96,165,250,.2);
  display: block;
}
.status-message.error {
  background: var(--error-bg);
  color: var(--error);
  border-color: rgba(248,113,113,.2);
  display: block;
}
.status-message.success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(52,211,153,.2);
  display: block;
}

/* ============================================================
   CAPTION BILINGUAL BLOCKS
   ============================================================ */
.caption-section {
  margin-top: 28px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.caption-block {
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  overflow: hidden;
  background: var(--bg-input);
  transition: border-color .2s;
}
.caption-block:hover { border-color: var(--accent); }

.caption-block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-card2);
  border-bottom: 1px solid var(--border);
}
.lang-flag { font-size: 1.05rem; }
.lang-label {
  flex: 1;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-secondary);
}
.copy-btn {
  padding: 5px 14px;
  background: var(--accent-dim);
  color: var(--accent-soft);
  border: 1px solid rgba(108,99,255,.3);
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.copy-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.caption-text {
  padding: 18px;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-primary);
}

/* ============================================================
   HISTORY PANEL
   ============================================================ */
.history-section { position: sticky; top: 24px; }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.history-header h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-secondary);
}
.clear-history-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  font-size: .85rem;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.clear-history-btn:hover {
  border-color: var(--error);
  color: var(--error);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 640px;
  overflow-y: auto;
  padding-right: 6px;
}
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}
.history-empty {
  color: var(--text-muted);
  font-size: .88rem;
  text-align: center;
  padding: 40px 0;
}

.history-item {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
  cursor: default;
}
.history-item:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}
.history-item img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}
.history-no-thumb {
  width: 100%; height: 60px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.history-item-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-lang-badge {
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-top: 8px;
}
.history-lang-badge:first-child { margin-top: 0; }
.history-item-caption {
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.history-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.history-item-date {
  font-size: .7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.history-item-btns { display: flex; gap: 6px; }
.history-copy-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 5px;
  transition: color .2s, border-color .2s, background .2s;
}
.history-copy-btn:hover {
  color: var(--accent-soft);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  header h1     { font-size: 1.8rem; }
  .card         { padding: 18px; }
  .header-icon  { width: 56px; height: 56px; font-size: 1.6rem; }
}
