/* --- Messages List Styling --- */

.messages-list {
  padding: 0;
  list-style: none;
}

/* Field and form-specific message list styling */
.field .messages-list,
.form-wrapper .messages-list {
  margin-bottom: 0;
}

/* --- Base Message Styling --- */

.messages {
  box-sizing: border-box;
  padding: 1rem 1rem 1rem calc(1.5rem - 5px); /* LTR padding */
  border-width: 1px; 
  border-style: solid;
  border-color: #212121;
  border-radius: 2px;
  margin-bottom: 5px;
}

/* RTL adjustments for message padding and border */
[dir="rtl"] .messages {
  padding-right: calc(1.5rem - 5px);
  padding-left: 1.5rem;
  border-right-width: 5px;
  border-left-width: 0;
}

/* --- Message Types --- */

/* Error message styling */
.messages--error {
  background-color: #fcf4f2;
  /* Uncomment for custom border color */
  /* border-color: #e34f4f; */
}

/* Status message styling */
.messages--status {
  border-color: #42a877;
  background-color: #f3faef;
}

/* Warning message styling */
.messages--warning {
  border-color: #e0ac00;
  background-color: #fdf8ed;
}

/* --- Message Title and Header Styling --- */

.messages__title {
  margin: 0 0 0 2.5rem; /* LTR margin */
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
}

[dir="rtl"] .messages__title {
  margin-right: 2.5rem;
  margin-left: 0;
}

/* Placeholder styling within messages */
.messages .placeholder {
  display: inline;
  min-height: inherit;
  vertical-align: inherit;
  cursor: inherit;
  background-color: transparent;
  opacity: inherit;
}

/* Error message icon */
.messages--error .messages__header {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 14 14'%3E%3Cpath d='M3 11.1931L11.4501 2.99995' stroke='%23e34f4f' stroke-width='2'/%3E%3Ccircle cx='7' cy='7' r='6' fill='none' stroke='%23e34f4f' stroke-width='2'/%3E%3C/svg%3E%0A") no-repeat center left; /* LTR */
}

[dir="rtl"] .messages--error .messages__header {
  background-position: center right;
}

/* Status message icon */
.messages--status .messages__header {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 13'%3E%3Cpath d='M2 6.57143L5.6 10L14 2' fill='none' stroke='%2342a877' stroke-width='3'/%3E%3C/svg%3E%0A") no-repeat center left; /* LTR */
}

[dir="rtl"] .messages--status .messages__header {
  background-position: center right;
}

/* Warning message icon */
.messages--warning .messages__header {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 4 14' fill='%23e0ac00'%3E%3Crect x='0.5' width='3' height='9'/%3E%3Ccircle cx='2' cy='12.5' r='1.5'/%3E%3C/svg%3E%0A") no-repeat center left; /* LTR */
}

[dir="rtl"] .messages--warning .messages__header {
  background-position: center right;
}

/* Header container styling */
.messages__header {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

/* --- Content and Link Styling --- */

@media screen and (min-width: 48rem) {
  .messages__content {
    margin-left: 2.5rem; /* LTR margin */
  }

  [dir="rtl"] .messages__content {
    margin-right: 2.5rem;
    margin-left: 0;
  }
}

/* Message link styling */
.messages a {
  text-decoration: underline;
}

/* --- Code Block and List Item Styling --- */

.messages pre {
  margin: 0;
}

.messages__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Spacing between list items */
.messages__item + .messages__item {
  margin-top: 0.75rem;
}

/* --- Accessibility Styling for High Contrast Mode --- */

@media screen and (-ms-high-contrast: active) {
  .messages {
    border-width: 1px 1px 1px 5px; /* LTR border width */
  }
  [dir="rtl"] .messages {
    border-right-width: 5px;
    border-left-width: 1px;
  }
  .messages__header {
    filter: grayscale(1) brightness(1.5) contrast(10);
  }
}
