/* ═══════════════════════════════════════════════════════════════════
   RAKJO Traductor de Documentos — Hoja de estilos principal
   Paleta: verde bosque #2d4a22, sage #8db87c, crema #f6f9f3
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --verde:        #2d4a22;
  --verde-dark:   #1e3217;
  --verde-hover:  #3a5f2c;
  --sage:         #8db87c;
  --sage-light:   #b5d4a7;
  --sage-fog:     #d4e4c8;
  --cream:        #f6f9f3;
  --cream-dark:   #edf2e8;
  --white:        #ffffff;
  --text:         #1a2a14;
  --text-muted:   #5a7050;
  --border:       #d0dfc8;
  --red:          #c0392b;
  --red-light:    #fde8e8;
  --shadow-sm:    0 1px 3px rgba(45,74,34,.10);
  --shadow-md:    0 4px 16px rgba(45,74,34,.14);
  --shadow-lg:    0 8px 32px rgba(45,74,34,.18);
  --radius:       10px;
  --radius-sm:    6px;
  --radius-lg:    16px;
  --header-h:     60px;
  --transition:   0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--verde); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }

/* ── Logo / Brand ─────────────────────────────────────────────────── */
.logo-mark {
  width: 44px; height: 44px;
  background: var(--verde); color: var(--white);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 800; flex-shrink: 0;
}
.logo-mark.sm { width: 32px; height: 32px; font-size: 1rem; }
.logo-text  { display: flex; flex-direction: column; line-height: 1.1; }
.logo-name  { font-size: 1.2rem; font-weight: 800; color: var(--verde); letter-spacing: -.5px; }
.logo-sub   { font-size: .7rem; color: var(--text-muted); font-weight: 500;
              text-transform: uppercase; letter-spacing: .5px; }

