/* ============= Status & Error Messages (global) =============
 * Drupal 10 renders status messages WITHOUT .messages class — it uses:
 *   <div data-drupal-messages>
 *     <div role="contentinfo" aria-label="Error message">
 *       <div role="alert">        ← present only for errors
 *         <h2 class="visually-hidden">Error message</h2>
 *         {text}
 *       </div>
 *     </div>
 *   </div>
 * We style by structure so the rules work in any language.
 */

/* Hide the screen-reader-only heading and the data-drupal-messages-fallback placeholder */
[data-drupal-messages-fallback] {
  display: none !important;
}
[data-drupal-messages] h2.visually-hidden,
[data-drupal-messages] .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  border: 0 !important;
}

/* Outer wrapper — base card */
[data-drupal-messages] > [role="contentinfo"],
[data-drupal-messages] > [role="alert"],
.messages,
.messages-list {
  position: relative;
  display: block;
  padding: 0.95rem 1.1rem 0.95rem 3rem;
  margin: 0 0 1.25rem;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.45;
  font-weight: 500;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd;
  color: #1e3a8a;
  box-shadow: 0 4px 14px -8px rgba(15, 23, 42, 0.18);
  animation: skymed-msg-in 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes skymed-msg-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Inner role=alert (errors) inherits the wrapper styling but resets the redundant frame */
[data-drupal-messages] > [role="contentinfo"] > [role="alert"] {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  animation: none;
  color: inherit;
  font-weight: inherit;
}

/* Icon (left badge) */
[data-drupal-messages] > [role="contentinfo"]::before,
.messages::before {
  content: '';
  position: absolute;
  left: 0.85rem;
  top: 0.95rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 14px;
  background-color: #2563eb;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><line x1='12' y1='11' x2='12' y2='17'/><circle cx='12' cy='7' r='0.6' fill='%23fff'/></svg>");
}

/* ----- ERROR — when an alert role is present, recolor to red ----- */
[data-drupal-messages] > [role="contentinfo"]:has([role="alert"]),
[data-drupal-messages] > [role="alert"],
.messages--error,
div.messages.messages--error,
.messages.error {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border-color: #fca5a5;
  color: #991b1b;
}
[data-drupal-messages] > [role="contentinfo"]:has([role="alert"])::before,
[data-drupal-messages] > [role="alert"]::before,
.messages--error::before {
  background-color: #dc2626;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'/><line x1='6' y1='6' x2='18' y2='18'/></svg>");
}

/* ----- STATUS (success): wrapper has aria-label="Status message" but we can use a different aria pattern.
 * Drupal status messages typically have role="contentinfo" without role="alert" inside.
 * We need a way to distinguish from warning/info. Drupal's pattern uses different aria-labels in i18n,
 * so we use the aria-label prefix in Russian/Ukrainian + English fallback. */
[data-drupal-messages] > [role="contentinfo"][aria-label*="Status" i],
[data-drupal-messages] > [role="contentinfo"][aria-label*="Статус" i],
[data-drupal-messages] > [role="contentinfo"][aria-label*="Сообщ" i]:not(:has([role="alert"])),
[data-drupal-messages] > [role="contentinfo"][aria-label*="Повідомл" i]:not(:has([role="alert"])),
.messages--status,
div.messages.messages--status {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border-color: #86efac;
  color: #14532d;
}
[data-drupal-messages] > [role="contentinfo"][aria-label*="Status" i]::before,
[data-drupal-messages] > [role="contentinfo"][aria-label*="Статус" i]::before,
[data-drupal-messages] > [role="contentinfo"][aria-label*="Сообщ" i]:not(:has([role="alert"]))::before,
[data-drupal-messages] > [role="contentinfo"][aria-label*="Повідомл" i]:not(:has([role="alert"]))::before,
.messages--status::before {
  background-color: #16a34a;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
}

/* ----- WARNING ----- */
[data-drupal-messages] > [role="contentinfo"][aria-label*="Warning" i],
[data-drupal-messages] > [role="contentinfo"][aria-label*="Предупр" i],
[data-drupal-messages] > [role="contentinfo"][aria-label*="Попередж" i],
.messages--warning,
div.messages.messages--warning {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fcd34d;
  color: #78350f;
}
[data-drupal-messages] > [role="contentinfo"][aria-label*="Warning" i]::before,
[data-drupal-messages] > [role="contentinfo"][aria-label*="Предупр" i]::before,
[data-drupal-messages] > [role="contentinfo"][aria-label*="Попередж" i]::before,
.messages--warning::before {
  background-color: #d97706;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M12 9v4'/><circle cx='12' cy='17' r='0.6' fill='%23fff'/></svg>");
}

/* Auth card: tighter margins */
.auth-form-card [data-drupal-messages] > [role="contentinfo"],
.auth-form-card .messages {
  margin: 0 0 1.25rem;
}

/* Page-level messages: centered/constrained on large screens */
main > [data-drupal-messages] > [role="contentinfo"],
main > .messages {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 640px) {
  [data-drupal-messages] > [role="contentinfo"],
  .messages { font-size: 0.9rem; padding-left: 2.75rem; }
  [data-drupal-messages] > [role="contentinfo"]::before,
  .messages::before { left: 0.7rem; }
}
