/* ============================================================
   Pshina Chat — Modern UI inspired by Circassian heritage colors
   Green (#296912) + Gold (#d4a017) + Cream
   ============================================================ */

.pshina-chat {
  /* Core palette */
  --pc-green: #296912;
  --pc-green-dark: #1d4d0c;
  --pc-green-light: #3d8a1f;
  --pc-gold: #d4a017;
  --pc-gold-light: #e8b835;
  --pc-cream: #fdfaf3;
  --pc-cream-2: #f5efe0;

  --pc-bg: #fdfaf3;
  --pc-surface: #ffffff;
  --pc-text: #15280a;
  --pc-text-soft: #2d3e22;
  --pc-muted: #6b7a5f;
  --pc-line: rgba(41, 105, 18, 0.14);
  --pc-line-strong: rgba(41, 105, 18, 0.24);

  --pc-success: var(--pc-green);
  --pc-error: #b3261e;

  --pc-radius: 18px;
  --pc-radius-lg: 28px;
  --pc-shadow-sm: 0 4px 12px rgba(15, 40, 5, 0.06);
  --pc-shadow-md: 0 14px 40px rgba(15, 40, 5, 0.12);
  --pc-shadow-lg: 0 30px 80px rgba(15, 40, 5, 0.18);

  color: var(--pc-text);
  direction: rtl;
  font-family: "Tajawal", "Cairo", Tahoma, "Segoe UI", system-ui, sans-serif;
  margin: 24px auto;
  max-width: 920px;
  position: relative;
}

.pshina-chat *,
.pshina-chat *::before,
.pshina-chat *::after {
  box-sizing: border-box;
}

/* -----------------------------------------------------------
   SHELL with subtle gold accent border
   ----------------------------------------------------------- */
.pshina-chat__shell {
  background: var(--pc-cream);
  border: 1px solid var(--pc-line);
  border-radius: var(--pc-radius-lg);
  box-shadow: var(--pc-shadow-lg);
  overflow: hidden;
  position: relative;
}

.pshina-chat__shell::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--pc-radius-lg);
  padding: 1.5px;
  background: linear-gradient(135deg,
    rgba(212, 160, 23, 0.4) 0%,
    rgba(41, 105, 18, 0.0) 30%,
    rgba(41, 105, 18, 0.0) 70%,
    rgba(212, 160, 23, 0.4) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 1;
}

/* -----------------------------------------------------------
   HEADER with green→gold gradient strip
   ----------------------------------------------------------- */
.pshina-chat__header {
  align-items: center;
  background: linear-gradient(135deg, var(--pc-green) 0%, var(--pc-green-light) 100%);
  color: #fff;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 22px 28px;
  position: relative;
}

.pshina-chat__header::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(212, 160, 23, 0.22) 0%, transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
  pointer-events: none;
}

.pshina-chat__header > * {
  position: relative;
  z-index: 2;
}

.pshina-chat__brand-block {
  align-items: center;
  display: flex;
  gap: 16px;
}

