/* ==========================================================================
   M10 : CODEX MORBUS
   Préfixe : codex-
   ========================================================================== */

/* ---------- MISE EN PAGE GLOBALE ---------- */

.codex-screen {
  display: flex;
  gap: 0;
  height: 100%;
  min-height: 0;
  background: #FFFFFF;
  border: 1px solid #E4E6E2;
  border-radius: 12px;
  overflow: hidden;
  opacity: 0;
  animation: codex-fade-in 320ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ---------- PANNEAU GAUCHE ---------- */

.codex-left {
  width: 300px;
  flex-shrink: 0;
  height: 100%;
  border-right: 1px solid #E4E6E2;
  display: flex;
  flex-direction: column;
  background: #FAFAFA;
}

/* Zone recherche et filtres */
.codex-search-area {
  padding: 16px 14px 12px;
  border-bottom: 1px solid #E4E6E2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #FFFFFF;
}

.codex-search-wrap {
  position: relative;
}

.codex-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #9CA09A;
  pointer-events: none;
  display: flex;
  align-items: center;
}

.codex-search-input {
  width: 100%;
  height: 36px;
  padding: 0 10px 0 34px;
  background: #F8F9FA;
  border: 1px solid #E4E6E2;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #3A3E38;
  box-sizing: border-box;
  transition: all 150ms ease;
}

.codex-search-input::placeholder {
  color: #9CA09A;
}

.codex-search-input:focus {
  background: #FFFFFF;
  border-color: #4A90E2;
  outline: none;
  box-shadow: 0 0 0 3px #E8F1FB;
}

.codex-filters {
  display: flex;
  gap: 6px;
}

.codex-select {
  flex: 1;
  height: 32px;
  padding: 0 8px;
  border: 1px solid #E4E6E2;
  border-radius: 7px;
  font-size: 11px;
  font-family: inherit;
  color: #64695F;
  background: #F8F9FA;
  cursor: pointer;
  transition: border-color 150ms ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239CA09A' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  padding-right: 22px;
}

.codex-select:focus {
  border-color: #4A90E2;
  outline: none;
}

.codex-results-count {
  font-size: 10px;
  color: #9CA09A;
  font-weight: 500;
  padding: 0 2px;
  letter-spacing: 0.3px;
}

/* Liste des maladies */
.codex-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 0;
}

.codex-list::-webkit-scrollbar {
  width: 4px;
}

.codex-list::-webkit-scrollbar-track {
  background: transparent;
}

.codex-list::-webkit-scrollbar-thumb {
  background: #E4E6E2;
  border-radius: 2px;
}

.codex-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 120ms ease;
  border-left: 3px solid transparent;
  opacity: 0;
  animation: codex-fade-in 350ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.codex-list-item:hover {
  background: #F2F3F5;
}

.codex-list-item.is-selected {
  background: #EEF5FC;
  border-left-color: #4A90E2;
}

.codex-list-item__main {
  flex: 1;
  min-width: 0;
}

.codex-list-item__name {
  font-size: 12px;
  font-weight: 600;
  color: #3A3E38;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.codex-list-item.is-selected .codex-list-item__name {
  color: #1A5DA0;
}

.codex-list-item__codes {
  font-size: 10px;
  color: #9CA09A;
  font-weight: 500;
  margin-top: 2px;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.2px;
}

.codex-list-item__badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.codex-list-empty {
  padding: 32px 20px;
  text-align: center;
  color: #9CA09A;
  font-size: 13px;
}

/* ---------- PANNEAU DROIT (DÉTAIL) ---------- */

.codex-right {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.codex-detail {
  padding: 28px 32px;
  flex: 1;
}

.codex-detail.is-entering {
  animation: codex-detail-in 280ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* En-tête détail */
.codex-detail__header {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #F2F2F2;
}

.codex-detail__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.codex-detail__title {
  font-family: 'Prompt', sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: #3A3E38;
  line-height: 1.25;
  margin: 0;
}

.codex-detail__action {
  flex-shrink: 0;
}

.codex-detail__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.codex-code-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.3px;
}

.codex-code-badge--cim10 {
  background: #E8F1FB;
  color: #1A5DA0;
}

.codex-code-badge--cim11 {
  background: #EDE3F4;
  color: #6B3FA0;
}

.codex-code-badge__label {
  font-family: inherit;
  font-size: 9px;
  font-weight: 600;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.codex-system-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.codex-freq-badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Description */
.codex-detail__desc {
  font-size: 13px;
  color: #64695F;
  line-height: 1.6;
  margin-bottom: 0;
}

/* Sections */
.codex-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.codex-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.codex-section--full {
  grid-column: 1 / -1;
}

.codex-section__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #9CA09A;
  padding-bottom: 6px;
  border-bottom: 1px solid #F2F2F2;
}

.codex-section__icon {
  color: currentColor;
  display: flex;
  align-items: center;
}

/* Symptômes (chips) */
.codex-symptom-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.codex-symptom-chip {
  padding: 4px 10px;
  background: #FBF1DD;
  color: #8B6914;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  opacity: 0;
  animation: codex-fade-in 350ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Examens et traitements (liste numérotée) */
.codex-item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.codex-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  opacity: 0;
  animation: codex-fade-in 350ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.codex-item__num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #E8F1FB;
  color: #4A90E2;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.codex-item__body {
  flex: 1;
  min-width: 0;
}

.codex-item__label {
  font-size: 12px;
  font-weight: 600;
  color: #3A3E38;
  line-height: 1.35;
}

.codex-item__note {
  font-size: 11px;
  color: #9CA09A;
  margin-top: 2px;
  line-height: 1.4;
}

/* Codes apparentés */
.codex-related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.codex-related-code {
  padding: 4px 10px;
  background: #F2F3F5;
  color: #64695F;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
  font-family: 'Courier New', monospace;
  opacity: 0;
  animation: codex-fade-in 350ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.codex-related-code:hover {
  background: #E8F1FB;
  color: #1A5DA0;
}

/* Placeholder si pas de détail disponible */
.codex-no-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  gap: 12px;
  color: #9CA09A;
}

.codex-no-detail__icon {
  width: 48px;
  height: 48px;
  background: #F2F2F2;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9CA09A;
}

.codex-no-detail__text {
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
}

/* ---------- ANIMATIONS ---------- */

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

@keyframes codex-detail-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---------- TABLETTE ---------- */

.frame--tablet .codex-left {
  width: 240px;
}

.frame--tablet .codex-detail {
  padding: 18px 20px;
}

.frame--tablet .codex-detail__title {
  font-size: 17px;
}

.frame--tablet .codex-sections {
  grid-template-columns: 1fr;
}

.frame--tablet .codex-section--full {
  grid-column: 1;
}

.frame--tablet .codex-list {
  max-height: 600px;
}
