/* ================================================================
   translate.css — v9 Premium Redesign (Clean)
   ================================================================ */

/* ---- Local Tokens ---- */
:root {
  --tw-radius-card: 2rem;
  --tw-radius-panel: 1.5rem;
  --tw-radius-btn: 0.75rem;
  --tw-glass-border: rgba(255, 255, 255, 0.18);
  --tw-glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
  --tw-glass-inner: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  --tw-diffusion: 0 20px 40px -15px rgba(0, 0, 0, 0.04);
}

/* ================================================================
   Main Container — constrained, airy
   ================================================================ */
.translate-main {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 40px 80px;
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ================================================================
   Workspace — Core translate area
   ================================================================ */
.tw-workspace {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
  width: 100%;
}

/* ---- Top Bar ---- */
.tw-top-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 0;
}

/* Workspace live status — subtle indicator */
.tw-workspace-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 0 0.25rem;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.tw-workspace-status .breathing-dot {
  width: 7px;
  height: 7px;
}

.tw-workspace-status-text {
  color: var(--color-text-muted);
  letter-spacing: 0.03em;
}

.tw-lang-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tw-lang-select {
  padding: 9px 34px 9px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--tw-radius-btn);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23959BA3' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}
.tw-lang-select:hover { border-color: var(--color-primary); }
.tw-lang-select:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-bg); }
.tw-lang-select option { background: var(--color-surface); color: var(--color-text); }

/* Compact lang select for in-header usage */
.tw-lang-select-sm {
  padding: 6px 28px 6px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.tw-swap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-spring);
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
}
.tw-swap-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  transform: rotate(180deg);
  background: var(--color-primary-bg);
}
.tw-swap-btn:active { transform: rotate(180deg) scale(0.9); }
.tw-swap-btn svg { width: 14px; height: 14px; }

.tw-action-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tw-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: var(--tw-radius-btn);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.tw-tool-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-bg);
  border-color: var(--color-border);
}
.tw-tool-btn:active { transform: scale(0.92); }
.tw-tool-btn svg { width: 17px; height: 17px; }
.tw-tool-btn.active { color: var(--color-primary); background: var(--color-primary-bg); }

.tw-primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--tw-radius-btn);
  background: var(--gradient-primary);
  color: #FFFFFF;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: 0 2px 12px var(--color-primary-glow);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.tw-primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--color-primary-glow);
}
.tw-primary-btn:active:not(:disabled) { transform: scale(0.96); }
.tw-primary-btn:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }

.tw-primary-btn-sm {
  padding: 6px 16px;
  font-size: 0.8rem;
}

/* ================================================================
   Unified Panel — Single container, left-right layout
   ================================================================ */
.tw-panel-unified {
  display: flex !important;
  flex-direction: row !important;
  border: 1px solid var(--color-border);
  border-radius: var(--tw-radius-panel);
  background: var(--color-surface);
  overflow: hidden;
  transition: all var(--transition-base);
  min-height: 480px;
  flex: 1;
  width: 100%;
  position: relative;
}

.tw-panel-unified::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  box-shadow: var(--tw-glass-inner);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.tw-panel-unified:hover {
  box-shadow: var(--tw-glass-shadow);
  border-color: rgba(13, 148, 136, 0.15);
}

/* ---- Source area (left) ---- */
.tw-uni-source {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--color-border-light);
  position: relative;
  z-index: 2;
}

.tw-uni-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.tw-uni-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.tw-uni-badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
  margin-left: auto;
  letter-spacing: 0.02em;
}

/* ---- Result area (right) ---- */
.tw-uni-result {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 2;
}

.tw-uni-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 20px;
  min-height: 0;
  position: relative;
  z-index: 2;
  overflow: hidden;
}

.tw-uni-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border-light);
  flex-shrink: 0;
  background: var(--color-bg-alt);
  position: relative;
  z-index: 2;
}