.pshina-chat__logo {
  align-items: center;
  background: linear-gradient(135deg, var(--pc-gold) 0%, var(--pc-gold-light) 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(15, 40, 5, 0.25), inset 0 1px 0 rgba(255,255,255,0.4);
  color: var(--pc-green-dark);
  display: inline-flex;
  flex-shrink: 0;
  font-size: 26px;
  font-weight: 900;
  height: 54px;
  justify-content: center;
  width: 54px;
}

.pshina-chat__logo span {
  display: block;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

.pshina-chat__kicker {
  color: var(--pc-gold-light);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.pshina-chat__brand {
  color: #fff;
  font-size: clamp(24px, 5vw, 32px);
  line-height: 1;
  margin: 0;
  letter-spacing: -0.015em;
  font-weight: 900;
}

.pshina-chat__intro {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  margin: 4px 0 0;
  max-width: 360px;
}

.pshina-chat__header-actions {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Online badge */
.pshina-chat__online {
  align-items: center;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 8px;
  padding: 6px 14px;
}

.pshina-chat__online-dot {
  background: var(--pc-gold-light);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(232, 184, 53, 0.3);
  display: inline-block;
  height: 8px;
  width: 8px;
  animation: pshina-pulse 1.8s ease-in-out infinite;
}

@keyframes pshina-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.7; }
}

/* Language selector inside header */
.pshina-chat__language-label {
  align-items: center;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  font-size: 12px;
  font-weight: 600;
  gap: 8px;
}

.pshina-chat__language-label > span {
  white-space: nowrap;
}

.pshina-chat__language {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  outline: none;
  padding: 7px 12px;
  transition: all 180ms ease;
  cursor: pointer;
}

.pshina-chat__language option {
  color: var(--pc-text);
  background: #fff;
}

.pshina-chat__language:hover,
.pshina-chat__language:focus {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.5);
}

/* -----------------------------------------------------------
   NOTICE bar — gold accent strip
   ----------------------------------------------------------- */
.pshina-chat__notice {
  background: linear-gradient(90deg,
    rgba(212, 160, 23, 0.08) 0%,
    rgba(212, 160, 23, 0.16) 50%,
    rgba(212, 160, 23, 0.08) 100%);
  border-bottom: 1px solid var(--pc-line);
  color: var(--pc-text-soft);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 28px;
  text-align: center;
  position: relative;
}

.pshina-chat__notice::before {
  content: "ⓘ";
  color: var(--pc-gold);
  font-weight: 900;
  margin-inline-end: 8px;
}

/* -----------------------------------------------------------
   REGISTRATION CARD
   ----------------------------------------------------------- */
.pshina-chat__registration {
  background:
    radial-gradient(ellipse at top, rgba(41, 105, 18, 0.04) 0%, transparent 60%),
    var(--pc-cream);
  padding: 44px 28px;
}

.pshina-chat__registration-inner {
  background: #fff;
  border: 1px solid var(--pc-line);
  border-radius: var(--pc-radius);
  box-shadow: var(--pc-shadow-md);
  margin: 0 auto;
  max-width: 460px;
  overflow: hidden;
  padding: 36px 30px;
  position: relative;
  text-align: center;
}

.pshina-chat__registration-inner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--pc-green) 0%, var(--pc-gold) 50%, var(--pc-green) 100%);
}

.pshina-chat__registration-icon {
  background: linear-gradient(135deg, var(--pc-green) 0%, var(--pc-green-light) 100%);
  border-radius: 18px;
  box-shadow: 0 14px 30px rgba(41, 105, 18, 0.3);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  height: 64px;
  width: 64px;
  margin-bottom: 18px;
  position: relative;
}

.pshina-chat__registration-icon::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 21px;
  border: 2px solid var(--pc-gold);
  opacity: 0.4;
}

.pshina-chat__registration h3 {
  color: var(--pc-text);
  font-size: clamp(22px, 3.6vw, 26px);
  font-weight: 900;
  margin: 0 0 10px;
}

.pshina-chat__registration p {
  color: var(--pc-muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 22px;
}

.pshina-chat__form {
  display: grid;
  gap: 14px;
  text-align: start;
}

.pshina-chat__form label {
  color: var(--pc-text-soft);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  letter-spacing: 0.02em;
}

.pshina-chat input,
.pshina-chat textarea {
  background: #fff;
  border: 1.5px solid var(--pc-line-strong);
  border-radius: 12px;
  color: var(--pc-text);
  font: inherit;
  outline: none;
  padding: 12px 14px;
  transition: all 180ms ease;
  width: 100%;
}

.pshina-chat input::placeholder,
.pshina-chat textarea::placeholder {
  color: rgba(107, 122, 95, 0.6);
}

.pshina-chat input:focus,
.pshina-chat textarea:focus {
  border-color: var(--pc-green);
  box-shadow: 0 0 0 4px rgba(41, 105, 18, 0.12);
}

/* -----------------------------------------------------------
   BUTTONS
   ----------------------------------------------------------- */
.pshina-chat__button,
.pshina-chat__ghost {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  transition: all 200ms cubic-bezier(0.2, 0.9, 0.25, 1);
  letter-spacing: 0.01em;
}

.pshina-chat__button {
  background: linear-gradient(135deg, var(--pc-green) 0%, var(--pc-green-light) 100%);
  border: 1px solid var(--pc-green-dark);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(41, 105, 18, 0.3), inset 0 1px 0 rgba(255,255,255,0.15);
  color: #fff;
  padding: 13px 22px;
  position: relative;
  overflow: hidden;
}

.pshina-chat__button::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(212, 160, 23, 0.4), transparent);
  transition: left 600ms ease;
}

.pshina-chat__button:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(41, 105, 18, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}

.pshina-chat__button:hover::before {
  left: 100%;
}

.pshina-chat__button:active {
  transform: translateY(0);
}

.pshina-chat__button:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

