/* ============================================================
   Azure Translator – styles.css
   Aesthetic: Editorial dark-slate with teal accent
   Fonts: Syne (display) + DM Sans (body)
   ============================================================ */

/* ── CSS Custom Properties (Design Tokens) ── */
:root {
  /* Color palette */
  --bg:          #0d1117;        /* page background */
  --surface:     #161b22;        /* card surfaces */
  --surface-2:   #1c2330;        /* elevated panels */
  --border:      #2a3441;        /* subtle borders */
  --border-focus:#3dd6c8;        /* teal on focus */
  --accent:      #3dd6c8;        /* primary accent (teal) */
  --accent-dark: #29a89d;        /* darker teal for hover */
  --text-primary:#e6edf3;        /* main text */
  --text-muted:  #7d8fa3;        /* secondary / placeholder */
  --text-dim:    #4d5f73;        /* very subtle */
  --danger:      #f87171;        /* error messages */
  --success:     #4ade80;        /* success feedback */

  /* Typography */
  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.35);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.45);

  /* Transitions */
  --ease: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  background-color: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Subtle grid pattern overlay */
  background-image:
    radial-gradient(circle at 18% 12%, rgba(61,214,200,0.07) 0%, transparent 50%),
    radial-gradient(circle at 85% 90%, rgba(61,214,200,0.05) 0%, transparent 45%);
}

/* ── Typography helpers ── */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--ease);
}
a:hover { color: var(--text-primary); }

/* ── Scrollbar (WebKit) ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }


/* ==============================================================
   HEADER
   ============================================================== */
.header {
  border-bottom: 1px solid var(--border);
  padding: 0 clamp(16px, 4vw, 48px);
  background: rgba(22,27,34,0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.logo-text strong { color: var(--accent); font-weight: 800; }

.header-tagline {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-weight: 300;
  letter-spacing: 0.03em;
}
@media (max-width: 480px) { .header-tagline { display: none; } }


/* ==============================================================
   MAIN LAYOUT
   ============================================================== */
.main {
  flex: 1;
  padding: clamp(24px, 4vw, 56px) clamp(16px, 4vw, 48px);
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}


/* ==============================================================
   CREDENTIALS CARD
   ============================================================== */
.credentials-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--ease);
}
.credentials-card:hover { border-color: #3a4a5c; }

/* Header row of the card */
.credentials-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  cursor: pointer;
  user-select: none;
}

.cred-icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex-shrink: 0;
}

.credentials-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

/* Collapse / expand toggle */
.toggle-creds {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--ease), background var(--ease), transform var(--ease);
}
.toggle-creds svg { width: 18px; height: 18px; }
.toggle-creds:hover { color: var(--accent); background: rgba(61,214,200,0.07); }

/* Rotated state when collapsed */
.toggle-creds.collapsed { transform: rotate(180deg); }

/* Body of credentials (collapsible) */
.credentials-body {
  padding: 0 22px 20px;
  border-top: 1px solid var(--border);
  /* Smooth collapse animation via max-height trick */
  max-height: 300px;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.25s ease,
              opacity 0.25s ease;
  opacity: 1;
}
.credentials-body.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

.credentials-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 14px 0 16px;
  line-height: 1.6;
}

/* 2-column grid for credential inputs */
.creds-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 560px) { .creds-grid { grid-template-columns: 1fr; } }

/* Form group: label + input */
.form-group { display: flex; flex-direction: column; gap: 6px; }

label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.required { color: var(--accent); }

/* Input wrapper for password toggle */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

/* Shared input styles */
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 10px 40px 10px 13px; /* right padding for eye btn */
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  transition: border-color var(--ease), box-shadow var(--ease);
  outline: none;
}
input[type="text"] { padding-right: 13px; } /* no eye btn */

input::placeholder { color: var(--text-dim); }

input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(61,214,200,0.12);
}

/* Show/hide API key toggle */
.eye-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  transition: color var(--ease);
  padding: 2px;
}
.eye-btn svg { width: 16px; height: 16px; }
.eye-btn:hover { color: var(--accent); }


