:root {
  --chat-profile-gap: 24px;
  --chat-profile-radius: 12px;
  --chat-profile-on-primary: var(--chat-join-bg);
}

/* Modern Layout Wrapper */
.chat-profile-wrapper.modern-layout {
  display: flex;
  flex-direction: column;
  gap: var(--chat-profile-gap);
  color: var(--color-text);
  padding: 4px;
}

.chat-profile-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--chat-join-primary) 8%, transparent);
  color: color-mix(in srgb, var(--color-text) 85%, transparent);
  border-left: 3px solid var(--chat-join-primary);
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-profile-banner i {
  color: var(--chat-join-primary);
  margin-top: 2px;
}

.chat-profile-banner.error {
  background: color-mix(in srgb, #ef4444 10%, transparent);
  border-left-color: #ef4444;
}

.chat-profile-banner.success {
  background: color-mix(in srgb, #22c55e 10%, transparent);
  border-left-color: #22c55e;
}

.chat-profile-banner.info {
  background: color-mix(in srgb, #3b82f6 10%, transparent);
  border-left-color: #3b82f6;
}

/* Grid Layout */
.chat-profile-content-grid {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

/* Avatar Section */
.chat-profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.chat-profile-avatar-container {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: var(--search-input);
  border: 3px solid color-mix(in srgb, var(--color-text) 8%, transparent);
  transition: border-color 0.2s;
}

.chat-profile-avatar-container:hover {
  border-color: var(--chat-join-primary);
}

.chat-profile-avatar-img {
  width: 100%;
  height: 100%;
  padding: 10px;
  object-fit: cover;
}

.chat-profile-avatar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.chat-profile-avatar-container:hover .chat-profile-avatar-overlay {
  opacity: 1;
}

.chat-profile-avatar-overlay i {
  color: white;
  font-size: 28px;
  drop-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Saving loader */
.chat-profile-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 24px;
  color: var(--color-text);
}

.chat-profile-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid color-mix(in srgb, var(--color-text) 20%, transparent);
  border-top-color: var(--chat-join-primary);
  border-radius: 50%;
  animation: chatProfileSpin 0.8s linear infinite;
}

@keyframes chatProfileSpin {
  to { transform: rotate(360deg); }
}

/* Saving overlay */
.chat-profile-saving-overlay {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--color-bg-from) 65%, rgba(0,0,0,0.4));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  backdrop-filter: blur(2px);
}

.chat-profile-saving-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--color-bg-from) 90%, rgba(0,0,0,0.05));
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  color: var(--color-text);
  font-weight: 600;
}

.chat-profile-saving-box .chat-profile-spinner {
  width: 20px;
  height: 20px;
}

.chat-profile-text-btn {
  background: none;
  border: none;
  color: var(--chat-join-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.2s;
}

.chat-profile-text-btn:hover {
  background: color-mix(in srgb, var(--chat-join-primary) 10%, transparent);
}

/* Form Section */
.chat-profile-form-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.chat-profile-section-box {
  background: var(--search-input);
  border: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
  border-radius: 12px;
  padding: 16px;
}

.chat-profile-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-profile-label {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
  margin-left: 2px;
  margin-bottom: 4px;
}

.chat-profile-input {
  width: 100%;
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--color-text) 18%, transparent);
  background: var(--block-bg);
  color: var(--color-text);
  outline: none;
  font-size: 15px;
  transition: all 0.2s ease;
}

.chat-profile-input:focus:not(:disabled) {
  border-color: var(--chat-join-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-join-primary) 20%, transparent);
}

.chat-profile-input:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  background: color-mix(in srgb, var(--block-bg) 50%, transparent);
  border-color: transparent;
}

/* Inline Note */
.chat-profile-inline-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: color-mix(in srgb, var(--color-text) 80%, transparent);
  margin-top: 4px;
  line-height: 1.5;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--chat-join-primary) 8%, transparent);
  border-radius: 8px;
  border-left: 3px solid var(--chat-join-primary);
}

.chat-profile-inline-note i {
  color: var(--chat-join-primary);
  margin-top: 3px;
}

.chat-profile-status {
  font-size: 13px;

  font-weight: 500;
}

.chat-profile-status.error { color: var(--chat-join-error); }
.chat-profile-status.success { color: var(--chat-join-success); }
.chat-profile-status.pending { color: var(--chat-join-primary); }

/* Email Row */
.chat-profile-email-row {
  display: flex;
  gap: 10px;
}

.chat-profile-xs-btn {
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--chat-join-primary);
  color: var(--chat-join-primary);
  background: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.chat-profile-xs-btn:hover {
  background: var(--chat-join-primary);
  color: var(--chat-profile-on-primary, white);
}

.chat-profile-confirm {
  padding: 16px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--block-bg) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-text) 12%, transparent);
  color: var(--color-text);
  line-height: 1.6;
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .chat-profile-content-grid {
    flex-direction: column;
    align-items: center;
    gap: 32px;
  }
  
  .chat-profile-avatar-section {
    width: 100%;
    border-bottom: 1px solid color-mix(in srgb, var(--color-text) 10%, transparent);
    padding-bottom: 24px;
  }
}