:root {
    --primary-color: var(--color-primary);
    --secondary-color: var(--color-secondary);
    --primary-gradient: linear-gradient(45deg, var(--color-primary), var(--color-secondary));
    --accent-color: var(--color-accent);
    --text-primary: var(--color-text);
    --text-secondary: var(--color-muted);
    --bg-light: var(--color-surface-muted);
    --card-bg: var(--color-surface);
    --border-radius-sm: var(--radius-sm);
    --border-radius-md: var(--radius-md);
    --border-radius-lg: var(--radius-lg);
    --box-shadow-sm: var(--shadow-sm);
    --box-shadow-md: var(--shadow-md);
    --transition-fast: 0.2s ease;
    --chat-overlay-gap: 16px;
    --chat-overlay-max-width: 420px;
    --chat-overlay-min-height: 320px;
  }

  /* Message styling */
  .message {
    padding: 0.75rem 1rem;
    width: fit-content;
    max-width: 80%;
    border-radius: 18px;
    margin-bottom: 0.5rem;
    text-align: start;
    font-size: medium;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: all var(--transition-fast);
    word-break: break-word;
  }

  .sender_msg {
    background-color: rgba(14, 165, 233, 0.1);
    color: var(--text-primary);
    border-bottom-left-radius: 5px;
  }

  .sender_msg:hover {
    background-color: rgba(14, 165, 233, 0.15);
  }

  .receiver_msg {
    background: var(--primary-gradient);
    color: white;
    border-bottom-right-radius: 5px;
  }

  .receiver_msg:hover {
    box-shadow: 0 3px 8px rgba(14, 165, 233, 0.2);
  }

  /* Delete button styling */
  .btn-delete {
    background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(255, 107, 107, 0.2);
    transition: all 0.3s ease;
  }

  .btn-delete:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(255, 107, 107, 0.25);
  }

  /* Chat form styling */
  #chat_form {
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--box-shadow-md);
    background-color: var(--card-bg);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: var(--chat-overlay-min-height);
  }

  #chat_form.is-hidden {
    display: none;
  }

  .chat-overlay {
    position: fixed;
    right: var(--chat-overlay-gap);
    bottom: var(--chat-overlay-gap);
    width: min(var(--chat-overlay-max-width), calc(100vw - (var(--chat-overlay-gap) * 2)));
    height: min(72vh, calc(100dvh - (var(--chat-overlay-gap) * 2)));
    min-height: var(--chat-overlay-min-height);
    max-height: calc(100dvh - (var(--chat-overlay-gap) * 2));
    margin: 0;
    z-index: 102;
    display: none;
  }

  #chat_form:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
  }

  #chat_form .card-header {
    background: linear-gradient(to right, rgba(14, 165, 233, 0.05), rgba(20, 184, 166, 0.05));
    border-bottom: none;
    padding: 1rem;
  }

  #chat_form .card-header,
  #chat_form .card-footer {
    flex: 0 0 auto;
  }

  #chat-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    background-color: rgba(249, 250, 251, 0.5);
    padding: 1rem;
  }

  /* File and user info styling */
  #buyer_avatar {
    width: 45px;
    height: 45px;
    object-fit: cover;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 2px solid white;
    transition: transform 0.3s ease;
  }

  #buyer_avatar:hover {
    transform: scale(1.1);
  }

  #buyer_username {
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.3s ease;
  }

  #buyer_username:hover {
    color: var(--secondary-color);
  }

  #buyer_user_feedback {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
  }

  /* Input area styling */
  .input-group {
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
  }

  #input-message {
    border: none;
    background-color: var(--bg-light);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    box-shadow: none;
  }

  #input-message:focus {
    outline: none;
    box-shadow: none;
  }

  #btn_attach, #btn_send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.3s ease;
  }

  #btn_attach {
    background-color: #f1f1f1;
    border-radius: 8px 0 0 8px;
  }

  #btn_attach:hover {
    background-color: #e5e5e5;
  }

  #btn_send {
    background: var(--primary-gradient);
    border-radius: 0 8px 8px 0;
  }

  #btn_send:hover {
    opacity: 0.9;
    transform: translateX(2px);
  }

  /* Scrollbar styling */
  ::-webkit-scrollbar {
    width: 6px;
  }

  ::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
  }

  ::-webkit-scrollbar-thumb {
    background: rgba(14, 165, 233, 0.3);
    border-radius: 5px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: rgba(14, 165, 233, 0.5);
  }

  /* Loading spinner */

  /* Responsive adjustments */
  @media (max-width: 768px) {
    .chat-overlay {
      top: clamp(64px, 9vh, 96px);
      right: 0;
      left: 0;
      bottom: 0;
      width: 100%;
      height: auto;
      max-height: calc(100dvh - clamp(64px, 9vh, 96px));
      min-height: 0;
      margin: 0;
      border-radius: 0;
    }

    #chat_form {
      border-radius: 0;
    }

    #chat-content {
      flex: 1;
      overflow-y: auto;
      height: auto;
      /* height: calc(100vh - 280px); */
      /* min-height: 300px; */
    }

    .message {
      max-width: 85%;
    }
  }

  @media (max-width: 576px) {
    #chat-content {
      padding: 0.75rem;
    }

    .message {
      max-width: 90%;
      padding: 0.5rem 0.75rem;
    }

    #buyer_username {
      font-size: 0.85rem;
    }

    #buyer_user_feedback {
      font-size: 0.85rem;
    }
  }

  @keyframes rotate {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
  }