.pshina-chat__button--sm {
  padding: 9px 18px;
  font-size: 13px;
}

/* -----------------------------------------------------------
   ROOM
   ----------------------------------------------------------- */
.pshina-chat__room {
  background: var(--pc-cream);
}

.pshina-chat__room-top {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--pc-line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 16px 28px;
}

.pshina-chat__user-info {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.pshina-chat__avatar {
  align-items: center;
  background: linear-gradient(135deg, var(--pc-green), var(--pc-green-light));
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(15, 40, 5, 0.18);
  color: #fff;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  letter-spacing: 0.02em;
  width: 42px;
}

.pshina-chat__room-title {
  color: var(--pc-text);
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 2px;
}

.pshina-chat__identity {
  color: var(--pc-muted);
  font-size: 12px;
  margin: 0;
}

.pshina-chat__ghost {
  align-items: center;
  background: var(--pc-cream-2);
  border: 1px solid var(--pc-line);
  border-radius: 999px;
  color: var(--pc-green-dark);
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
  padding: 8px 16px;
}

.pshina-chat__ghost:hover {
  background: var(--pc-cream);
  border-color: var(--pc-green);
  transform: translateY(-1px);
}

/* -----------------------------------------------------------
   MESSAGES area
   ----------------------------------------------------------- */
.pshina-chat__messages {
  background:
    radial-gradient(circle at 50% 0%, rgba(41, 105, 18, 0.03) 0%, transparent 50%),
    var(--pc-cream);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 500px;
  min-height: 340px;
  overflow-y: auto;
  padding: 22px 28px;
  scroll-behavior: smooth;
}

.pshina-chat__messages::-webkit-scrollbar {
  width: 8px;
}

.pshina-chat__messages::-webkit-scrollbar-track {
  background: transparent;
}

.pshina-chat__messages::-webkit-scrollbar-thumb {
  background: rgba(41, 105, 18, 0.25);
  border-radius: 8px;
}

.pshina-chat__messages::-webkit-scrollbar-thumb:hover {
  background: rgba(41, 105, 18, 0.4);
}

.pshina-chat__empty {
  color: var(--pc-muted);
  font-size: 14px;
  margin: auto;
  text-align: center;
}

.pshina-chat__message {
  animation: pshina-msg-in 360ms cubic-bezier(0.2, 0.9, 0.25, 1);
}

@keyframes pshina-msg-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.pshina-chat__message-row {
  align-items: flex-end;
  display: flex;
  gap: 10px;
  max-width: 82%;
}

.pshina-chat__message--own {
  align-self: flex-end;
}

.pshina-chat__message--own .pshina-chat__message-row {
  flex-direction: row-reverse;
  margin-inline-start: auto;
}

.pshina-chat__bubble {
  background: #fff;
  border: 1px solid var(--pc-line);
  border-radius: 18px;
  box-shadow: var(--pc-shadow-sm);
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  position: relative;
}

/* Tail/arrow on bubbles */
.pshina-chat__message:not(.pshina-chat__message--own) .pshina-chat__bubble {
  border-bottom-right-radius: 4px;
}

.pshina-chat__message--own .pshina-chat__bubble {
  background: linear-gradient(135deg, var(--pc-green) 0%, var(--pc-green-light) 100%);
  border: 1px solid var(--pc-green-dark);
  border-bottom-left-radius: 4px;
  box-shadow: 0 6px 20px rgba(41, 105, 18, 0.28);
  color: #fff;
}

.pshina-chat__message--own .pshina-chat__message-meta {
  color: rgba(255, 255, 255, 0.85);
}

.pshina-chat__message--own .pshina-chat__message-meta strong {
  color: #fff !important;
}

.pshina-chat__message--own .pshina-chat__lang {
  background: rgba(212, 160, 23, 0.95);
  color: var(--pc-green-dark);
}

.pshina-chat__message-meta {
  align-items: center;
  color: var(--pc-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 11px;
  gap: 8px;
  margin-bottom: 4px;
}

.pshina-chat__message-meta strong {
  color: var(--pc-green-dark);
  font-size: 13px;
  font-weight: 800;
}

.pshina-chat__message-meta time {
  font-size: 10px;
  opacity: 0.85;
}

.pshina-chat__lang {
  background: var(--pc-cream-2);
  border-radius: 4px;
  color: var(--pc-green-dark);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 2px 6px;
}

.pshina-chat__message-text {
  font-size: 14.5px;
  line-height: 1.65;
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* -----------------------------------------------------------
   COMPOSER
   ----------------------------------------------------------- */
.pshina-chat__composer {
  background: #fff;
  border-top: 1px solid var(--pc-line);
  padding: 16px 28px;
}

.pshina-chat__composer-inner {
  background: var(--pc-cream);
  border: 1.5px solid var(--pc-line-strong);
  border-radius: 16px;
  overflow: hidden;
  transition: all 200ms ease;
}

.pshina-chat__composer-inner:focus-within {
  background: #fff;
  border-color: var(--pc-green);
  box-shadow: 0 0 0 4px rgba(41, 105, 18, 0.12);
}

.pshina-chat__composer textarea {
  background: transparent;
  border: 0;
  border-radius: 0;
  min-height: 56px;
  padding: 12px 14px 4px;
  resize: none;
}

.pshina-chat__composer textarea:focus {
  box-shadow: none;
  border: 0;
}

.pshina-chat__composer-footer {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 6px 10px 10px;
}

.pshina-chat__counter {
  color: var(--pc-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.pshina-chat__counter--warn {
  color: var(--pc-error);
  font-weight: 800;
}

/* -----------------------------------------------------------
   STATUS + FOOTER
   ----------------------------------------------------------- */
.pshina-chat__status {
  background: #fff;
  border-top: 1px solid var(--pc-line);
  color: var(--pc-muted);
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  margin: 0;
  min-height: 32px;
  padding: 8px 28px;
}

.pshina-chat__status[data-type="success"] {
  color: var(--pc-success);
}

.pshina-chat__status[data-type="error"] {
  color: var(--pc-error);
}

.pshina-chat__status:not(:empty)::before {
  content: "•";
  margin-inline-end: 8px;
  font-size: 16px;
  line-height: 1;
}

.pshina-chat__footer {
  align-items: center;
  background: linear-gradient(135deg, var(--pc-green-dark) 0%, var(--pc-green) 100%);
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  flex-wrap: wrap;
  font-size: 11px;
  font-weight: 600;
  gap: 6px;
  justify-content: center;
  margin: 0;
  padding: 12px 28px;
}

.pshina-chat__footer strong {
  color: var(--pc-gold-light);
  font-weight: 800;
}

/* -----------------------------------------------------------
   LTR mode adjustments
   ----------------------------------------------------------- */
.pshina-chat--ltr {
  direction: ltr;
}

.pshina-chat--ltr .pshina-chat__notice::before {
  margin-inline-end: 8px;
}

.pshina-chat--ltr .pshina-chat__message:not(.pshina-chat__message--own) .pshina-chat__bubble {
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 4px;
}

.pshina-chat--ltr .pshina-chat__message--own .pshina-chat__bubble {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 4px;
}

.pshina-chat--ltr .pshina-chat__message--own .pshina-chat__message-row {
  flex-direction: row-reverse;
}

/* -----------------------------------------------------------
   RESPONSIVE — Mobile & Tablet
   ----------------------------------------------------------- */
@media (max-width: 768px) {
  .pshina-chat {
    margin: 8px;
  }

  .pshina-chat__shell {
    border-radius: 20px;
  }

  .pshina-chat__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 18px;
  }

  .pshina-chat__header-actions {
    align-items: stretch;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
  }

  .pshina-chat__brand {
    font-size: 26px;
  }

  .pshina-chat__intro {
    font-size: 12px;
  }

  .pshina-chat__notice {
    font-size: 12px;
    padding: 10px 18px;
  }

  .pshina-chat__registration {
    padding: 24px 16px;
  }

  .pshina-chat__registration-inner {
    padding: 28px 22px;
  }

  .pshina-chat__room-top {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 18px;
  }

  .pshina-chat__messages {
    max-height: 55vh;
    min-height: 280px;
    padding: 16px;
  }

  .pshina-chat__message-row {
    max-width: 90%;
  }

  .pshina-chat__composer {
    padding: 14px 16px;
  }

  .pshina-chat__status {
    padding: 8px 18px;
  }

  .pshina-chat__footer {
    font-size: 10px;
    padding: 10px 18px;
  }
}

@media (max-width: 480px) {
  .pshina-chat__logo {
    height: 46px;
    width: 46px;
    font-size: 22px;
  }

  .pshina-chat__brand {
    font-size: 22px;
  }

  .pshina-chat__avatar {
    height: 36px;
    width: 36px;
    font-size: 12px;
  }
}
