/* ============================================================
   GALIA Traducción — main stylesheet
   Pure CSS, no frameworks. System font stack, offline-friendly.
   ============================================================ */

:root {
  --color-bg: #f0f4f8;
  --color-surface: #ffffff;
  --color-panel: #f8f9fa;
  --color-border: #dde3ea;
  --color-border-soft: #e8ebef;
  --color-text: #202124;
  --color-text-muted: #5f6368;
  --color-accent: #77aad6;
  --color-accent-dark: #5d95c9;
  --color-error: #d93025;
  --color-disabled: #c4c9cf;
  --color-scrollbar: #b8c2cc;
  --radius-card: 12px;
  --radius-control: 8px;
}

/* --- Reset / base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Thin scrollbars --- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-scrollbar) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-scrollbar);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-muted);
}

/* --- Visible focus for keyboard navigation --- */
button:focus-visible,
select:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

textarea:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

/* --- Header --- */
.app-header {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.app-header__inner {
  max-width: 1530px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
}

.app-logo {
  width: auto;
  display: block;
}

/* --- Main / card --- */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 1530px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
}

.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* --- Language selector row --- */
.lang-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}

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

.lang-field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.detected-lang {
  font-weight: 400;
  color: var(--color-accent-dark);
}

select {
  width: 100%;
  font: inherit;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease;
}

select:hover {
  background-color: var(--color-bg);
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
}

/* --- Swap button (circular, borderless) --- */
.swap-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background-color: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.swap-btn:hover:not(:disabled) {
  background-color: var(--color-bg);
  color: var(--color-accent-dark);
}

.swap-btn:disabled {
  cursor: not-allowed;
  color: var(--color-disabled);
}

/* --- Panels (source / target), full height --- */
.panels {
  flex: 1;
  display: flex;
  gap: 16px;
  position: relative;
}

.panel {
  flex: 1 1 650px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--color-panel);
  border: 1px solid var(--color-border-soft);
  border-radius: 10px;
  overflow: hidden;
}

.panel__label {
  padding: 12px 14px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.panel textarea {
  flex: 1 1 auto;
  width: 100%;
  min-height: 200px;
  border: none;
  background: transparent;
  resize: vertical;
  padding: 8px 14px;
  font: inherit;
  color: var(--color-text);
}

.panel textarea::placeholder {
  color: #9aa0a6;
}

.panel textarea[readonly] {
  cursor: text;
}

/* --- Tiny panel footers --- */
.panel__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 14px 5px;
  border-top: 1px solid var(--color-border-soft);
  background-color: var(--color-surface);
  border-radius: 0 0 10px 10px;
}

.panel--source .panel__footer {
  justify-content: flex-start;
}

.panel--target .panel__footer {
  justify-content: flex-end;
}

.char-count {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* --- Busy overlay (while translating) --- */
.busy-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(32, 33, 36, 0.25);
  border-radius: 10px;
  z-index: 5;
  pointer-events: none;
}

/* --- Buttons --- */
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  padding: 9px 20px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease;
}

.btn:disabled {
  cursor: not-allowed;
}

.btn--primary {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
}

.btn--primary:hover:not(:disabled) {
  background-color: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
}

.btn--primary:disabled {
  background-color: var(--color-disabled);
  border-color: var(--color-disabled);
  color: #ffffff;
}

.btn--secondary {
  background-color: var(--color-surface);
  border-color: var(--color-border);
  color: #3c4043;
}

.btn--secondary:hover:not(:disabled) {
  background-color: var(--color-bg);
  color: var(--color-accent-dark);
}

.btn--secondary:disabled {
  color: var(--color-disabled);
}

/* --- Status line (target panel footer) --- */
.status {
  margin: 0;
  flex: 1 1 auto;
  min-height: 1.2em;
  font-size: 12px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status--error {
  color: var(--color-error);
}

.status--info {
  color: var(--color-text-muted);
}

/* --- Spinner (shown while translating) --- */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1.5s;
  }
}

/* --- Mobile (phones and small tablets, both orientations):
     everything fits the viewport — the two panels share the full height --- */
@media (max-width: 900px) {
  body {
    min-height: 0;
    height: 100vh;
    height: 100dvh;
  }

  .app-main {
    min-height: 0;
    padding: 16px 14px;
  }

  .card {
    min-height: 0;
    padding: 14px;
  }

  .lang-row {
    gap: 8px;
  }

  .panels {
    flex-direction: column;
    min-height: 0;
  }

  .panel {
    flex: 1 1 0;
    min-height: 0;
  }

  .panel textarea {
    min-height: 0;
    resize: none;
  }
}
