/* =========================================================
   FASHCOACH MESSAGING
========================================================= */

.messages-page {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }


  /* =========================================================
     LAYOUT
  ========================================================= */

  .messages-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    min-height: 620px;
    overflow: hidden;

    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;

    background:
      linear-gradient(
        145deg,
        rgba(24, 18, 43, 0.98),
        rgba(13, 11, 24, 0.98)
      );

    box-shadow:
      0 20px 60px rgba(0, 0, 0, 0.22);
  }


  /* =========================================================
     CONVERSATION SIDEBAR
  ========================================================= */

  .messages-conversations {
    display: flex;
    flex-direction: column;
    min-width: 0;

    border-right: 1px solid rgba(255, 255, 255, 0.08);

    background:
      rgba(255, 255, 255, 0.015);
  }


  .messages-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    min-height: 70px;
    padding: 16px 18px;

    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }


  .messages-list-header > div {
    display: flex;
    align-items: center;
    gap: 10px;
  }


  .messages-list-header span {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.55);
  }


  .messages-list-header strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 25px;
    height: 25px;
    padding: 0 7px;

    border-radius: 999px;

    background:
      rgba(139, 92, 246, 0.16);

    color: #c4b5fd;
    font-size: 0.75rem;
  }


  .messages-conversation-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }


  /* =========================================================
     CONVERSATION ITEM
  ========================================================= */

  .messages-conversation-item {
    width: 100%;

    display: flex;
    align-items: center;
    gap: 12px;

    padding: 15px 16px;

    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.055);

    background:
      rgba(255, 255, 255, 0.018);
    color: inherit;

    text-align: left;
    cursor: pointer;

    transition:
      background 0.18s ease,
      border-color 0.18s ease;
  }

  .messages-conversation-item:nth-child(even) {
    background:
      rgba(139, 92, 246, 0.075);
  }

  .messages-conversation-item:hover {
    background:
      rgba(139, 92, 246, 0.07);
  }


  .messages-conversation-item.active {
    background:
      linear-gradient(
        90deg,
        rgba(124, 58, 237, 0.2),
        rgba(124, 58, 237, 0.06)
      );

    box-shadow:
      inset 3px 0 0 #8b5cf6;
  }


  .messages-conversation-item.unread {
  background:
    linear-gradient(
      90deg,
      rgba(139, 92, 246, 0.13),
      rgba(139, 92, 246, 0.045)
    );
}

.messages-conversation-item.unread
  .messages-conversation-top strong {
  color: #ffffff;
  font-weight: 800;
}