.tw-result-acts {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.tw-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.tw-icon-btn:hover { color: var(--color-primary); background: var(--color-primary-bg); }
.tw-icon-btn:active { transform: scale(0.92); }
.tw-icon-btn svg { width: 16px; height: 16px; }

.tw-textarea {
  flex: 1;
  width: 100%;
  padding: 16px 20px;
  background: transparent;
  border: none;
  outline: none !important;
  font-size: 1rem;
  line-height: 1.85;
  color: var(--color-text);
  font-family: var(--font-sans);
  resize: none;
  min-height: 320px;
  box-sizing: border-box;
}
.tw-textarea:focus { outline: none !important; }
.tw-textarea::placeholder { color: var(--color-text-muted); }

.tw-result {
  flex: 1;
  padding: 4px 0;
  font-size: 1rem;
  line-height: 1.85;
  color: var(--color-text);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.tw-result.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--color-text-muted);
}

.tw-empty-icon svg {
  width: 56px;
  height: 56px;
  opacity: 0.12;
  color: var(--color-primary);
  animation: twEmptyFloat 4s ease-in-out infinite;
}

@keyframes twEmptyFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.tw-empty-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 0;
}

.tw-empty-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* ---- Skeleton Shimmer ---- */
.tw-skeleton {
  position: absolute;
  inset: 0;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 3;
  background: var(--color-surface);
  border-radius: 0 0 var(--tw-radius-panel) var(--tw-radius-panel);
}

.tw-skel-line {
  height: 14px;
  border-radius: 6px;
  background: var(--color-bg-alt);
  position: relative;
  overflow: hidden;
}
.tw-skel-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(13, 148, 136, 0.06) 50%, transparent 100%);
  animation: tw-shimmer 1.6s ease-in-out infinite;
}

@keyframes tw-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ---- Processing overlay — gradient pulse on result area ---- */
.tw-uni-result.processing::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 4;
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.03) 0%, transparent 50%, rgba(13, 148, 136, 0.03) 100%);
  animation: tw-processPulse 2s ease-in-out infinite;
}

@keyframes tw-processPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

.tw-shortcuts {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.tw-shortcuts span {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.tw-shortcuts kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  font-size: 0.62rem;
  font-family: var(--font-mono);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.tw-count {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* ================================================================
   Export Menu
   ================================================================ */
.export-menu {
  position: fixed;
  min-width: 180px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  padding: 6px;
  z-index: 1000;
  animation: exportMenuIn 0.15s ease-out;
}

@keyframes exportMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.export-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.export-item:hover {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

/* ================================================================
   Entry Animations
   ================================================================ */
.tw-panel-unified {
  animation: tw-panelSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s forwards;
  opacity: 0;
}

@keyframes tw-panelSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   Responsive — Tablet ≤ 768px
   ================================================================ */
@media (max-width: 768px) {
  .translate-main { padding: 0 20px 40px; }

  .tw-top-bar { flex-direction: column; align-items: stretch; }
  .tw-action-group { justify-content: center; }

  .tw-panel-unified { flex-direction: column !important; min-height: 400px; }
  .tw-uni-source { border-right: none; border-bottom: 1px solid var(--color-border-light); }
  .tw-textarea { min-height: 160px; }
  .tw-uni-result { min-height: 160px; }

  .tw-shortcuts { display: none; }
}

/* ================================================================
   Responsive — Mobile ≤ 480px
   ================================================================ */
@media (max-width: 480px) {
  .translate-main { padding: 0 14px 24px; }

  .tw-lang-select { font-size: 0.8rem; padding: 7px 28px 7px 10px; min-width: 90px; }
  .tw-swap-btn { width: 34px; height: 34px; }
  .tw-primary-btn { padding: 8px 18px; font-size: 0.8rem; }
  .tw-tool-btn { width: 34px; height: 34px; }

  .tw-uni-head { padding: 12px 16px; }
  .tw-uni-body { padding: 14px 16px; }
  .tw-uni-foot { padding: 10px 16px; }
  .tw-textarea { font-size: 0.9rem; min-height: 140px; }
  .tw-result { font-size: 0.9rem; }
}

/* ================================================================
   Responsive — Extra Small ≤ 360px
   ================================================================ */
@media (max-width: 360px) {
  .translate-main { padding: 0 10px 16px; }

  .tw-lang-select-sm { min-width: 72px; font-size: 0.75rem; }
}

/* ================================================================
   Reduced Motion
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  .tw-empty-icon svg,
  .tw-uni-result.processing::after { animation: none; }

  .tw-panel-unified { opacity: 1; transform: none; animation: none; }
  .tw-skel-line::after { animation: none; background: var(--color-bg-alt); }
}