/* ── Auth pages ───────────────────────────────────────────────────── */
.auth-page {
  background: linear-gradient(135deg, var(--verde) 0%, #4a7a3a 100%);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
}
.auth-container { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.auth-card {
  width: 100%; background: var(--white);
  border-radius: var(--radius-lg); padding: 2.5rem 2rem; box-shadow: var(--shadow-lg);
}
.auth-logo     { display: flex; align-items: center; gap: .75rem; margin-bottom: 2rem; }
.auth-title    { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-bottom: .25rem; }
.auth-subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.75rem; }
.auth-footer   { color: rgba(255,255,255,.6); font-size: .8rem; text-align: center; }
.auth-form     { display: flex; flex-direction: column; gap: 1rem; }

/* ── App layout ───────────────────────────────────────────────────── */
.app-page { background: var(--cream); min-height: 100vh; }

.app-header {
  height: var(--header-h);
  background: linear-gradient(135deg, var(--verde) 0%, var(--verde-hover) 100%);
  border-bottom: none;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.20);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 1.25rem;
  height: 100%; display: flex; align-items: center; gap: 1rem;
}
.header-brand  { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.brand-name    { font-size: 1.05rem; font-weight: 700; color: #fff; }
.brand-sub     { font-size: .8rem; font-weight: 400; color: rgba(255,255,255,.7); margin-left: .25rem; }
.header-user   { display: flex; align-items: center; gap: .5rem; margin-left: .5rem; }
.user-name     { font-size: .85rem; color: rgba(255,255,255,.8); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Elementos dentro del header: forzar colores claros */
.app-header .btn-icon  { color: rgba(255,255,255,.85); }
.app-header .btn-icon:hover  { background: rgba(255,255,255,.15); color: #fff; }
.app-header .btn-ghost { color: rgba(255,255,255,.85); }
.app-header .btn-ghost:hover { background: rgba(255,255,255,.15); color: #fff; }
.app-header button[type="submit"] { color: rgba(255,255,255,.85); border-color: rgba(255,255,255,.3); }
.app-header button[type="submit"]:hover { background: rgba(255,255,255,.15); }

.app-main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem; }

/* ── Action bar ───────────────────────────────────────────────────── */
.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.action-bar-left  { display: flex; align-items: baseline; gap: .75rem; }
.action-bar-right { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.page-title  { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.doc-counter { font-size: .85rem; color: var(--text-muted); }

/* ── Language chip (quick-pick) ──────────────────────────────────── */
.lang-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem .9rem;
  background: var(--sage-fog);
  border: 1.5px solid var(--sage-light);
  border-radius: 20px;
  font-size: .88rem; font-weight: 600; color: var(--verde-dark);
  cursor: pointer; transition: var(--transition);
  user-select: none;
}
.lang-chip:hover    { background: var(--sage-light); }
.lang-chip-icon     { font-size: 1rem; }
.lang-chip-arrow    { font-size: .7rem; color: var(--text-muted); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; padding: .55rem 1.1rem;
  border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600;
  cursor: pointer; border: none; transition: var(--transition); white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary  { background: var(--verde); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--verde-hover); }

.btn-translate {
  background: var(--sage); color: var(--verde-dark);
  padding: .65rem 1.5rem; font-size: 1rem; box-shadow: var(--shadow-sm);
}
.btn-translate:hover:not(:disabled) {
  background: var(--sage-light); box-shadow: var(--shadow-md); transform: translateY(-1px);
}
.btn-translate:active { transform: translateY(0); }

.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--verde); color: var(--verde); background: var(--cream); }
.btn-ghost   { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--cream-dark); color: var(--text); }
.btn-danger  { background: var(--red-light); color: var(--red); border: 1.5px solid #f5c6c4; }
.btn-danger:hover { background: #f9d0ce; }

.btn-full { width: 100%; }
.btn-sm   { padding: .35rem .75rem; font-size: .82rem; }
.btn-xs   { padding: .2rem .55rem; font-size: .78rem; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 1rem; color: var(--text-muted); transition: var(--transition);
}
.btn-icon:hover { background: var(--cream-dark); color: var(--text); }

/* ── Forms ────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--text); }
.form-group small { font-size: .78rem; color: var(--text-muted); }
input[type="text"], input[type="password"], input[type="email"],
input[type="number"], textarea, select {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: .6rem .85rem; font-size: .9rem; color: var(--text);
  background: var(--white); transition: border-color var(--transition); width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(141,184,124,.2);
}
.input-sm  { padding: .4rem .65rem; font-size: .85rem; }
.select-sm { padding: .4rem .65rem; font-size: .85rem; width: 100%; }
.divider   { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.required  { color: var(--red); }

/* Toggle */
.toggle-row { display: flex; align-items: center; gap: .75rem; font-size: .9rem; color: var(--text); }
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 24px; transition: var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; left: 3px; bottom: 3px;
  background: var(--white); border-radius: 50%; transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--sage); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Panels (inbox / outbox) ──────────────────────────────────────── */
.panels-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: stretch;
}
@media (max-width: 700px) { .panels-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
}
.panel-header {
  display: flex; align-items: center; gap: .6rem;
  padding: .85rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--cream); flex-wrap: wrap;
}
.panel-title {
  display: flex; align-items: center; gap: .4rem;
  font-weight: 600; font-size: .92rem; color: var(--text); flex: 1;
}
.panel-icon  { font-size: 1rem; }
.formats-hint  { font-size: .72rem; color: var(--text-muted); margin-right: auto; }
.formats-small { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

.drop-zone {
  flex: 1; min-height: 280px; position: relative; padding: .5rem;
  transition: background var(--transition);
}
.drop-zone.drag-over { background: var(--sage-fog); }
.outbox-area { flex: 1; min-height: 280px; padding: .5rem; position: relative; }

.drop-hint {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: .5rem; color: var(--text-muted); text-align: center;
  padding: 2rem; pointer-events: none;
}
.drop-hint.hidden-hint { display: none; }
.drop-icon { font-size: 2.5rem; opacity: .5; }
.drop-hint p { font-size: .88rem; line-height: 1.55; }

.file-list { list-style: none; display: flex; flex-direction: column; gap: .35rem; }
.file-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .75rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--white); transition: var(--transition);
}
.file-item:hover { border-color: var(--sage-light); background: var(--cream); }
.file-icon    { font-size: 1.2rem; flex-shrink: 0; }
.file-info    { flex: 1; min-width: 0; }
.file-name    { font-size: .85rem; font-weight: 500; color: var(--text);
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta    { font-size: .75rem; color: var(--text-muted); }
.file-actions { display: flex; gap: .3rem; flex-shrink: 0; }
.file-format-badge {
  font-size: .68rem; font-weight: 700; padding: .1rem .4rem;
  background: var(--sage-fog); color: var(--verde-dark);
  border-radius: 4px; flex-shrink: 0; text-transform: uppercase;
}

.file-item.translated { border-color: var(--sage-light); background: var(--sage-fog); }
.file-item.translated .file-name { color: var(--verde); }

/* ── Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--border); border-radius: 10px;
  font-size: .72rem; font-weight: 700; color: var(--text-muted);
}
.badge-green { background: var(--sage-light); color: var(--verde-dark); }

/* ── Alerts ───────────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: .88rem; line-height: 1.4; }
.alert-error   { background: var(--red-light); color: var(--red); border: 1px solid #f5c6c4; }
.alert-info    { background: #e8f4fd; color: #004085; border: 1px solid #bee5eb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

/* ── Toast ────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%);
  background: var(--text); color: var(--white);
  padding: .75rem 1.5rem; border-radius: 999px;
  font-size: .88rem; font-weight: 500;
  box-shadow: var(--shadow-md); z-index: 9999;
  max-width: 90vw; text-align: center;
  animation: toastIn .2s ease;
}
.toast-success { background: var(--verde); }
.toast-error   { background: var(--red); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Preferences panel (slide-over) ──────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.3);
  z-index: 200; backdrop-filter: blur(2px);
}
.prefs-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(500px, 100vw); background: var(--white);
  z-index: 201; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.prefs-panel.hidden { display: none; }

.prefs-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--cream);
}
.prefs-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.prefs-body {
  flex: 1; overflow-y: auto; padding: 1.25rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.prefs-section { display: flex; flex-direction: column; gap: .5rem; }
.prefs-label   { font-size: .85rem; font-weight: 700; color: var(--text); }
.prefs-hint    { font-size: .78rem; color: var(--text-muted); }
.prefs-footer  { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }

/* ── Language selector ────────────────────────────────────────────── */
.lang-search-wrap { position: relative; }
.lang-list-scroll {
  max-height: 260px; overflow-y: auto;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--white);
}
.lang-group-header {
  padding: .4rem .75rem;
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted);
  background: var(--cream); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}
