:root {
  --blue: #2879d0;
  --blue-dark: #155184;
  --blue-soft: #eef6ff;
  --title-blue: #164e7d;
  --text: #0f1720;
  --muted: #5f6470;
  --line: #d8d8d8;
  --field-border: #cfcfcf;
  --bg: #eef1f4;
  --white: #ffffff;
  --error: #b00020;
  --success: #1f7a3f;
  --panel-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
}

.page {
  min-height: 100vh;
  padding: 12px 22px 42px;
}

.card {
  max-width: 750px;
  margin: 0 auto;
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.14);
  padding: 48px 29px 48px;
}

h1 {
  margin: 0 0 28px;
  color: var(--title-blue);
  text-align: center;
  font-size: 34px;
  line-height: 1.15;
  font-weight: 700;
}

.form-group {
  margin-bottom: 24px;
}

.form-group > label,
.priority-block > label,
.photo-group > label {
  display: block;
  margin-bottom: 8px;
  color: #0d1721;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 700;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  border: 1px solid var(--field-border);
  border-radius: 5px;
  background: #ffffff;
  color: #1c2430;
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input[type="text"],
input[type="password"] {
  height: 44px;
  padding: 10px 12px;
}

textarea {
  min-height: 170px;
  padding: 12px;
  resize: vertical;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
  color: #6e7580;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(40, 121, 208, 0.12);
}

.description-location {
  background: #f6f6f6 !important;
  font-style: italic;
  color: #111111;
}

.functional-select {
  position: relative;
  width: 100%;
}

.functional-input-wrap {
  position: relative;
}

#functionalSearch {
  padding-right: 44px;
}

.clear-button {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #777777;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: none;
}

.clear-button:hover {
  color: var(--blue);
  background: var(--blue-soft);
}

.clear-button.visible {
  display: block;
}


.functional-selected-description {
  display: none;
  margin-top: 8px;
  padding: 0 2px;
  color: #666d75;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 400;
}

.functional-selected-description.visible {
  display: block;
}

.dropdown-panel {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 50;
  max-height: 420px;
  overflow: auto;
  background: #ffffff;
  border: 1px solid #d7e4f2;
  border-radius: 0 0 8px 8px;
  box-shadow: var(--panel-shadow);
  padding: 8px 0;
}

.functional-select.open .dropdown-panel {
  display: block;
}

.dropdown-status,
.dropdown-empty {
  padding: 14px 16px;
  color: var(--muted);
  font-size: 15px;
}

.tree-row,
.search-row {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr 34px;
  gap: 14px;
  align-items: center;
  min-height: 44px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  color: #5f646b;
  cursor: pointer;
  font-size: 17px;
}

.tree-row:hover,
.search-row:hover {
  background: var(--blue-soft);
}

.tree-row.inactive-row,
.search-row.inactive-row {
  cursor: not-allowed;
  background: #ffffff;
}

.tree-row.inactive-row:hover,
.search-row.inactive-row:hover {
  background: #f5f6f8;
}

.tree-row.inactive-row .toggle-button {
  cursor: pointer;
}

.tree-row.root-row {
  grid-template-columns: 1fr 34px;
  gap: 10px;
  min-height: 42px;
  border-bottom: 0;
  color: #6d7278;
  font-size: 18px;
  font-weight: 500;
}

.tree-row.root-row .tree-description {
  display: none;
}

.tree-code,
.search-code {
  white-space: nowrap;
  color: var(--blue);
  font-weight: 600;
}

.inactive-row .tree-code,
.inactive-row .search-code {
  color: #8a8f96;
  font-weight: 500;
}

.tree-description,
.search-description {
  color: #777d85;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, transform 0.12s ease;
}

.toggle-button::before {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 3px solid var(--blue);
  border-bottom: 3px solid var(--blue);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.12s ease;
}

.toggle-button.expanded::before {
  transform: rotate(225deg) translate(-2px, -2px);
}

.toggle-button:hover {
  background: var(--blue-soft);
}

.toggle-placeholder {
  width: 30px;
  height: 30px;
}

.search-path,
.selected-path {
  display: none;
}

.priority-group {
  display: flex;
  align-items: center;
  gap: 34px;
  flex-wrap: wrap;
  margin-top: 2px;
  padding-left: 0;
}

.priority-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #111827;
  font-size: 16px;
  font-weight: 400;
  cursor: pointer;
}

.priority-option input {
  width: 14px;
  height: 14px;
  margin: 0;
}

input[type="file"] {
  width: 100%;
  font-size: 14px;
}

.form-actions {
  margin-top: 24px;
}

.submit-button {
  width: 100%;
  min-height: 49px;
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #ffffff;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
}

.submit-button:hover {
  background: #1f6fc4;
}

.form-message {
  margin-top: 14px;
  min-height: 20px;
  font-size: 14px;
}

.form-message.error {
  color: var(--error);
}

.form-message.success {
  color: var(--success);
}

@media (max-width: 720px) {
  .page {
    padding: 10px 10px 32px;
  }

  .card {
    padding: 34px 18px 36px;
  }

  h1 {
    font-size: 30px;
  }

  .tree-row,
  .search-row {
    grid-template-columns: minmax(105px, max-content) 1fr 30px;
    gap: 10px;
    font-size: 15px;
  }

  .tree-row.root-row {
    grid-template-columns: 1fr 30px;
    font-size: 16px;
  }

  .priority-group {
    gap: 24px;
  }
}


/* Correction INAC / couleurs de la liste déroulante */
.tree-row.active-row .tree-code,
.search-row.active-row .search-code {
  color: var(--blue) !important;
  font-weight: 700 !important;
}

.tree-row.active-row .tree-description,
.search-row.active-row .search-description {
  color: #777d85 !important;
  font-weight: 400 !important;
}

.tree-row.inactive-row,
.search-row.inactive-row {
  cursor: not-allowed !important;
  background: #ffffff;
}

.tree-row.inactive-row .tree-code,
.search-row.inactive-row .search-code {
  color: #8a8f96 !important;
  font-weight: 500 !important;
}

.tree-row.inactive-row .tree-description,
.search-row.inactive-row .search-description {
  color: #9aa0a6 !important;
  font-weight: 400 !important;
}

.tree-row.inactive-row:hover,
.search-row.inactive-row:hover {
  background: #f5f6f8 !important;
}

.tree-row.inactive-row .toggle-button {
  cursor: pointer !important;
}

.toggle-button::before {
  border-right-color: var(--blue) !important;
  border-bottom-color: var(--blue) !important;
}


/* Correction fermeture du menu déroulant */
.functional-select:not(.open) .dropdown-panel {
  display: none !important;
}

.functional-select.open .dropdown-panel {
  display: block !important;
}


.photo-message {
  margin-top: 8px;
  min-height: 18px;
  color: #666d75;
  font-size: 13px;
  line-height: 1.35;
}

.photo-message.error {
  color: var(--error);
}

.photo-message.success {
  color: var(--success);
}

.photo-message.info {
  color: #4f5b66;
}


/* Connexion */
.logout-bar {
  max-width: 750px;
  margin: 14px auto 0;
  padding: 0 22px;
  text-align: right;
  font-size: 14px;
}

.logout-bar a {
  color: var(--blue-dark);
  text-decoration: none;
  font-weight: 700;
}

.logout-bar a:hover {
  text-decoration: underline;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 34px;
}

.login-card {
  max-width: 430px;
  padding: 42px 30px;
}

.login-intro {
  margin: -12px 0 24px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.login-error {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #f0b8c0;
  border-radius: 5px;
  background: #fff4f5;
  color: var(--error);
  font-weight: 700;
}