/* ==============================================================
   TRANSLATOR CARD
   ============================================================== */
.translator-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}


/* ── Language Row ── */
.lang-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.lang-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 140px;
}

/* Select dropdown */
select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8fa3' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 9px 36px 9px 12px;
  cursor: pointer;
  transition: border-color var(--ease), box-shadow var(--ease);
  outline: none;
  width: 100%;
}
select:hover { border-color: #3a4a5c; }
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(61,214,200,0.12);
}

/* Swap button */
.swap-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-bottom: 1px;            /* align with select */
  transition: background var(--ease), color var(--ease),
              border-color var(--ease), transform var(--ease);
}
.swap-btn svg { width: 16px; height: 16px; }
.swap-btn:hover {
  background: rgba(61,214,200,0.1);
  color: var(--accent);
  border-color: var(--accent);
  transform: rotate(180deg);
}


/* ── Text Panels Row ── */
.text-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* Separator line between panels */
  gap: 0;
}
@media (max-width: 640px) {
  .text-row { grid-template-columns: 1fr; }
}

/* Individual text panel */
.text-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 260px;
}

/* Divider between input and output panels */
.input-panel {
  border-right: 1px solid var(--border);
}
@media (max-width: 640px) {
  .input-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

/* Panel header: label + actions */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.panel-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.char-count {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* Textarea */
.text-area {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  padding: 16px;
  outline: none;
  transition: background var(--ease);
  width: 100%;
}
.text-area::placeholder { color: var(--text-dim); }
.text-area:focus { background: rgba(255,255,255,0.015); }

/* Output area: slightly different tint */
.output-area {
  color: var(--accent);
  cursor: default;
}
.output-area::placeholder { color: var(--text-dim); }

/* Clear button (absolute in input panel) */
.clear-btn {
  position: absolute;
  top: 46px;           /* just below panel-header */
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  display: flex;
  padding: 4px;
  border-radius: 50%;
  transition: color var(--ease), background var(--ease);
  opacity: 0;          /* hidden until there's text */
  pointer-events: none;
}
.clear-btn svg { width: 14px; height: 14px; }
.clear-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
.clear-btn:hover { color: var(--danger); background: rgba(248,113,113,0.1); }

/* Detected language badge */
.detected-badge {
  position: absolute;
  bottom: 10px;
  left: 14px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--ease), transform var(--ease);
}
.detected-badge.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Copy button */
.copy-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  padding: 3px 10px;
  transition: all var(--ease);
}
.copy-btn svg { width: 13px; height: 13px; }
.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(61,214,200,0.07);
}
.copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
  background: rgba(74,222,128,0.07);
}


/* ── Actions Row ── */
.actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

/* Status message area */
.status-area {
  font-size: 0.82rem;
  color: var(--text-muted);
  flex: 1;
  min-height: 1.2em;
}
.status-area.error { color: var(--danger); }
.status-area.success { color: var(--success); }

/* Main Translate button */
.translate-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #0d1117;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  border: none;
  border-radius: 10px;
  padding: 11px 28px;
  cursor: pointer;
  transition: background var(--ease), transform var(--ease), box-shadow var(--ease);
  box-shadow: 0 4px 18px rgba(61,214,200,0.25);
  white-space: nowrap;
}
.translate-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(61,214,200,0.35);
}
.translate-btn:active {
  transform: translateY(0);
  box-shadow: none;
}
.translate-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Loading spinner */
.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(13,17,23,0.3);
  border-top-color: #0d1117;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner.active { display: inline-block; }

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


/* ==============================================================
   FOOTER
   ============================================================== */
.footer {
  text-align: center;
  padding: 20px;
  font-size: 0.73rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  margin-top: auto;
}


/* ==============================================================
   RESPONSIVE TWEAKS
   ============================================================== */
@media (max-width: 480px) {
  .lang-row { padding: 14px 14px 12px; }
  .translate-btn { width: 100%; justify-content: center; }
  .actions-row { flex-direction: column-reverse; align-items: stretch; }
  .status-area { text-align: center; }
}

/* ── Fade-in animation for the whole app ── */
.main { animation: fadeUp 0.5s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}