.messages-conversation-item.active,
.messages-conversation-item.active.unread {
  background:
    linear-gradient(
      90deg,
      rgba(124, 58, 237, 0.2),
      rgba(124, 58, 237, 0.06)
    );

  box-shadow:
    inset 3px 0 0 #8b5cf6;
}


  .messages-conversation-avatar,
  .messages-thread-avatar,
  .messages-new-option-avatar {
    flex: 0 0 auto;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 42px;
    height: 42px;

    border-radius: 50%;

    background:
      linear-gradient(
        145deg,
        #7c3aed,
        #4f46e5
      );

    color: #ffffff;

    font-size: 0.95rem;
    font-weight: 800;
  }


  .messages-conversation-avatar.group,
  .messages-thread-avatar.group,
  .messages-new-option-avatar.group {
    border-radius: 13px;

    background:
      linear-gradient(
        145deg,
        #9333ea,
        #6d28d9
      );
  }


  .messages-conversation-content {
    min-width: 0;
    flex: 1;

    display: flex;
    flex-direction: column;
    gap: 5px;
  }


  .messages-conversation-top,
  .messages-conversation-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }


  .messages-conversation-top strong {
    min-width: 0;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: rgba(255, 255, 255, 0.88);
    font-size: 0.91rem;
  }


  .messages-conversation-top small {
    flex: 0 0 auto;

    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
  }


  .messages-conversation-bottom > span {
    min-width: 0;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: rgba(255, 255, 255, 0.46);
    font-size: 0.78rem;
  }


  .messages-unread-dot {
    flex: 0 0 auto;

    width: 8px;
    height: 8px;

    border-radius: 50%;

    background: #a78bfa;

    box-shadow:
      0 0 12px rgba(167, 139, 250, 0.65);
  }


  /* =========================================================
     EMPTY CONVERSATION LIST
  ========================================================= */

  .messages-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 55px 24px;

    text-align: center;
  }


  .messages-empty-icon,
  .messages-thread-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 54px;
    height: 54px;

    margin-bottom: 16px;

    border-radius: 17px;

    background:
      rgba(139, 92, 246, 0.12);

    border: 1px solid rgba(167, 139, 250, 0.15);

    color: #c4b5fd;
    font-size: 1.4rem;
  }


  .messages-list-empty strong {
    color: rgba(255, 255, 255, 0.88);
  }


  .messages-list-empty p {
    max-width: 230px;
    margin: 8px 0 0;

    color: rgba(255, 255, 255, 0.45);
    line-height: 1.55;
    font-size: 0.82rem;
  }


  /* =========================================================
     THREAD
  ========================================================= */

  .messages-thread {
    min-width: 0;

    display: flex;
    flex-direction: column;

    background:
      radial-gradient(
        circle at top right,
        rgba(124, 58, 237, 0.08),
        transparent 35%
      );
  }


  .messages-thread-empty,
  .messages-thread-loading {
    flex: 1;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    min-height: 500px;

    padding: 40px;

    text-align: center;
  }


  .messages-thread-empty h3 {
    margin: 0;

    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
  }


  .messages-thread-empty p,
  .messages-thread-loading span {
    max-width: 340px;

    margin: 8px 0 0;

    color: rgba(255, 255, 255, 0.45);
    line-height: 1.55;
  }


  .messages-thread-loading strong {
    color: rgba(255, 255, 255, 0.9);
  }


  /* =========================================================
     THREAD HEADER
  ========================================================= */

  .messages-thread-header {
    min-height: 70px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;

    padding: 13px 20px;

    border-bottom: 1px solid rgba(255, 255, 255, 0.08);

    background:
      rgba(12, 10, 22, 0.42);

    backdrop-filter: blur(12px);
  }


  .messages-thread-person {
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 12px;
  }


  .messages-thread-person > div {
    min-width: 0;

    display: flex;
    flex-direction: column;
    gap: 3px;
  }


  .messages-thread-person strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: rgba(255, 255, 255, 0.92);
  }


  .messages-thread-person span:not(.messages-thread-avatar) {
    color: rgba(255, 255, 255, 0.42);
    font-size: 0.75rem;
  }


  /* =========================================================
     MESSAGE BODY
  ========================================================= */

  .messages-thread-body {
    flex: 1;

    min-height: 420px;
    max-height: 560px;

    overflow-y: auto;

    display: flex;
    flex-direction: column;
    gap: 9px;

    padding: 24px;
  }


  .messages-message-row {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
  }


  .messages-message-row.own {
    justify-content: flex-end;
    align-items: flex-start;
  }

  .messages-message-bubble {
    width: auto;
    max-width: min(72%, 620px);

    padding: 9px 12px 7px;

    border-radius:
      5px 17px 17px 17px;

    background:
      rgba(255, 255, 255, 0.075);

    border:
      1px solid rgba(255, 255, 255, 0.065);

    color: rgba(255, 255, 255, 0.88);

    box-shadow:
      0 8px 24px rgba(0, 0, 0, 0.1);
  }

  .messages-message-row.own
  .messages-message-bubble {
  background:
    linear-gradient(
      135deg,
      rgba(124, 58, 237, 0.42),
      rgba(109, 40, 217, 0.28)
    );

  border-color:
    rgba(139, 92, 246, 0.3);

  border-radius:
    17px 5px 17px 17px;
}

  .messages-message-row.own
    .messages-message-bubble {
    border-radius:
      17px 5px 17px 17px;

    background:
      linear-gradient(
        145deg,
        rgba(124, 58, 237, 0.88),
        rgba(91, 33, 182, 0.92)
      );

    border-color:
      rgba(167, 139, 250, 0.2);
  }


  .messages-message-bubble p {
    display: block;
    margin: 0;

    white-space: normal;
    overflow-wrap: anywhere;

    text-align: left;

    line-height: 1.35;
    font-size: 0.9rem;
  }


  .messages-message-bubble span {
    display: block;

    margin-top: 3px;

    color: rgba(255, 255, 255, 0.62);

    text-align: right;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.15;
  }

  .messages-message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;

    margin-top: 3px;
  }


  .messages-message-meta span {
    margin-top: 0;
  }


  .messages-delete-button {
    appearance: none;

    padding: 0;

    border: 0;
    background: transparent;

    color: rgba(255, 255, 255, 0.58);

    font: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.15;

    cursor: pointer;
  }


  .messages-delete-button:hover,
  .messages-delete-button:focus-visible {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: underline;
  }


  .messages-delete-button:focus-visible {
    outline:
      2px solid rgba(196, 181, 253, 0.75);

    outline-offset: 3px;
    border-radius: 2px;
  }


  .messages-message-row.own
    .messages-message-bubble span {
    color: rgba(255, 255, 255, 0.62);
  }


  .messages-thread-first {
    margin: auto;

    padding: 30px;

    text-align: center;

    color: rgba(255, 255, 255, 0.55);
  }


  .messages-thread-first strong {
    display: block;

    color: rgba(255, 255, 255, 0.82);
  }


  .messages-thread-first p {
    margin: 7px 0 0;

    font-size: 0.82rem;
  }


  /* =========================================================
     COMPOSER
  ========================================================= */

  .messages-composer {
    display: flex;
    align-items: flex-end;
    gap: 12px;

    padding: 16px 20px;

    border-top:
      1px solid rgba(255, 255, 255, 0.08);

    background:
      rgba(12, 10, 22, 0.68);
  }


  .messages-composer textarea {
    flex: 1;

    min-height: 46px;
    max-height: 130px;

    resize: vertical;

    padding: 12px 14px;

    border:
      1px solid rgba(255, 255, 255, 0.1);

    border-radius: 14px;

    outline: none;

    background:
      rgba(255, 255, 255, 0.055);

    color: #ffffff;

    font: inherit;
    line-height: 1.4;

    transition:
      border-color 0.18s ease,
      box-shadow 0.18s ease,
      background 0.18s ease;
  }


  .messages-composer textarea::placeholder {
    color: rgba(255, 255, 255, 0.35);
  }


  .messages-composer textarea:focus {
    border-color:
      rgba(167, 139, 250, 0.52);

    background:
      rgba(255, 255, 255, 0.075);

    box-shadow:
      0 0 0 3px
      rgba(139, 92, 246, 0.1);
  }

  /* =========================================================
    EMOJI PICKER
  ========================================================= */

  .messages-emoji-wrapper {
    position: relative;
    flex: 0 0 auto;
  }

  .messages-emoji-button {
    width: 42px;
    height: 42px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border:
      1px solid rgba(167, 139, 250, 0.18);

    border-radius: 12px;

    background:
      rgba(139, 92, 246, 0.08);

    color: #ffffff;

    font-size: 1.15rem;
    cursor: pointer;
  }

  .messages-emoji-button:hover {
    background:
      rgba(139, 92, 246, 0.16);

    border-color:
      rgba(167, 139, 250, 0.32);
  }

  .messages-emoji-picker {
    position: absolute;
    left: 0;
    bottom: calc(100% + 10px);
    z-index: 20;

    width: 220px;

    display: grid;
    grid-template-columns:
      repeat(4, 1fr);
    gap: 5px;

    padding: 10px;

    border:
      1px solid rgba(167, 139, 250, 0.2);

    border-radius: 14px;

    background:
      rgba(24, 18, 43, 0.98);

    box-shadow:
      0 16px 40px
      rgba(0, 0, 0, 0.35);
  }

  .messages-emoji-picker[hidden] {
    display: none;
  }

  .messages-emoji-option {
    min-width: 0;
    height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 0;
    border-radius: 9px;

    background: transparent;

    font-size: 1.25rem;
    cursor: pointer;
  }

  .messages-emoji-option:hover {
    background:
      rgba(139, 92, 246, 0.16);
  }

  /* =========================================================
     NEW MESSAGE PANEL
  ========================================================= */

  .messages-new-panel {
    position: relative;
  }


  .messages-new-card {
    padding: 22px;

    border:
      1px solid rgba(167, 139, 250, 0.15);

    border-radius: 20px;

    background:
      linear-gradient(
        145deg,
        rgba(30, 22, 51, 0.98),
        rgba(17, 13, 31, 0.98)
      );

    box-shadow:
      0 18px 50px rgba(0, 0, 0, 0.22);
  }


  .messages-new-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;

    margin-bottom: 20px;
  }


  .messages-new-header h3 {
    margin: 5px 0 0;

    color: rgba(255, 255, 255, 0.94);
  }


  .messages-new-grid {
    display: grid;
    grid-template-columns:
      repeat(2, minmax(0, 1fr));

    gap: 16px;
  }


  .messages-new-section {
    min-width: 0;

    padding: 18px;

    border:
      1px solid rgba(255, 255, 255, 0.07);

    border-radius: 16px;

    background:
      rgba(255, 255, 255, 0.025);
  }


  .messages-new-section h4 {
    margin: 0;

    color: rgba(255, 255, 255, 0.9);
  }


  .messages-new-section > p {
    margin: 7px 0 16px;

    color: rgba(255, 255, 255, 0.45);
    line-height: 1.5;
    font-size: 0.8rem;
  }


  .messages-new-options {
    display: flex;
    flex-direction: column;
    gap: 7px;

    max-height: 300px;
    overflow-y: auto;
  }


  .messages-new-option {
    width: 100%;

    display: flex;
    align-items: center;
    gap: 11px;

    padding: 10px;

    border:
      1px solid rgba(255, 255, 255, 0.06);

    border-radius: 13px;

    background:
      rgba(255, 255, 255, 0.035);

    color: inherit;

    text-align: left;
    cursor: pointer;

    transition:
      background 0.18s ease,
      border-color 0.18s ease,
      transform 0.18s ease;
  }


  .messages-new-option:hover {
    transform:
      translateY(-1px);

    border-color:
      rgba(167, 139, 250, 0.22);

    background:
      rgba(139, 92, 246, 0.09);
  }


  .messages-new-option > span:last-child {
    min-width: 0;

    display: flex;
    flex-direction: column;
    gap: 3px;
  }


  .messages-new-option strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: rgba(255, 255, 255, 0.88);
  }


  .messages-new-option small {
    color: rgba(255, 255, 255, 0.4);
  }


  .messages-new-empty {
    padding: 18px;

    border-radius: 12px;

    background:
      rgba(255, 255, 255, 0.025);

    color: rgba(255, 255, 255, 0.42);

    text-align: center;
    font-size: 0.8rem;
  }


  /* =========================================================
     SMALL BUTTONS
  ========================================================= */

  .messages-icon-button,
  .messages-secondary-button {
    border:
      1px solid rgba(167, 139, 250, 0.18);

    background:
      rgba(139, 92, 246, 0.08);

    color: #c4b5fd;

    cursor: pointer;

    transition:
      background 0.18s ease,
      border-color 0.18s ease;
  }


  .messages-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 34px;
    height: 34px;

    padding: 0;

    border-radius: 10px;

    font-size: 1.15rem;
  }


  .messages-secondary-button {
    padding: 8px 12px;

    border-radius: 10px;

    font-size: 0.75rem;
    font-weight: 700;
  }


  .messages-icon-button:hover,
  .messages-secondary-button:hover {
    border-color:
      rgba(167, 139, 250, 0.34);

    background:
      rgba(139, 92, 246, 0.15);
  }


  .messages-icon-button:disabled,
  .messages-secondary-button:disabled,
  .messages-new-option:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }


  /* =========================================================
     FEEDBACK
  ========================================================= */

  #messagesFeedback:empty {
    display: none;
  }


  #messagesFeedback[data-type="error"] {
    border-color:
      rgba(248, 113, 113, 0.22);

    color: #fca5a5;
  }


  /* =========================================================
     RESPONSIVE
  ========================================================= */

  @media (max-width: 900px) {

    .messages-layout {
      grid-template-columns: 280px minmax(0, 1fr);
    }

    .messages-new-grid {
      grid-template-columns: 1fr;
    }

  }


  @media (max-width: 700px) {

    .messages-layout {
      display: flex;
      flex-direction: column;

      min-height: 0;
    }


    .messages-conversations {
      border-right: 0;
      border-bottom:
        1px solid rgba(255, 255, 255, 0.08);
    }


    .messages-conversation-list {
      max-height: 300px;
    }


    .messages-thread {
      min-height: 500px;
    }


    .messages-thread-empty,
    .messages-thread-loading {
      min-height: 420px;
    }


    .messages-thread-body {
      min-height: 350px;
      max-height: 500px;

      padding: 18px 14px;
    }


    .messages-message-bubble {
      max-width: 86%;
    }


    .messages-thread-header {
      padding:
        12px 14px;
    }


    .messages-composer {
      padding:
        12px 14px;
    }

  }


  @media (max-width: 520px) {

    .messages-page {
      gap: 16px;
    }


    .messages-new-card {
      padding: 16px;
    }


    .messages-new-section {
      padding: 14px;
    }


    .messages-thread-header {
      align-items: flex-start;
    }


    .messages-thread-avatar,
    .messages-conversation-avatar {
      width: 38px;
      height: 38px;
    }


    .messages-secondary-button {
      padding:
        7px 9px;

      font-size: 0.68rem;
    }


    .messages-composer {
      gap: 8px;
    }


    .messages-composer
      .primary-button {
      padding:
        11px 14px;
    }

  }
  .messages-message-sender {
    display: block;
    margin: 0 0 4px;

    text-align: left;

    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1.2;
    opacity: 1;
  }