[hidden] { display: none !important; }

:root {
  color-scheme: light dark;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: #11151c;
  color: #f0f4f8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === HEADER === */
header {
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #1f2933, #323f4b);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
}

.brand-logo {
  height: 50px;
  width: auto;
  margin-right: 12px;
  border-radius: 4px;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.header-language-form {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: #d9e2ec;
}

.header-language-form label {
  font-weight: 600;
  font-size: 0.95rem;
}

.header-language-form select {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.35);
  color: #f0f4f8;
  font-size: 0.95rem;
}

.header-language-form select:focus {
  outline: none;
  border-color: #56e6d6;
  box-shadow: 0 0 0 2px rgba(86, 230, 214, 0.25);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: #6e7f97;
  margin-left: auto;
}

.status[data-status='success'] {
  color: #2ec4b6;
}

.status[data-status='error'] {
  color: #ff6b6b;
}

/* === MAIN LAYOUT === */
main {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  padding: 1.5rem 2rem 2rem;
  flex: 1;
  min-height: 0;
}

/* === DUAL PANE (Transcription + Traduction) === */
.dual-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  min-height: 0;
}

.text-pane {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  min-height: 400px;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pane-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pane-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-action {
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.btn-action:hover {
  background: rgba(255, 255, 255, 0.15);
}

.text-content {
  flex: 1;
  padding: 1.25rem;
  font-size: 1.1rem;
  line-height: 1.7;
  color: #e0e8f9;
  overflow-y: auto;
  min-height: 200px;
  outline: none;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.text-content:empty::before {
  content: attr(data-placeholder);
  color: #6e7f97;
  font-style: italic;
}

.text-content:focus {
  background: rgba(86, 230, 214, 0.03);
}

#original-text {
  border-left: 3px solid #56e6d6;
}

#translation-text {
  border-left: 3px solid #9fb3c8;
  color: #a8d8ea;
}

.pane-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.75rem;
}

.char-count {
  color: #6e7f97;
}

.edit-indicator {
  color: #ffb020;
  font-weight: 600;
}

/* === CONTROL PANEL (Sidebar) === */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.panel {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #9fb3c8;
}

/* === GLOSSARY === */
#glossary-panel {
  flex-shrink: 0;
}

#glossary-form {
  margin-bottom: 0.75rem;
}

.glossary-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.glossary-input-row input {
  padding: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.5);
  color: #e2e8f0;
  font-size: 0.85rem;
}

.glossary-input-row input:focus {
  outline: none;
  border-color: #2ec4b6;
  box-shadow: 0 0 0 2px rgba(46, 196, 182, 0.18);
}

.glossary-input-row button {
  padding: 0.5rem 0.75rem;
  background: rgba(46, 196, 182, 0.16);
  color: #56e6d6;
  border: 1px solid rgba(86, 230, 214, 0.35);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

.glossary-input-row button:hover {
  background: rgba(46, 196, 182, 0.24);
}

#glossary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 150px;
  overflow-y: auto;
}

.glossary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 6px;
  font-size: 0.8rem;
}

.glossary-item__term {
  font-weight: 600;
  color: #e2e8f0;
}

.glossary-item__delete {
  padding: 0.2rem 0.4rem;
  background: rgba(244, 63, 94, 0.18);
  color: #ff8899;
  border: 1px solid rgba(255, 136, 153, 0.35);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
}

.glossary-item__delete:hover {
  background: rgba(244, 63, 94, 0.26);
}

/* === HISTORY === */
#history-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  flex: 1;
}

.history-item {
  padding: 0.6rem 0.75rem;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.history-item:hover {
  background: rgba(46, 196, 182, 0.08);
  border-color: rgba(86, 230, 214, 0.25);
}

.history-item__original {
  font-size: 0.8rem;
  color: #e0e8f9;
  margin-bottom: 0.3rem;
  line-height: 1.4;
  padding: 0.25rem;
  border-radius: 4px;
  transition: background 0.2s;
  /* Retirer la limitation de lignes pour permettre l'édition */
  overflow: auto;
  max-height: 200px;
}

.history-item__translation {
  font-size: 0.75rem;
  color: #9fb3c8;
  line-height: 1.4;
  padding: 0.25rem;
  border-radius: 4px;
  transition: background 0.2s;
  /* Retirer la limitation de lignes pour permettre l'édition */
  overflow: auto;
  max-height: 200px;
}

.history-item__original.editing,
.history-item__translation.editing {
  background: rgba(46, 196, 182, 0.1);
  border: 1px solid rgba(86, 230, 214, 0.3);
  outline: none;
}

.history-item__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.history-item__btn {
  font-size: 0.7rem;
  padding: 0.3rem 0.6rem;
  background: rgba(46, 196, 182, 0.15);
  color: #56e6d6;
  border: 1px solid rgba(86, 230, 214, 0.3);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.history-item__btn:hover {
  background: rgba(46, 196, 182, 0.25);
  border-color: rgba(86, 230, 214, 0.5);
}

.history-item__btn--save {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.35);
}

.history-item__btn--save:hover {
  background: rgba(34, 197, 94, 0.28);
  border-color: rgba(134, 239, 172, 0.5);
}

/* Bordure verte pour les phrases corrigées */
.history-item--corrected {
  border: 2px solid rgba(34, 197, 94, 0.6) !important;
  background: rgba(34, 197, 94, 0.08);
}

.history-item--corrected::before {
  content: "✓ Corrigé";
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.65rem;
  color: #86efac;
  background: rgba(34, 197, 94, 0.2);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
}

/* === RESPONSIVE === */
@media (max-width: 1200px) {
  main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .control-panel {
    flex-direction: row;
    gap: 1rem;
  }

  .panel {
    flex: 1;
  }

  #history-panel {
    max-height: 200px;
  }
}

@media (max-width: 900px) {
  .dual-pane {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .text-pane {
    min-height: 250px;
  }
}

@media (max-width: 640px) {
  header {
    padding: 0.75rem 1rem;
  }

  h1 {
    font-size: 1.1rem;
  }

  .brand-logo {
    height: 30px;
  }

  .header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .header-language-form {
    width: 100%;
    justify-content: space-between;
  }

  .status {
    margin-left: 0;
  }

  main {
    padding: 1rem;
    gap: 1rem;
  }

  .control-panel {
    flex-direction: column;
  }

  .text-content {
    font-size: 1rem;
    padding: 1rem;
  }
}

/* === SCROLLBAR STYLING === */
.text-content::-webkit-scrollbar,
#glossary-list::-webkit-scrollbar,
#history-list::-webkit-scrollbar {
  width: 6px;
}

.text-content::-webkit-scrollbar-track,
#glossary-list::-webkit-scrollbar-track,
#history-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.text-content::-webkit-scrollbar-thumb,
#glossary-list::-webkit-scrollbar-thumb,
#history-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 3px;
}

.text-content::-webkit-scrollbar-thumb:hover,
#glossary-list::-webkit-scrollbar-thumb:hover,
#history-list::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

/* === KEYBOARD SHORTCUTS HINT === */
@media (min-width: 900px) {
  main::after {
    content: 'Raccourcis: Ctrl+Shift+C = Copier tout | Ctrl+Shift+R = Reprendre le flux';
    position: fixed;
    bottom: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: #4a5568;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
  }
}