.lang-option {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .85rem; cursor: pointer; transition: background var(--transition);
  font-size: .9rem;
}
.lang-option:hover    { background: var(--cream); }
.lang-option.selected { background: var(--sage-fog); font-weight: 600; color: var(--verde); }
.lang-option.popular  { }
.lang-popular-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sage); flex-shrink: 0;
}
.lang-option-check { margin-left: auto; color: var(--verde); font-size: 1rem; }
.lang-option.hidden-lang { display: none; }

/* ── Language picker modal (quick pick) ──────────────────────────── */
.lang-picker-modal {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 380px;
  max-height: 80vh; display: flex; flex-direction: column;
  animation: fadeIn .18s ease;
}
.lang-picker-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--cream);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.lang-picker-header h3 { font-size: 1rem; font-weight: 700; }
.lang-picker-list {
  flex: 1; overflow-y: auto; padding: .5rem;
  display: flex; flex-direction: column; gap: .25rem;
}
.lang-picker-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .85rem; border-radius: var(--radius-sm);
  cursor: pointer; font-size: .9rem; transition: background var(--transition);
}
.lang-picker-item:hover    { background: var(--cream); }
.lang-picker-item.active   { background: var(--sage-fog); color: var(--verde); font-weight: 600; }
.lang-picker-item.hidden-lang { display: none; }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; backdrop-filter: blur(2px);
}
.signing-modal {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 3rem 2rem; text-align: center; box-shadow: var(--shadow-lg);
  max-width: 400px; width: 100%;
}
.signing-spinner {
  font-size: 3rem; margin-bottom: 1rem;
  animation: spin 2s linear infinite;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.signing-modal h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: .5rem; }
.signing-modal p  { color: var(--text-muted); font-size: .9rem; }
@keyframes fadeIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .auth-card { padding: 2rem 1.25rem; }
  .header-inner { padding: 0 .75rem; gap: .5rem; }
  .brand-sub { display: none; }
  .user-name { display: none; }
  .app-main { padding: 1rem .75rem; }
  .action-bar { gap: .5rem; }
  .btn-translate { padding: .55rem 1rem; font-size: .9rem; }
  .prefs-panel { width: 100vw; }
  .formats-hint { display: none; }
}
