.kalam-ai-root,
.kalam-ai-root *,
.kalam-ai-root *::before,
.kalam-ai-root *::after {
  box-sizing: border-box;
}

.kalam-ai-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 99990;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  direction: rtl;
  text-align: right;
}

.kalam-ai-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 18px;
  border-radius: 999px !important;
  border: 1.5px solid #C8B48A !important;
  background: linear-gradient(145deg, #274D3D 0%, #1E3B2F 60%, #13281F 100%) !important;
  color: #FFFDF7 !important;
  font-family: inherit !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  line-height: 1.4 !important;
  text-transform: none !important;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(223, 205, 167, 0.45),
    0 4px 0 #0B1912,
    0 12px 24px rgba(17, 36, 27, 0.34);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.kalam-ai-trigger span {
  color: #FFFDF7 !important;
}

.kalam-ai-trigger:hover {
  transform: translateY(-2px);
  border-color: #DFCDA7 !important;
  color: #FFFFFF !important;
  box-shadow:
    inset 0 1px 0 rgba(223, 205, 167, 0.65),
    0 6px 0 #0B1912,
    0 16px 28px rgba(17, 36, 27, 0.4);
}

.kalam-ai-trigger:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 #0B1912,
    0 6px 14px rgba(17, 36, 27, 0.28);
}

.kalam-ai-trigger svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #DFCDA7 !important;
}

.kalam-ai-panel {
  display: none;
  flex-direction: column;
  width: 375px;
  max-width: calc(100vw - 24px);
  height: 540px;
  max-height: 78vh;
  background: #FFFEFA;
  border: 1.5px solid #C8B48A;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 20px 44px rgba(17, 36, 27, 0.26),
    0 4px 12px rgba(17, 36, 27, 0.14);
}

.kalam-ai-panel.is-open {
  display: flex;
}

.kalam-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(145deg, #274D3D 0%, #1E3B2F 100%);
  border-bottom: 2px solid #C8B48A;
  color: #FFFDF7;
}

.kalam-ai-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kalam-ai-title {
  font-size: 15px;
  font-weight: 800;
  color: #FFFDF7;
  margin: 0;
  line-height: 1.4;
}

.kalam-ai-subtitle {
  font-size: 12px;
  color: #DFCDA7;
  margin: 0;
}

.kalam-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kalam-ai-icon-btn {
  width: 32px;
  height: 32px;
  padding: 0 !important;
  border-radius: 9px !important;
  border: 1px solid rgba(200, 180, 138, 0.5) !important;
  background: rgba(255, 255, 255, 0.1) !important;
  color: #FFFDF7 !important;
  font-family: inherit !important;
  font-size: 16px !important;
  line-height: 1 !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.kalam-ai-icon-btn:hover {
  background: rgba(200, 180, 138, 0.28) !important;
  color: #FFFFFF !important;
}

.kalam-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FAF8F3;
}

.kalam-ai-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.kalam-ai-msg.is-bot {
  align-self: flex-start;
  background: #FFFFFF;
  color: #22312A;
  border: 1px solid #E8E2C8;
  border-right: 3px solid #C8B48A;
  border-top-right-radius: 4px;
}

.kalam-ai-msg.is-user {
  align-self: flex-end;
  background: #1E3B2F;
  color: #FFFDF7;
  border: 1px solid #C8B48A;
  border-top-left-radius: 4px;
}

.kalam-ai-msg.is-error {
  align-self: flex-start;
  background: #FFF6F5;
  color: #5E2323;
  border: 1px solid #E7C4C0;
  border-right: 3px solid #C56D65;
  border-top-right-radius: 4px;
}

.kalam-ai-msg a {
  color: #1E3B2F;
  font-weight: 700;
  text-decoration: underline;
}

.kalam-ai-msg.is-user a {
  color: #DFCDA7;
}

.kalam-ai-msg.is-error a {
  color: #5E2323;
}

.kalam-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: #F5F2E9;
  border-top: 1px solid #E8E2C8;
}

.kalam-ai-chip {
  padding: 5px 10px !important;
  border-radius: 999px !important;
  border: 1px solid #C8B48A !important;
  background: #FFFFFF !important;
  color: #1E3B2F !important;
  font-family: inherit !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.kalam-ai-chip:hover {
  background: #1E3B2F !important;
  color: #FFFDF7 !important;
}

.kalam-ai-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #FFFFFF;
  border-top: 1px solid #E8E2C8;
}

.kalam-ai-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #D5CCA9;
  border-radius: 10px;
  background: #FAF8F3;
  color: #22312A;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}

.kalam-ai-input:focus {
  border-color: #1E3B2F;
  background: #FFFFFF;
}

.kalam-ai-send {
  height: 40px;
  padding: 0 14px !important;
  border: 1px solid #C8B48A !important;
  border-radius: 10px !important;
  background: #1E3B2F !important;
  color: #FFFDF7 !important;
  font-family: inherit !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.kalam-ai-send:hover {
  background: #2C5240 !important;
  color: #FFFFFF !important;
}

.kalam-ai-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.kalam-ai-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  background: #F5F2E9;
  border-top: 1px solid #E8E2C8;
  font-size: 12px;
  color: #22312A;
}

.kalam-ai-footer-link {
  color: #1E3B2F;
  font-weight: 700;
  text-decoration: none;
}

.kalam-ai-footer-link:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  .kalam-ai-root {
    right: 12px;
    bottom: 14px;
  }

  .kalam-ai-trigger {
    padding: 10px 14px !important;
    font-size: 13px !important;
  }

  .kalam-ai-panel {
    width: calc(100vw - 24px);
    height: 74vh;
    max-height: 76dvh;
  }

  /* Prevent unwanted iOS Safari auto-zoom on input focus */
  .kalam-ai-input {
    font-size: 16px;
  }
}
